euv_core/platform/backend/
fn.rs1use super::*;
2
3#[must_use]
9pub fn detect_current_platform() -> PlatformKind {
10 #[cfg(target_arch = "wasm32")]
11 {
12 PlatformKind::Web
13 }
14 #[cfg(target_os = "android")]
15 {
16 PlatformKind::Android
17 }
18 #[cfg(target_os = "ios")]
19 {
20 ios_detect_platform_kind()
21 }
22 #[cfg(target_os = "macos")]
23 {
24 PlatformKind::MacOs
25 }
26 #[cfg(target_os = "windows")]
27 {
28 PlatformKind::Windows
29 }
30 #[cfg(target_os = "linux")]
31 {
32 PlatformKind::Linux
33 }
34 #[cfg(not(any(target_arch = "wasm32", unix, windows)))]
35 {
36 PlatformKind::Headless
37 }
38}
39
40#[must_use]
46pub fn create_native_platform() -> Box<dyn PlatformBackend> {
47 #[cfg(target_arch = "wasm32")]
48 {
49 Box::new(WebPlatform::default())
50 }
51 #[cfg(target_os = "android")]
52 {
53 Box::new(AndroidPlatform::default())
54 }
55 #[cfg(target_os = "ios")]
56 {
57 Box::new(IosPlatform::default())
58 }
59 #[cfg(target_os = "macos")]
60 {
61 Box::new(MacOsPlatform::default())
62 }
63 #[cfg(target_os = "windows")]
64 {
65 Box::new(WindowsPlatform::default())
66 }
67 #[cfg(target_os = "linux")]
68 {
69 Box::new(LinuxPlatform::default())
70 }
71 #[cfg(not(any(target_arch = "wasm32", unix, windows)))]
72 {
73 Box::new(HeadlessPlatform::default())
74 }
75}