use std::fmt;
use crate::utils::{build_env, define_target_enum};
define_target_enum! {
#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
pub enum Vendor {
Apple => "apple",
Fortanix => "fortanix",
Nvidia => "nvidia",
Pc => "pc",
Sony => "sony",
Unknown => "unknown",
Wrs => "wrs",
Uwp => "uwp",
}
as_str_doc = "String representing this target vendor which matches `#[cfg(target_vendor)]`",
from_str_doc = "Tries to parse the given string as an [`Vendor`] falling back to [`Vendor::Other`] for unknown values.",
}
impl Vendor {
#[must_use]
pub fn target() -> Self {
Self::from_str(build_env("CARGO_CFG_TARGET_VENDOR"))
}
}
impl fmt::Display for Vendor {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}