#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Serialize, Deserialize)]
pub enum MemoryChannels
{
#[allow(missing_docs)]
One = 1,
#[allow(missing_docs)]
Two = 2,
#[allow(missing_docs)]
Three = 3,
#[allow(missing_docs)]
Four = 4,
}
impl MemoryChannels
{
#[inline(always)]
pub fn configured_number_of_memory_channels() -> Option<MemoryChannels>
{
let channels = unsafe { rte_memory_get_nchannel() };
if channels == 0
{
return None
}
if channels > 4
{
panic!("Invalid number of memory channels '{}'", channels)
}
Some(unsafe { transmute(channels) })
}
#[inline(always)]
pub fn as_initialization_argument(self) -> ConstCStr
{
use self::MemoryChannels::*;
match self
{
One => ConstCStr(b"1\0"),
Two => ConstCStr(b"2\0"),
Three => ConstCStr(b"3\0"),
Four => ConstCStr(b"4\0"),
}
}
}