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