pub fn get_unit(mana_dir: &Path, id: &str) -> Result<Unit, ManaError>Expand description
Load a unit by ID.
Finds the unit file in the .mana/ directory and deserializes it.
Works for active (non-archived) units only. For archived units, use
get_archived_unit.
§Errors
ManaError::UnitNotFound— no unit file for the given IDManaError::InvalidId— ID is empty or contains invalid charactersManaError::ParseError— file cannot be deserializedManaError::IoError— filesystem failure
§Example
use mana_core::api::get_unit;
use std::path::Path;
let mana_dir = Path::new("/project/.mana");
let unit = get_unit(mana_dir, "42").unwrap();
println!("{}: {}", unit.id, unit.title);