tilepad_manifest/
system.rs1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3use strum::{Display, EnumString};
4
5#[derive(
7 Debug, Clone, Copy, PartialEq, Eq, EnumString, Display, Serialize, Deserialize, JsonSchema,
8)]
9#[serde(rename_all = "lowercase")]
10pub enum OperatingSystem {
11 #[strum(serialize = "windows")]
12 Windows,
13 #[strum(serialize = "macos")]
14 MacOs,
15 #[strum(serialize = "linux")]
16 Linux,
17}
18
19impl Default for OperatingSystem {
20 fn default() -> Self {
21 platform_os()
22 }
23}
24
25#[cfg(target_os = "windows")]
26pub fn platform_os() -> OperatingSystem {
27 OperatingSystem::Windows
28}
29
30#[cfg(target_os = "macos")]
31pub fn platform_os() -> OperatingSystem {
32 OperatingSystem::MacOs
33}
34
35#[cfg(target_os = "linux")]
36pub fn platform_os() -> OperatingSystem {
37 OperatingSystem::Linux
38}
39
40#[derive(
42 Debug, Clone, Copy, PartialEq, Eq, EnumString, Display, Serialize, Deserialize, JsonSchema,
43)]
44#[serde(rename_all = "lowercase")]
45pub enum Arch {
46 #[strum(serialize = "x86")]
47 X86,
48 #[strum(serialize = "x64")]
49 X64,
50 #[strum(serialize = "arm")]
51 Arm,
52 #[strum(serialize = "arm64")]
53 Arm64,
54}
55
56impl Default for Arch {
57 fn default() -> Self {
58 platform_arch()
59 }
60}
61
62#[cfg(all(
63 target_pointer_width = "64",
64 not(any(target_arch = "arm", target_arch = "aarch64"))
65))]
66pub fn platform_arch() -> Arch {
67 Arch::X64
68}
69
70#[cfg(all(
71 target_pointer_width = "32",
72 not(any(target_arch = "arm", target_arch = "aarch64"))
73))]
74pub fn platform_arch() -> Arch {
75 Arch::X86
76}
77
78#[cfg(all(
79 target_pointer_width = "64",
80 any(target_arch = "arm", target_arch = "aarch64")
81))]
82pub fn platform_arch() -> Arch {
83 Arch::Arm64
84}
85
86#[cfg(all(
87 target_pointer_width = "32",
88 any(target_arch = "arm", target_arch = "aarch64")
89))]
90pub fn platform_arch() -> Arch {
91 Arch::Arm
92}