1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use ockam_core::compat::{boxed::Box, vec::Vec};
use ockam_core::{async_trait, Result};

/// This trait defines a key/value storage
#[async_trait]
pub trait KeyValueStorage<K, V>: Sync + Send + 'static {
    /// Store a key / value
    async fn put(&self, key: K, value: V) -> Result<()>;

    /// Retrieve a value. Return None if no value corresponds to the specified key
    async fn get(&self, key: &K) -> Result<Option<V>>;

    /// Delete a value and return it if found
    async fn delete(&self, key: &K) -> Result<Option<V>>;

    /// Return the list of all the keys
    async fn keys(&self) -> Result<Vec<K>>;
}