pub struct Store { /* private fields */ }Implementations§
Source§impl Store
impl Store
pub fn new(storage_dir: impl Into<PathBuf>) -> Self
Sourcepub fn find_file(&self, date: NaiveDate) -> Option<PathBuf>
pub fn find_file(&self, date: NaiveDate) -> Option<PathBuf>
First .mps file matching date, or None.
Sourcepub fn find_files(&self, date: NaiveDate) -> Vec<PathBuf>
pub fn find_files(&self, date: NaiveDate) -> Vec<PathBuf>
All .mps files matching date (handles multiple files per day).
Sourcepub fn find_or_create_path(&self, date: NaiveDate) -> PathBuf
pub fn find_or_create_path(&self, date: NaiveDate) -> PathBuf
Existing file for date, or a generated new path (file not yet created).
Sourcepub fn parse_date(
&self,
date: NaiveDate,
) -> Result<IndexMap<String, Element>, MpsError>
pub fn parse_date( &self, date: NaiveDate, ) -> Result<IndexMap<String, Element>, MpsError>
Parsed elements for date. Returns empty map if no file exists.
Sourcepub fn append(
&self,
kind: &str,
body: &str,
tags: &[String],
attrs: &[(&str, &str)],
date: NaiveDate,
) -> Result<PathBuf, MpsError>
pub fn append( &self, kind: &str, body: &str, tags: &[String], attrs: &[(&str, &str)], date: NaiveDate, ) -> Result<PathBuf, MpsError>
Append a new element to date’s file (creates file if absent).
Sourcepub fn all_files(&self) -> Result<Vec<PathBuf>, MpsError>
pub fn all_files(&self) -> Result<Vec<PathBuf>, MpsError>
All .mps files in storage_dir, sorted by filename (chronological).
Sourcepub fn files_since(
&self,
since_date: NaiveDate,
) -> Result<Vec<PathBuf>, MpsError>
pub fn files_since( &self, since_date: NaiveDate, ) -> Result<Vec<PathBuf>, MpsError>
Files whose date-stamp >= since_date.
Sourcepub fn all_file_dates(&self) -> Result<Vec<NaiveDate>, MpsError>
pub fn all_file_dates(&self) -> Result<Vec<NaiveDate>, MpsError>
Unique sorted dates for which .mps files exist.
Sourcepub fn rewrite_element(
&self,
ref_str: &str,
new_attrs: &HashMap<String, String>,
date: NaiveDate,
) -> Result<bool, MpsError>
pub fn rewrite_element( &self, ref_str: &str, new_attrs: &HashMap<String, String>, date: NaiveDate, ) -> Result<bool, MpsError>
Rewrite an element’s typed attributes in-place, atomically.
ref_str may be an epoch ref (e.g. “20260428.1”) or a human ref (e.g. “task-1”).
Human refs are resolved against date (defaults to today in the caller).
new_attrs maps attribute name → new value (e.g. {“status” → “done”}).
Returns true on success, false if ref not found or file unchanged.