Skip to main content

Store

Trait Store 

Source
pub trait Store {
    // Required methods
    fn get_manifest(&self, id: &str) -> Result<Manifest, StoreError>;
    fn fetch_files(
        &self,
        manifest: &Manifest,
        dest: &Path,
    ) -> Result<(), StoreError>;
    fn push(&self, manifest: &Manifest, source: &Path) -> Result<(), StoreError>;
}
Expand description

A content-addressable storage backend for snapdir snapshots.

Implementors hold objects under object_path and manifests under manifest_path within some root (a local directory, an S3/GCS/B2 bucket prefix, …). The trait is the minimal surface the orchestrator needs to read a snapshot back (get_manifest + fetch_files) and to write one (push).

It is object-safe: callers can hold &dyn Store and pick the concrete backend at runtime from a store:// URL.

See the module docs for why this is synchronous even though network backends are async internally.

Required Methods§

Source

fn get_manifest(&self, id: &str) -> Result<Manifest, StoreError>

Reads and parses the manifest stored under id’s sharded path, verifying that its bytes hash back to id before returning it.

§Errors
Source

fn fetch_files( &self, manifest: &Manifest, dest: &Path, ) -> Result<(), StoreError>

Materializes every entry of manifest under dest, pulling each referenced object from the store and reconstructing the directory tree (files, directories, permissions) rooted at dest.

Implementations verify each fetched object against its manifest checksum.

§Errors
Source

fn push(&self, manifest: &Manifest, source: &Path) -> Result<(), StoreError>

Uploads the objects referenced by manifest (reading their bytes from the tree rooted at source) and then the manifest itself, filing each under its sharded address.

Implementations are expected to skip blobs already present and to write the manifest only after all of its objects have landed, so a manifest is never observable before the content it references (mirroring the oracle’s commit ordering).

§Errors

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§