Skip to main content

ManifestStore

Trait ManifestStore 

Source
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§

Source

type Error: Error + Send + Sync + 'static

Error type for manifest operations.

Required Methods§

Source

fn get_root(&self, name: &[u8]) -> Result<Option<RootManifest>, Self::Error>

Load a named root manifest.

Source

fn put_root( &self, name: &[u8], manifest: &RootManifest, ) -> Result<(), Self::Error>

Unconditionally insert or replace a named root manifest.

Source

fn delete_root(&self, name: &[u8]) -> Result<(), Self::Error>

Delete a named root manifest. Deleting a missing name is not an error.

Source

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".

Implementations on Foreign Types§

Source§

impl<T: ManifestStore> ManifestStore for Arc<T>

Source§

type Error = <T as ManifestStore>::Error

Source§

fn get_root(&self, name: &[u8]) -> Result<Option<RootManifest>, Self::Error>

Source§

fn put_root( &self, name: &[u8], manifest: &RootManifest, ) -> Result<(), Self::Error>

Source§

fn delete_root(&self, name: &[u8]) -> Result<(), Self::Error>

Source§

fn compare_and_swap_root( &self, name: &[u8], expected: Option<&RootManifest>, new: Option<&RootManifest>, ) -> Result<ManifestUpdate, Self::Error>

Implementors§