Skip to main content

Store

Trait Store 

Source
pub trait Store: Send + Sync {
    // Required methods
    fn read(&self, key: &Safekey) -> Result<Option<Metadata>, StoreError>;
    fn write(
        &self,
        key: &Safekey,
        m: &Metadata,
        pdf: Option<&Utf8Path>,
    ) -> Result<(), StoreError>;
    fn list_recent(&self, limit: usize) -> Result<Vec<EntryInfo>, StoreError>;
    fn search(
        &self,
        query: &str,
        limit: usize,
    ) -> Result<Vec<EntryInfo>, StoreError>;
}
Expand description

Filesystem-shaped metadata store, semver-locked per docs/PUBLIC_API.md §2.

Implementations are responsible for honoring:

  • docs/STORE.md §4 lock protocol (advisory flock on <safekey>.toml.lock with a 5 s timeout).
  • docs/STORE.md §5 atomic-write sequence (tmp → fsync → rename → fsync parent).
  • docs/STORE.md §6 doiget write discipline: never overwrite reserved top-level fields previously written by another tool.
  • docs/STORE.md §7 TOML normalization (alphabetical key order, \n line endings, trailing newline).

Required Methods§

Source

fn read(&self, key: &Safekey) -> Result<Option<Metadata>, StoreError>

Read the entry keyed by key.

Returns Ok(None) if no entry exists. Returns Err on I/O failure, malformed TOML, or unrecoverable schema mismatch (e.g. future major).

Source

fn write( &self, key: &Safekey, m: &Metadata, pdf: Option<&Utf8Path>, ) -> Result<(), StoreError>

Write or update the entry keyed by key.

If pdf is Some, the file at that path is copied to <root>/<safekey>.pdf via the same atomic-rename dance as the metadata file. The caller is responsible for emitting the event=store_write provenance row (see docs/PROVENANCE_LOG.md §3).

Source

fn list_recent(&self, limit: usize) -> Result<Vec<EntryInfo>, StoreError>

Return up to limit entries, most-recent first by [doiget].fetched_at.

Source

fn search( &self, query: &str, limit: usize, ) -> Result<Vec<EntryInfo>, StoreError>

Return up to limit entries whose title / authors / venue / publisher case-insensitively contain query.

Implementors§