use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum HostClass {
H0,
H1,
H2,
H3,
H4,
H5,
}
impl HostClass {
pub const ALL: [Self; 6] = [Self::H0, Self::H1, Self::H2, Self::H3, Self::H4, Self::H5];
#[must_use]
pub const fn label(self) -> &'static str {
match self {
Self::H0 => "H0",
Self::H1 => "H1",
Self::H2 => "H2",
Self::H3 => "H3",
Self::H4 => "H4",
Self::H5 => "H5",
}
}
#[must_use]
pub fn detect() -> Self {
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
{
return Self::H5;
}
#[cfg(not(target_os = "linux"))]
{
return Self::H4;
}
#[cfg(all(target_os = "linux", any(target_arch = "x86", target_arch = "x86_64")))]
{
let hw = crate::hw_probe::probe_hardware();
if hw.gpu_available && !hw.gpu_is_software {
Self::H2
} else if hw.gpu_available && hw.gpu_is_software {
Self::H3
} else if hw.hyperscan_available {
Self::H1
} else {
Self::H0
}
}
}
}