pub struct Store { /* private fields */ }Expand description
The data folder where tasks are stored.
Implementations§
Source§impl Store
impl Store
Sourcepub fn open() -> Result<Self>
pub fn open() -> Result<Self>
The nearest .brain/ in the current directory or above it, so each project’s repository
keeps its own; else the central brain ($KANBRAIN_DIR, else the platform data dir, e.g.
~/.local/share/kanbrain).
Sourcepub fn open_named(name: Option<&str>) -> Result<Self>
pub fn open_named(name: Option<&str>) -> Result<Self>
The brain of the project registered as name (central for the central one), from anywhere;
without a name, the one Store::open finds.
Sourcepub fn project(&self) -> Option<String>
pub fn project(&self) -> Option<String>
The project’s name: the one on its card (project.md), else the folder holding .brain/;
None for the central brain.
Sourcepub fn record(&self)
pub fn record(&self)
Starts recording the files written or deleted from now on, so they can be put back (see undo).
Sourcepub fn recorded(&self) -> Vec<Change>
pub fn recorded(&self) -> Vec<Change>
Stops recording, and returns what was recorded, with what each file holds now.
Sourcepub fn reports_dir(&self) -> PathBuf
pub fn reports_dir(&self) -> PathBuf
Where report exports are written.
Sourcepub fn load(&self) -> Result<(Vec<Task>, Vec<String>)>
pub fn load(&self) -> Result<(Vec<Task>, Vec<String>)>
Returns the parsed tasks plus a warning for every file that could not be read.
Sourcepub fn save(&self, task: &mut Task) -> Result<()>
pub fn save(&self, task: &mut Task) -> Result<()>
Writes atomically and renames the file when the title (slug) changed.
Sourcepub fn delete(&self, task: &Task) -> Result<()>
pub fn delete(&self, task: &Task) -> Result<()>
Removes the task’s file. Refuses anything outside the data folder.
Sourcepub fn last_id(&self) -> u32
pub fn last_id(&self) -> u32
The highest id given so far, as last-id keeps it; 0 when it’s missing (a folder from an older
version) or unreadable, and then the entries’ own ids are all there is to go by.
Sourcepub fn save_last_id(&self, id: u32) -> Result<()>
pub fn save_last_id(&self, id: u32) -> Result<()>
Writes last-id.
Sourcepub fn load_tag_colors(&self) -> Result<TagColors>
pub fn load_tag_colors(&self) -> Result<TagColors>
Reads tags.md; no file means no colors assigned yet.
Sourcepub fn save_tag_colors(&self, colors: &TagColors) -> Result<()>
pub fn save_tag_colors(&self, colors: &TagColors) -> Result<()>
Writes tags.md.