memkit 0.2.0-beta.1

Deterministic, intent-driven memory allocation for systems requiring predictable performance
Documentation
//! Core traits for memkit.

use crate::tag::MkTag;

/// Core allocator trait.
pub trait Allocator {
    /// Allocate memory with the given layout.
    fn allocate(&self, layout: std::alloc::Layout) -> *mut u8;
    
    /// Deallocate memory.
    ///
    /// # Safety
    ///
    /// The pointer must have been allocated by this allocator.
    unsafe fn deallocate(&self, ptr: *mut u8, layout: std::alloc::Layout);
}

/// Trait for types that can be reset.
pub trait Resettable {
    /// Reset to initial state.
    fn reset(&mut self);
}

/// Trait for tagged allocations.
pub trait Tagged {
    /// Set the tag for this allocation.
    fn set_tag(&mut self, tag: MkTag);
    
    /// Get the current tag.
    fn tag(&self) -> Option<&MkTag>;
}