Struct FSRepo

Source
pub struct FSRepo {
    pub base_dir: PathBuf,
    pub config: Config,
    pub git_repo: GitRepo,
}
Expand description

Filesystem-backed implementation of SnippetRepository.

Snippets are stored under a root base_dir, each in a dedicated subdirectory named by slug. Each snippet directory contains:

  • meta.toml: metadata (name, tags, language, etc.)
  • content.<ext>: raw snippet content file Additionally, base_dir contains:
  • snippets/: all snippet folders
  • history/: reserved for future versioning/history features
  • config.toml: configuration file (created if missing)

Fields§

§base_dir: PathBuf

Root directory containing all snippet data.

§config: Config§git_repo: GitRepo

Implementations§

Source§

impl FSRepo

Source

pub fn new<P: AsRef<Path>>(path: P) -> Result<Self, NibbError>

Creates a new FSRepo and ensures the necessary folder structure exists.

Will create snippets/, history/, and config.toml if missing.

Source

pub fn snippet_path(&self, slug: &str) -> PathBuf

Returns the path to a snippet’s directory based on its slug.

Trait Implementations§

Source§

impl SnippetRepository for FSRepo

Source§

fn load_all(&self) -> Result<Vec<Snippet>, NibbError>

Loads all snippets by iterating through the snippets/ directory and deserializing each snippet from meta.toml and its content file.

Source§

fn load(&self, slug: &str) -> Result<Snippet, NibbError>

Loads a specific snippet by slug.

Reads metadata from meta.toml and content from content.<ext>.

Source§

fn save(&self, snippet: &Snippet) -> Result<(), NibbError>

Saves a single snippet to disk.

Creates the snippet folder and both metadata/content files if they don’t exist.

Source§

fn save_all(&self, snippets: &[Snippet]) -> Result<(), NibbError>

Saves a list of snippets.

Calls save() for each snippet.

Source§

fn delete(&self, slug: &str) -> Result<(), NibbError>

Deletes the snippet directory and all its contents.

Auto Trait Implementations§

§

impl Freeze for FSRepo

§

impl RefUnwindSafe for FSRepo

§

impl Send for FSRepo

§

impl !Sync for FSRepo

§

impl Unpin for FSRepo

§

impl UnwindSafe for FSRepo

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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,