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§
Sourcefn get_manifest(&self, id: &str) -> Result<Manifest, StoreError>
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
StoreError::ManifestNotFoundif no manifest is stored atid.StoreError::Integrityif the stored bytes do not hash toid.StoreError::Parseif the bytes are not a valid manifest.StoreError::Io/StoreError::Backendon transport failure.
Sourcefn fetch_files(
&self,
manifest: &Manifest,
dest: &Path,
) -> Result<(), StoreError>
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
StoreError::ObjectNotFoundif a referenced object is missing.StoreError::Integrityif a fetched object is corrupt.StoreError::Io/StoreError::Backendon transport failure.
Sourcefn push(&self, manifest: &Manifest, source: &Path) -> Result<(), StoreError>
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
StoreError::Io/StoreError::Backendon transport failure.StoreError::Integrityif a source file no longer matches its manifest checksum at upload time.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".