memkit 0.2.0-beta.1

Deterministic, intent-driven memory allocation for systems requiring predictable performance
Documentation
//! Allocation tagging and intent.

/// Describes the intended lifetime and usage of an allocation.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum MkIntent {
    /// Frame-temporary allocation.
    #[default]
    Frame,
    /// Short-lived allocation from object pool.
    Pool,
    /// Long-lived allocation from heap.
    Heap,
}

/// A tag for categorizing allocations.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MkTag {
    name: &'static str,
}

impl MkTag {
    /// Create a new tag.
    pub const fn new(name: &'static str) -> Self {
        Self { name }
    }

    /// Get the tag name.
    pub fn name(&self) -> &'static str {
        self.name
    }
}

// Common predefined tags
impl MkTag {
    pub const RENDERING: Self = Self::new("rendering");
    pub const PHYSICS: Self = Self::new("physics");
    pub const AUDIO: Self = Self::new("audio");
    pub const SCRIPTING: Self = Self::new("scripting");
    pub const ASSETS: Self = Self::new("assets");
    pub const UI: Self = Self::new("ui");
    pub const NETWORKING: Self = Self::new("networking");
    pub const GENERAL: Self = Self::new("general");
}