//! [TSM.ID].[11031972] — Platform X Ecosystem
//! xcu-garbage-collector — Deterministic Memory Cleaner
#![deny(warnings)]
#![allow(dead_code)]

pub mod collector;
pub mod tracker;

#[derive(Debug)]
pub enum GcError {
    AllocationFailed,
    InvalidReference,
    CollectionFailed(String),
    HeapCorrupted,
}
impl std::fmt::Display for GcError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::AllocationFailed => write!(f, "Allocation failed"),
            Self::InvalidReference => write!(f, "Invalid reference"),
            Self::CollectionFailed(e) => write!(f, "Collection failed: {e}"),
            Self::HeapCorrupted => write!(f, "Heap corrupted"),
        }
    }
}
impl std::error::Error for GcError {}
pub type Result<T> = std::result::Result<T, GcError>;

#[derive(Debug, Clone, Copy, PartialEq)]
pub enum GcColor { White, Gray, Black }

pub struct GcConfig {
    pub heap_size: usize,
    pub threshold: usize,
    pub generation_count: u8,
}

impl Default for GcConfig {
    fn default() -> Self { Self { heap_size: 1_048_576, threshold: 768_000, generation_count: 3 } }
}
