1use super::*;
2
3impl PlatformKind {
5 #[must_use]
15 pub const fn as_str(&self) -> &'static str {
16 match *self {
17 Self::Web => PLATFORM_NAME_WEB,
18 Self::Android => PLATFORM_NAME_ANDROID,
19 Self::Ios => PLATFORM_NAME_IOS,
20 Self::IpadOs => PLATFORM_NAME_IPADOS,
21 Self::MacOs => PLATFORM_NAME_MACOS,
22 Self::Windows => PLATFORM_NAME_WINDOWS,
23 Self::Linux => PLATFORM_NAME_LINUX,
24 Self::Headless => PLATFORM_NAME_HEADLESS,
25 }
26 }
27
28 #[must_use]
38 pub const fn form_factor(&self) -> DeviceFormFactor {
39 match *self {
40 Self::MacOs | Self::Windows | Self::Linux => DeviceFormFactor::Desktop,
41 Self::IpadOs => DeviceFormFactor::Tablet,
42 Self::Ios | Self::Android => DeviceFormFactor::Phone,
43 Self::Web => DeviceFormFactor::Browser,
44 Self::Headless => DeviceFormFactor::Headless,
45 }
46 }
47
48 #[must_use]
58 pub const fn is_mobile_or_tablet(&self) -> bool {
59 matches!(*self, Self::Android | Self::Ios | Self::IpadOs)
60 }
61
62 #[must_use]
68 pub const fn all_targets() -> [Self; 7] {
69 [
70 Self::Web,
71 Self::Android,
72 Self::Ios,
73 Self::IpadOs,
74 Self::MacOs,
75 Self::Windows,
76 Self::Linux,
77 ]
78 }
79}
80
81impl PlatformCapabilities {
83 #[must_use]
93 pub fn for_platform(platform: PlatformKind) -> Self {
94 match platform {
95 PlatformKind::MacOs => Self {
96 multi_window: true,
97 hover_pointer: true,
98 touch: false,
99 stylus: false,
100 hardware_keyboard: true,
101 safe_area_insets: false,
102 hardware_gpu: true,
103 software_blit: true,
104 clipboard: true,
105 ime: true,
106 dynamic_island: false,
107 live_activities: false,
108 system_tray: true,
109 biometrics: true,
110 haptics: true,
111 protocol_handler: true,
112 accessibility_bridge: true,
113 },
114 PlatformKind::Windows => Self {
115 multi_window: true,
116 hover_pointer: true,
117 touch: false,
118 stylus: false,
119 hardware_keyboard: true,
120 safe_area_insets: false,
121 hardware_gpu: true,
122 software_blit: true,
123 clipboard: true,
124 ime: true,
125 dynamic_island: false,
126 live_activities: false,
127 system_tray: true,
128 biometrics: true,
129 haptics: false,
130 protocol_handler: true,
131 accessibility_bridge: true,
132 },
133 PlatformKind::Linux => Self {
134 multi_window: true,
135 hover_pointer: true,
136 touch: false,
137 stylus: false,
138 hardware_keyboard: true,
139 safe_area_insets: false,
140 hardware_gpu: true,
141 software_blit: true,
142 clipboard: true,
143 ime: true,
144 dynamic_island: false,
145 live_activities: false,
146 system_tray: true,
147 biometrics: false,
148 haptics: false,
149 protocol_handler: true,
150 accessibility_bridge: true,
151 },
152 PlatformKind::IpadOs => Self {
153 multi_window: true,
154 hover_pointer: true,
155 touch: true,
156 stylus: true,
157 hardware_keyboard: true,
158 safe_area_insets: true,
159 hardware_gpu: true,
160 software_blit: true,
161 clipboard: true,
162 ime: true,
163 dynamic_island: false,
164 live_activities: true,
165 system_tray: false,
166 biometrics: true,
167 haptics: true,
168 protocol_handler: true,
169 accessibility_bridge: true,
170 },
171 PlatformKind::Ios => Self {
172 multi_window: false,
173 hover_pointer: false,
174 touch: true,
175 stylus: true,
176 hardware_keyboard: false,
177 safe_area_insets: true,
178 hardware_gpu: true,
179 software_blit: true,
180 clipboard: true,
181 ime: true,
182 dynamic_island: true,
183 live_activities: true,
184 system_tray: false,
185 biometrics: true,
186 haptics: true,
187 protocol_handler: true,
188 accessibility_bridge: true,
189 },
190 PlatformKind::Android => Self {
191 multi_window: false,
192 hover_pointer: false,
193 touch: true,
194 stylus: true,
195 hardware_keyboard: false,
196 safe_area_insets: true,
197 hardware_gpu: true,
198 software_blit: true,
199 clipboard: true,
200 ime: true,
201 dynamic_island: false,
202 live_activities: true,
203 system_tray: false,
204 biometrics: true,
205 haptics: true,
206 protocol_handler: true,
207 accessibility_bridge: true,
208 },
209 PlatformKind::Web => Self {
210 multi_window: false,
211 hover_pointer: true,
212 touch: true,
213 stylus: true,
214 hardware_keyboard: true,
215 safe_area_insets: true,
216 hardware_gpu: true,
217 software_blit: true,
218 clipboard: true,
219 ime: true,
220 dynamic_island: false,
221 live_activities: false,
222 system_tray: false,
223 biometrics: true,
224 haptics: true,
225 protocol_handler: true,
226 accessibility_bridge: true,
227 },
228 PlatformKind::Headless => Self {
229 multi_window: true,
230 hover_pointer: true,
231 touch: true,
232 stylus: false,
233 hardware_keyboard: true,
234 safe_area_insets: true,
235 hardware_gpu: false,
236 software_blit: true,
237 clipboard: true,
238 ime: true,
239 dynamic_island: false,
240 live_activities: false,
241 system_tray: true,
242 biometrics: false,
243 haptics: false,
244 protocol_handler: true,
245 accessibility_bridge: true,
246 },
247 }
248 }
249}