pub trait Storage: Send + Sync {
    fn store(&mut self, key: &str, value: Vec<u8>) -> Result<(), StorageError>;
    fn retrieve(&self, key: &str) -> Result<Vec<u8>, StorageError>;
}
Expand description

A trait for giving a type a custom storage implementation

The Storage is used to store the collection content locally.

How can I implement Storage?

struct MyStore {}

impl Storage for MyStore {
    fn store(&mut self, key: &str, value: Vec<u8>) -> Result<(), StorageError> {
        Ok(())
    }

    fn retrieve(&self, key: &str) -> Result<Vec<u8>, StorageError> {
        Ok(Vec::new())
    }
}

Required Methods

Store a key, value pair.

Errors

If an error occurs while storing, a StorageError::WriteError is returned.

Retrieve a value for a given key.

Errors

If the specified key does not exist, a StorageError::KeyNotFound is returned.

If an error occurs while reading, a StorageError::ReadError is returned.

Trait Implementations

Formats the value using the given formatter. Read more

Implementors