pub struct Store { /* private fields */ }Expand description
Local artifact store. Thread-safe via internal RwLock.
Artifacts are stored as <artifact_id>.json files.
Content-addressed IDs mean same content → same filename → idempotent writes.
An index.json tracks all artifact IDs for O(1) listing.
Implementations§
Source§impl Store
impl Store
Sourcepub fn open(dir: impl AsRef<Path>) -> Result<Self, StorageError>
pub fn open(dir: impl AsRef<Path>) -> Result<Self, StorageError>
Opens or creates an artifact store at dir.
Sourcepub fn write(&self, record: &Record) -> Result<(), StorageError>
pub fn write(&self, record: &Record) -> Result<(), StorageError>
Writes an artifact record. Idempotent: writing the same artifact twice has no effect beyond overwriting with identical content.
Sourcepub fn exists(&self, id: &str) -> bool
pub fn exists(&self, id: &str) -> bool
Returns true if an artifact with this ID is stored locally.
Sourcepub fn list(&self) -> Vec<IndexEntry>
pub fn list(&self) -> Vec<IndexEntry>
Lists index entries, most recent first.
Sourcepub fn list_by_type(&self, payload_type: &str) -> Vec<IndexEntry>
pub fn list_by_type(&self, payload_type: &str) -> Vec<IndexEntry>
Lists index entries filtered to a specific payload type.
Sourcepub fn set_hub_url(&self, id: &str, hub_url: &str) -> Result<(), StorageError>
pub fn set_hub_url(&self, id: &str, hub_url: &str) -> Result<(), StorageError>
Updates the hub_url on a stored record after a successful dock push.
Sourcepub fn add_anchor(
&self,
id: &str,
anchor: RecordAnchor,
) -> Result<(), StorageError>
pub fn add_anchor( &self, id: &str, anchor: RecordAnchor, ) -> Result<(), StorageError>
Record that an external witness saw this artifact.
Appends rather than replaces: two witnesses are strictly better evidence than one, and they fail differently – a Hub anchor requires trusting the Hub, an OpenTimestamps anchor does not. Collapsing them would discard that difference.
Sourcepub fn latest(&self) -> Option<IndexEntry>
pub fn latest(&self) -> Option<IndexEntry>
Returns the most recently stored artifact, if any.