Trait persist::storage::Blob[][src]

pub trait Blob: BlobRead + Sized {
    type Config;
    type Read: BlobRead;
    fn open_exclusive(
        config: Self::Config,
        lock_info: LockInfo
    ) -> Result<Self, Error>;
fn open_read(config: Self::Config) -> Result<Self::Read, Error>;
fn set<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        key: &'life1 str,
        value: Vec<u8>,
        atomic: Atomicity
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
fn delete<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        key: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }
Expand description

An abstraction over read-write access to a bytes key->bytes value store.

Blob and BlobRead impls are allowed to be concurrently opened for the same location in the same process (which is often used in tests), but this is not idiomatic for production usage. Instead, within a process, only single Blob or BlobRead impl should be used for each unique storage location.

  • Invariant: Implementations are responsible for ensuring that they are exclusive writers to this location.

Associated Types

The configuration necessary to open this type of storage.

The corresponding BlobRead implementation.

Required methods

Opens the given location for exclusive read-write access.

Implementations are responsible for storing the given LockInfo in such a way that no other calls to open_exclusive succeed before this one has been closed. However, it must be possible to continue to open this location for reads via Blob::open_read.

Opens the given location for non-exclusive read-only access.

Implementations are responsible for ensuring that this works regardless of whether anyone has opened the same location is opened for exclusive read-write access. Said another way, this should succeed even if there is no LOCK file present. If it’s pointed at a meaningless location, the first read (META) will fail anyway.

Inserts a key-value pair into the map.

When atomicity is required, writes must be atomic and either succeed or leave the previous value intact.

Remove a key from the map.

Succeeds if the key does not exist.

Implementors