#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum SlabError {
OutOfMemory,
AlignmentMismatch,
InvalidPointer,
FatalError,
}
impl core::fmt::Display for SlabError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::OutOfMemory => write!(f, "Memory allocation failed: Out of memory"),
Self::AlignmentMismatch => {
write!(f, "Memory alignment is incorrect for this operation")
}
Self::InvalidPointer => write!(f, "Attempted to use an invalid or null pointer"),
Self::FatalError => write!(f, "A fatal system error occurred"),
}
}
}
impl core::error::Error for SlabError {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
None
}
}
pub type Result<T> = core::result::Result<T, SlabError>;