Skip to main content

MemoryBlob

Struct MemoryBlob 

Source
pub struct MemoryBlob { /* private fields */ }
Expand description

An in-memory reference backend. Correct unless built with MemoryBlob::with_defect.

Implementations§

Source§

impl MemoryBlob

Source

pub fn new() -> Self

A correct, empty store.

Source

pub fn with_defect(defect: Defect) -> Self

A store that is wrong in exactly one way.

Trait Implementations§

Source§

impl BlobBackend for MemoryBlob

Source§

fn backend(&self) -> &str

The backend’s name as it appears in matrix rows (memory, fs, s3).
Source§

fn version(&self) -> &str

The backend’s version string as it appears in matrix rows.
Source§

async fn read(&self, key: &str) -> Result<Option<Vec<u8>>, BlobError>

The value at key, or None if absent.
Source§

async fn write(&self, key: &str, bytes: Vec<u8>) -> Result<(), BlobError>

Store bytes at key, replacing any earlier value. Atomicity is not implied; that is blob.replace_atomic.
Source§

async fn delete(&self, key: &str) -> Result<(), BlobError>

Remove key. Removing an absent key is Ok.
Source§

async fn stat(&self, key: &str) -> Result<Option<Entry>, BlobError>

The entry at key without reading its value, or None if absent.
Source§

async fn list( &self, prefix: &str, after: Option<&str>, limit: usize, ) -> Result<Page, BlobError>

Up to limit entries whose key starts with the literal prefix, in ascending bytewise key order, strictly after after if given.
Source§

async fn create_exclusive( &self, key: &str, bytes: Vec<u8>, ) -> Result<bool, BlobError>

Write bytes at key only if nothing is there. Ok(true) created it, Ok(false) found a value and changed nothing. Of any number of concurrent callers for one key, exactly one gets Ok(true) (blob.create_exclusive). A backend that cannot promise that returns BlobError::Unsupported; the default does.
Source§

async fn replace_atomic( &self, key: &str, bytes: Vec<u8>, ) -> Result<(), BlobError>

Replace the value at key so that a concurrent reader sees the whole old value or the whole new one, never a mix (blob.replace_atomic.concurrent_read). A backend that cannot promise that returns BlobError::Unsupported; the default does.
Source§

async fn append(&self, key: &str, bytes: Vec<u8>) -> Result<(), BlobError>

Add bytes after the existing bytes of key, in call order (blob.append). Of concurrent calls, each call’s bytes arrive whole and exactly once (blob.append.concurrent_whole). A backend that cannot promise that returns BlobError::Unsupported; the default does.
Source§

impl Debug for MemoryBlob

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MemoryBlob

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.