pub mod align;
mod buddy;
use std::num::NonZeroU64;
pub use buddy::{BuddyAllocation, BuddyAllocator};
pub mod linear;
pub use linear::LinearAllocator;
use thiserror::Error;
pub trait Allocation {
fn offset(&self) -> u64;
fn size(&self) -> u64;
}
#[derive(Error, Debug)]
#[error("OOM")]
pub struct OutOfMemory;
pub trait Allocator {
type Allocation: Allocation;
fn allocate(
&mut self,
size: NonZeroU64,
alignment: NonZeroU64,
) -> Result<Self::Allocation, OutOfMemory>;
fn from_properties(min_alloc: u64, capacity: NonZeroU64) -> Self;
}
pub trait Deallocator: Allocator {
fn deallocate(&mut self, alloc: &Self::Allocation);
}