pub trait SnippetRepository {
// Required methods
fn load_all(&self) -> Result<Vec<Snippet>, NibbError>;
fn load(&self, slug: &str) -> Result<Snippet, NibbError>;
fn save(&self, snippet: &Snippet) -> Result<(), NibbError>;
fn save_all(&self, snippets: &[Snippet]) -> Result<(), NibbError>;
fn delete(&self, slug: &str) -> Result<(), NibbError>;
}
Expand description
Defines the interface for a snippet repository backend.
Allows loading, saving, and deleting individual or multiple Snippet
s
via a consistent API, independent of the concrete storage type (e.g. FS, DB, etc.).
Required Methods§
Sourcefn load_all(&self) -> Result<Vec<Snippet>, NibbError>
fn load_all(&self) -> Result<Vec<Snippet>, NibbError>
Load all available snippets from the repository.
Sourcefn load(&self, slug: &str) -> Result<Snippet, NibbError>
fn load(&self, slug: &str) -> Result<Snippet, NibbError>
Load a single snippet by its slugified name.