use core::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct CoreId(u64);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct IdError;
impl CoreId {
pub const fn new(value: u64) -> Result<Self, IdError> {
if value == 0 {
Err(IdError)
} else {
Ok(Self(value))
}
}
pub const fn get(self) -> u64 {
self.0
}
}
impl fmt::Display for CoreId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
impl fmt::Display for IdError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("core identifier must be non-zero")
}
}
impl std::error::Error for IdError {}