Trait Persist

Source
pub trait Persist: Clone + Send {
    // Required methods
    fn put(&self, key: &PersistKey<'_>, value: &[u8]) -> Result<()>;
    fn get(&self, key: &PersistKey<'_>) -> Result<Option<Vec<u8>>>;
}
Expand description

Trait for a persistence implementation.

Implementation must be clonable and thread safe (Send). This can easily be done by wrapping the implemetation an Arc<Mutex<P>>.

Required Methods§

Source

fn put(&self, key: &PersistKey<'_>, value: &[u8]) -> Result<()>

Store the given bytes under the given key.

Source

fn get(&self, key: &PersistKey<'_>) -> Result<Option<Vec<u8>>>

Read the bytes stored under the given key.

None if the value doesn’t exist.

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§