Collection

Trait Collection 

Source
pub trait Collection<'a, T>
where T: Serialize + DeserializeOwned + 'a,
{ // Required methods fn put(&mut self, key: &str, value: T) -> Result<Option<T>, Error>; fn get(&mut self, key: &str) -> Result<Option<T>, Error>; fn prefix( &mut self, prefix: &str, ) -> Box<dyn Iterator<Item = Result<T, Error>> + 'a>; }
Expand description

A Collection contains serializable objects which are accessible by a key.

Required Methods§

Source

fn put(&mut self, key: &str, value: T) -> Result<Option<T>, Error>

Put the given value into the collection under the given key. If the key already exists, it’s replaced with the given value and the old value is returned.

Source

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

Source

fn prefix( &mut self, prefix: &str, ) -> Box<dyn Iterator<Item = Result<T, Error>> + 'a>

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

Implementors§

Source§

impl<'a, T> Collection<'a, T> for Sled
where T: Serialize + DeserializeOwned + 'a,