Trait linera_views::store::AdminKeyValueStore

source ·
pub trait AdminKeyValueStore: WithError + Sized + Send {
    type Config: Send + Sync;

    // Required methods
    fn get_name() -> String;
    fn connect(
        config: &Self::Config,
        namespace: &str,
        root_key: &[u8],
    ) -> impl Future<Output = Result<Self, Self::Error>> + Send;
    fn clone_with_root_key(&self, root_key: &[u8]) -> Result<Self, Self::Error>;
    fn list_all(
        config: &Self::Config,
    ) -> impl Future<Output = Result<Vec<String>, Self::Error>> + Send;
    fn list_root_keys(
        config: &Self::Config,
        namespace: &str,
    ) -> impl Future<Output = Result<Vec<Vec<u8>>, Self::Error>> + Send;
    fn exists(
        config: &Self::Config,
        namespace: &str,
    ) -> impl Future<Output = Result<bool, Self::Error>> + Send;
    fn create(
        config: &Self::Config,
        namespace: &str,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn delete(
        config: &Self::Config,
        namespace: &str,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;

    // Provided methods
    fn delete_all(
        config: &Self::Config,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send { ... }
    fn maybe_create_and_connect(
        config: &Self::Config,
        namespace: &str,
        root_key: &[u8],
    ) -> impl Future<Output = Result<Self, Self::Error>> + Send { ... }
    fn recreate_and_connect(
        config: &Self::Config,
        namespace: &str,
        root_key: &[u8],
    ) -> impl Future<Output = Result<Self, Self::Error>> + Send { ... }
}
Expand description

Low-level trait for the administration of stores and their namespaces.

Required Associated Types§

source

type Config: Send + Sync

The configuration needed to interact with a new store.

Required Methods§

source

fn get_name() -> String

The name of this class of stores

source

fn connect( config: &Self::Config, namespace: &str, root_key: &[u8], ) -> impl Future<Output = Result<Self, Self::Error>> + Send

Connects to an existing namespace using the given configuration.

source

fn clone_with_root_key(&self, root_key: &[u8]) -> Result<Self, Self::Error>

Takes a connection and creates a new one with a different root_key.

source

fn list_all( config: &Self::Config, ) -> impl Future<Output = Result<Vec<String>, Self::Error>> + Send

Obtains the list of existing namespaces.

source

fn list_root_keys( config: &Self::Config, namespace: &str, ) -> impl Future<Output = Result<Vec<Vec<u8>>, Self::Error>> + Send

Lists the root keys of the namespace. It is possible that some root keys have no keys.

source

fn exists( config: &Self::Config, namespace: &str, ) -> impl Future<Output = Result<bool, Self::Error>> + Send

Tests if a given namespace exists.

source

fn create( config: &Self::Config, namespace: &str, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Creates a namespace. Returns an error if the namespace exists.

source

fn delete( config: &Self::Config, namespace: &str, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Deletes the given namespace.

Provided Methods§

source

fn delete_all( config: &Self::Config, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Deletes all the existing namespaces.

source

fn maybe_create_and_connect( config: &Self::Config, namespace: &str, root_key: &[u8], ) -> impl Future<Output = Result<Self, Self::Error>> + Send

Initializes a storage if missing and provides it.

source

fn recreate_and_connect( config: &Self::Config, namespace: &str, root_key: &[u8], ) -> impl Future<Output = Result<Self, Self::Error>> + Send

Creates a new storage. Overwrites it if this namespace already exists.

Object Safety§

This trait is not object safe.

Implementors§