1use crate::{Error, Result};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
5#[serde(rename_all = "lowercase")]
6pub enum Platform {
7 Macos,
8 Linux,
9}
10
11impl Platform {
12 pub fn detect() -> Result<Self> {
13 match std::env::consts::OS {
14 "macos" => Ok(Self::Macos),
15 "linux" => Ok(Self::Linux),
16 other => Err(Error::Invalid(format!(
17 "unsupported operating system: {other}"
18 ))),
19 }
20 }
21}
22
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
24#[serde(rename_all = "snake_case")]
25pub enum Architecture {
26 X86_64,
27 Aarch64,
28}
29
30impl Architecture {
31 pub fn detect() -> Result<Self> {
32 match std::env::consts::ARCH {
33 "x86_64" => Ok(Self::X86_64),
34 "aarch64" => Ok(Self::Aarch64),
35 arch => Err(Error::Invalid(format!("unsupported architecture: {arch}"))),
36 }
37 }
38}