Skip to main content

DocumentStore

Struct DocumentStore 

Source
pub struct DocumentStore { /* private fields */ }

Implementations§

Source§

impl DocumentStore

Source

pub fn new(base_path: PathBuf) -> Self

Source

pub fn base_path(&self) -> &Path

The root directory this store reads notes from.

Source

pub fn path_for(&self, name: &str) -> PathBuf

Resolve the on-disk path for a note name (with or without a .md extension), without reading the file. Used e.g. to move a note when renaming it.

We deliberately do not rely on Path::extension, which would treat the trailing part of a dotted note name (e.g. “sprint-q2.6”) as the extension and skip adding .md.

Source

pub fn load(&self, name: &str) -> Result<Document, String>

Load a document by name (with or without .md extension) If the file doesn’t exist, creates an empty document that will be saved on first write

Source

pub fn list_all_documents(&self) -> Result<Vec<String>, String>

Recursively list all markdown files in the directory and subdirectories Returns relative paths from base_path (e.g., “project-a/standup”)

Source

pub fn save(&self, doc: &Document) -> Result<(), String>

Save document content Creates parent directories if they don’t exist

Source

pub fn delete(&self, name: &str) -> Result<(), String>

Delete a note’s file from disk.

A note that was never written (e.g. a brand-new, never-typed-into note) has no file yet; a missing file is treated as success so that deleting always leaves the note gone. Only a real I/O failure returns an error.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.