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 (advisoryflockon<safekey>.toml.lockwith 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,\nline endings, trailing newline).
Required Methods§
Sourcefn read(&self, key: &Safekey) -> Result<Option<Metadata>, StoreError>
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).
Sourcefn write(
&self,
key: &Safekey,
m: &Metadata,
pdf: Option<&Utf8Path>,
) -> Result<(), StoreError>
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).
Sourcefn list_recent(&self, limit: usize) -> Result<Vec<EntryInfo>, StoreError>
fn list_recent(&self, limit: usize) -> Result<Vec<EntryInfo>, StoreError>
Return up to limit entries, most-recent first by [doiget].fetched_at.