commonware_runtime

Trait Storage

Source
pub trait Storage<B>:
    Clone
    + Send
    + Sync
    + 'static
where B: Blob,
{ // Required methods fn open( &self, partition: &str, name: &[u8], ) -> impl Future<Output = Result<B, Error>> + Send; fn remove( &self, partition: &str, name: Option<&[u8]>, ) -> impl Future<Output = Result<(), Error>> + Send; fn scan( &self, partition: &str, ) -> impl Future<Output = Result<Vec<Vec<u8>>, Error>> + Send; }
Expand description

Interface to interact with storage.

To support storage implementations that enable concurrent reads and writes, blobs are responsible for maintaining synchronization.

Storage can be backed by a local filesystem, cloud storage, etc.

Required Methods§

Source

fn open( &self, partition: &str, name: &[u8], ) -> impl Future<Output = Result<B, Error>> + Send

Open an existing blob in a given partition or create a new one.

Multiple instances of the same blob can be opened concurrently, however, writing to the same blob concurrently may lead to undefined behavior.

Source

fn remove( &self, partition: &str, name: Option<&[u8]>, ) -> impl Future<Output = Result<(), Error>> + Send

Remove a blob from a given partition.

If no name is provided, the entire partition is removed.

Source

fn scan( &self, partition: &str, ) -> impl Future<Output = Result<Vec<Vec<u8>>, Error>> + Send

Return all blobs in a given partition.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Storage<Blob> for commonware_runtime::deterministic::Context

Source§

impl Storage<Blob> for commonware_runtime::tokio::Context