Trait Store

Source
pub trait Store<B, I>
where B: Blob, I: Iterator<Item = Result<B, Error>>,
{ // Required methods fn put_from<R: Read>( &mut self, key: &str, r: &mut R, ) -> Result<usize, Error>; fn get_to<W: Write>(&mut self, key: &str, w: &mut W) -> Result<usize, Error>; fn prefix(&mut self, prefix: &str) -> I; fn delete(&mut self, key: &str) -> Result<(), Error>; // Provided methods fn put(&mut self, key: &str, data: &[u8]) -> Result<(), Error> { ... } fn get(&mut self, key: &str) -> Result<Vec<u8>, Error> { ... } fn remove(&mut self, name: &str) -> Result<(), Error> { ... } }
Expand description

A generic Storage system for blobs.

Required Methods§

Source

fn put_from<R: Read>(&mut self, key: &str, r: &mut R) -> Result<usize, Error>

Save the content of r into the storage system with the given key.

Source

fn get_to<W: Write>(&mut self, key: &str, w: &mut W) -> Result<usize, Error>

Read the contents of the blob with the given key into the given writer.

Source

fn prefix(&mut self, prefix: &str) -> I

Find all blobs that have the given prefix and iterate over them.

Source

fn delete(&mut self, key: &str) -> Result<(), Error>

Delete the blob with the given key.

Provided Methods§

Source

fn put(&mut self, key: &str, data: &[u8]) -> Result<(), Error>

Similar to put_from but uses the give data instead of a reader.

Source

fn get(&mut self, key: &str) -> Result<Vec<u8>, Error>

Similar to get_to but reads the contents into a byte vector.

Source

fn remove(&mut self, name: &str) -> Result<(), Error>

Similar to delete but it does not return an error if the error is NotFound.

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§