1use std::fmt;
2
3use crate::utils::{build_env, define_target_enum};
4
5define_target_enum! {
6 #[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
8 #[non_exhaustive]
9 pub enum Vendor {
10 Apple => "apple",
12 Fortanix => "fortanix",
14 Nvidia => "nvidia",
16 Pc => "pc",
18 Sony => "sony",
20 Unknown => "unknown",
22 Wrs => "wrs",
24 Uwp => "uwp",
26 }
27
28 as_str_doc = "String representing this target vendor which matches `#[cfg(target_vendor)]`",
29 from_str_doc = "Tries to parse the given string as an [`Vendor`] falling back to [`Vendor::Other`] for unknown values.",
30}
31
32impl Vendor {
33 #[must_use]
35 pub fn target() -> Self {
36 Self::from_str(build_env("CARGO_CFG_TARGET_VENDOR"))
37 }
38}
39
40impl fmt::Display for Vendor {
41 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42 f.write_str(self.as_str())
43 }
44}