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<Index, Error>
pub fn build(mana_dir: &Path) -> Result<Index, Error>
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, Error>
pub fn is_stale(mana_dir: &Path) -> Result<bool, Error>
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<Index, Error>
pub fn load_or_rebuild(mana_dir: &Path) -> Result<Index, Error>
Load the cached index or rebuild it if stale. This is the main entry point for read-heavy commands.
Sourcepub fn load(mana_dir: &Path) -> Result<Index, Error>
pub fn load(mana_dir: &Path) -> Result<Index, Error>
Load the index from the cached index.yaml file.
Sourcepub fn collect_archived(mana_dir: &Path) -> Result<Vec<IndexEntry>, Error>
pub fn collect_archived(mana_dir: &Path) -> Result<Vec<IndexEntry>, Error>
Collect all archived units from .mana/archive/ directory. Walks through year/month subdirectories and loads all unit files. Returns IndexEntry items for archived units.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Index
impl<'de> Deserialize<'de> for Index
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Index, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Index, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Index
impl Serialize for Index
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Index
Auto Trait Implementations§
impl Freeze for Index
impl RefUnwindSafe for Index
impl Send for Index
impl Sync for Index
impl Unpin for Index
impl UnsafeUnpin for Index
impl UnwindSafe for Index
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more