pub trait ManifestStore: Send + Sync {
type Error: Error + Send + Sync + 'static;
// Required methods
fn get_root(&self, name: &[u8]) -> Result<Option<RootManifest>, Self::Error>;
fn put_root(
&self,
name: &[u8],
manifest: &RootManifest,
) -> Result<(), Self::Error>;
fn delete_root(&self, name: &[u8]) -> Result<(), Self::Error>;
fn compare_and_swap_root(
&self,
name: &[u8],
expected: Option<&RootManifest>,
new: Option<&RootManifest>,
) -> Result<ManifestUpdate, Self::Error>;
}Expand description
Storage for named root manifests.
This trait is separate from crate::Store so content-addressed node stores
remain simple. Backends that can update a named root atomically should
implement compare-and-swap directly in their native transaction mechanism.
Required Associated Types§
Required Methods§
Sourcefn get_root(&self, name: &[u8]) -> Result<Option<RootManifest>, Self::Error>
fn get_root(&self, name: &[u8]) -> Result<Option<RootManifest>, Self::Error>
Load a named root manifest.
Sourcefn put_root(
&self,
name: &[u8],
manifest: &RootManifest,
) -> Result<(), Self::Error>
fn put_root( &self, name: &[u8], manifest: &RootManifest, ) -> Result<(), Self::Error>
Unconditionally insert or replace a named root manifest.
Sourcefn delete_root(&self, name: &[u8]) -> Result<(), Self::Error>
fn delete_root(&self, name: &[u8]) -> Result<(), Self::Error>
Delete a named root manifest. Deleting a missing name is not an error.
Sourcefn compare_and_swap_root(
&self,
name: &[u8],
expected: Option<&RootManifest>,
new: Option<&RootManifest>,
) -> Result<ManifestUpdate, Self::Error>
fn compare_and_swap_root( &self, name: &[u8], expected: Option<&RootManifest>, new: Option<&RootManifest>, ) -> Result<ManifestUpdate, Self::Error>
Atomically update a named root if the current manifest matches
expected.
expected == None means the name must be absent. new == None deletes
the name when the compare succeeds.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".