pub struct Index {
pub units: Vec<IndexEntry>,
}Expand description
The in-memory and on-disk unit index.
Holds a flat list of IndexEntry values for all active (non-archived)
units in the project. Archived units are stored separately in
.mana/archive/ and are not included here.
Obtain an index via Index::load_or_rebuild (lazy, cached) or
Index::build (always scans unit files from disk).
Fields§
§units: Vec<IndexEntry>All active units, sorted by ID in natural order.
Implementations§
Source§impl Index
impl Index
Sourcepub fn build(mana_dir: &Path) -> Result<Self>
pub fn build(mana_dir: &Path) -> Result<Self>
Build the index by reading all unit files from the units directory. Supports both new format ({id}-{slug}.md) and legacy format ({id}.yaml). Excludes config.yaml, index.yaml, and unit.yaml. Sorts entries by ID using natural ordering. Returns an error if duplicate unit IDs are detected.
Sourcepub fn is_stale(mana_dir: &Path) -> Result<bool>
pub fn is_stale(mana_dir: &Path) -> Result<bool>
Check whether the cached index is stale. Returns true if the index file is missing or if any unit file (.md or .yaml) in the units directory has been modified after the index was last written.
Sourcepub fn load_or_rebuild(mana_dir: &Path) -> Result<Self>
pub fn load_or_rebuild(mana_dir: &Path) -> Result<Self>
Load the cached index or rebuild it if stale. This is the main entry point for read-heavy commands.
Sourcepub fn collect_archived(mana_dir: &Path) -> Result<Vec<IndexEntry>>
pub fn collect_archived(mana_dir: &Path) -> Result<Vec<IndexEntry>>
Collect all archived units from .mana/archive/ directory. Walks through year/month subdirectories and loads all unit files. Returns IndexEntry items for archived units.