buddy_slab_allocator/
error.rs1use core::fmt;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum AllocError {
6 InvalidParam,
8 MemoryOverlap,
10 NoMemory,
12 NotAllocated,
14 NotInitialized,
16 NotFound,
18}
19
20impl fmt::Display for AllocError {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 match self {
23 Self::InvalidParam => write!(f, "invalid parameter"),
24 Self::MemoryOverlap => write!(f, "memory regions overlap"),
25 Self::NoMemory => write!(f, "out of memory"),
26 Self::NotAllocated => write!(f, "memory not allocated"),
27 Self::NotInitialized => write!(f, "allocator not initialized"),
28 Self::NotFound => write!(f, "not found"),
29 }
30 }
31}
32
33pub type AllocResult<T = ()> = Result<T, AllocError>;