leyline-engine 0.1.0

Storage engine: IDs, segments, CSR adjacency, manifest, LSM
Documentation
//! The manifest: the mutable pointer that makes a set of segments *the*
//! graph. Swapping it is the only mutation in the system (docs/SEGMENTS.md).

use serde::{Deserialize, Serialize};

pub const FORMAT_VERSION: u32 = 1;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Manifest {
    pub format_version: u32,
    /// Monotonic; every committed flush or compaction bumps it. Surfaced by
    /// the API as `manifestGeneration`.
    pub generation: u64,
    /// Append-only: a label's index is its identity in every segment ever
    /// written. Compaction may not renumber.
    pub labels: Vec<String>,
    /// Id allocation resumes above everything ever committed.
    pub next_node_id: u64,
    pub node_count: u64,
    pub edge_count: u64,
    /// Oldest → newest.
    pub segments: Vec<SegmentMeta>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SegmentMeta {
    pub name: String,
    pub level: u32,
    pub edges: u64,
    pub bytes: u64,
}

impl Manifest {
    pub fn empty() -> Self {
        Self {
            format_version: FORMAT_VERSION,
            generation: 0,
            labels: Vec::new(),
            next_node_id: 0,
            node_count: 0,
            edge_count: 0,
            segments: Vec::new(),
        }
    }
}