Files
spacedrive/core/src/node/platform.rs
Oscar Beaumont fdd1c5e1e4 Cloud + P2P (#1970)
* P2P Debug route

* Remove legacy peer to peer pairing process

* Fix error typo

* Sync instances with cloud

* Upgrade deps + extended instance data

* Create instance with extended metadata

* Auto sync instances

* Actually `.await`

* bruh

* sync library info

* this isn't gonna work

* only sleep cloud receiver when no more messages (#1985)

* [ENG-1567] Fix renaming (#1986)

fix rename

* only sleep cloud receiver when no more messages

* use in memory instances during cloud receive (#1995)

* use in memory instances during cloud receive

* is_empty

---------

Co-authored-by: nikec <43032218+niikeec@users.noreply.github.com>

* fix type error

* wip

* make mdns mdns better

* response

* remove renames

---------

Co-authored-by: Brendan Allan <brendonovich@outlook.com>
Co-authored-by: nikec <43032218+niikeec@users.noreply.github.com>
2024-02-02 09:31:11 +00:00

63 lines
1.1 KiB
Rust

use crate::NodeError;
use serde::{Deserialize, Serialize};
use specta::Type;
#[allow(clippy::upper_case_acronyms)]
#[repr(u8)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Type, Eq, PartialEq)]
pub enum Platform {
Unknown = 0,
Windows = 1,
MacOS = 2,
Linux = 3,
IOS = 4,
Android = 5,
}
impl Platform {
#[allow(unreachable_code)]
pub fn current() -> Self {
#[cfg(target_os = "windows")]
return Self::Windows;
#[cfg(target_os = "macos")]
return Self::MacOS;
#[cfg(target_os = "linux")]
return Self::Linux;
#[cfg(target_os = "ios")]
return Self::IOS;
#[cfg(target_os = "android")]
return Self::Android;
Self::Unknown
}
}
impl TryFrom<u8> for Platform {
type Error = NodeError;
fn try_from(value: u8) -> Result<Self, Self::Error> {
let s = match value {
0 => Self::Unknown,
1 => Self::Windows,
2 => Self::MacOS,
3 => Self::Linux,
4 => Self::IOS,
5 => Self::Android,
_ => return Err(NodeError::InvalidPlatformInt(value)),
};
Ok(s)
}
}
impl From<Platform> for u8 {
fn from(platform: Platform) -> Self {
platform as u8
}
}