Skip to main content

objectiveai_sdk/filesystem/plugins/
platform.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4/// A supported runtime target — the cross product of OS and CPU
5/// architecture the cli knows how to install plugin binaries for.
6/// Serialized as `<os>_<arch>` (e.g. `"linux_x86_64"`,
7/// `"windows_aarch64"`). Used as the key type in
8/// [`super::Manifest::binaries`] so a manifest can declare a distinct
9/// release-asset filename per platform. The underscore separator (vs
10/// the hyphen used by Rust target triples) keeps the names usable
11/// directly as identifiers in the cross-language SDK codegen.
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
13#[schemars(rename = "filesystem.plugins.Platform")]
14pub enum Platform {
15    #[serde(rename = "linux_x86_64")]
16    LinuxX86_64,
17    #[serde(rename = "linux_aarch64")]
18    LinuxAarch64,
19    #[serde(rename = "windows_x86_64")]
20    WindowsX86_64,
21    #[serde(rename = "windows_aarch64")]
22    WindowsAarch64,
23    #[serde(rename = "macos_x86_64")]
24    MacosX86_64,
25    #[serde(rename = "macos_aarch64")]
26    MacosAarch64,
27}
28
29impl Platform {
30    /// The platform this binary was built for, if recognized. Returns
31    /// `None` on exotic build targets (BSD, RISC-V, 32-bit ARM, etc.)
32    /// — those simply have no manifest binding.
33    pub fn current() -> Option<Self> {
34        match (std::env::consts::OS, std::env::consts::ARCH) {
35            ("linux", "x86_64") => Some(Self::LinuxX86_64),
36            ("linux", "aarch64") => Some(Self::LinuxAarch64),
37            ("windows", "x86_64") => Some(Self::WindowsX86_64),
38            ("windows", "aarch64") => Some(Self::WindowsAarch64),
39            ("macos", "x86_64") => Some(Self::MacosX86_64),
40            ("macos", "aarch64") => Some(Self::MacosAarch64),
41            _ => None,
42        }
43    }
44}