whoami/
platform.rs
1use std::fmt::{self, Display, Formatter};
2
3#[allow(missing_docs)]
5#[derive(Debug, PartialEq, Eq, Clone)]
6#[non_exhaustive]
7pub enum Platform {
8 Linux,
9 Bsd,
10 Windows,
11 MacOS,
14 Illumos,
15 Ios,
16 Android,
17 Nintendo,
20 Xbox,
22 PlayStation,
23 Fuchsia,
24 Redox,
25 Unknown(String),
26}
27
28impl Display for Platform {
29 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
30 if let Self::Unknown(_) = self {
31 f.write_str("Unknown: ")?;
32 }
33
34 f.write_str(match self {
35 Self::Linux => "Linux",
36 Self::Bsd => "BSD",
37 Self::Windows => "Windows",
38 Self::MacOS => "Mac OS",
39 Self::Illumos => "illumos",
40 Self::Ios => "iOS",
41 Self::Android => "Android",
42 Self::Nintendo => "Nintendo",
43 Self::Xbox => "XBox",
44 Self::PlayStation => "PlayStation",
45 Self::Fuchsia => "Fuchsia",
46 Self::Redox => "Redox",
47 Self::Unknown(a) => a,
48 })
49 }
50}