linera_views::store

Trait LocalAdminKeyValueStore

Source
pub trait LocalAdminKeyValueStore: WithError + Sized {
    type Config: Send + Sync;

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

    // Provided methods
    fn delete_all(
        config: &Self::Config,
    ) -> impl Future<Output = Result<(), Self::Error>> { ... }
    fn maybe_create_and_connect(
        config: &Self::Config,
        namespace: &str,
    ) -> impl Future<Output = Result<Self, Self::Error>> { ... }
    fn recreate_and_connect(
        config: &Self::Config,
        namespace: &str,
    ) -> impl Future<Output = Result<Self, Self::Error>> { ... }
}
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

async fn connect( config: &Self::Config, namespace: &str, ) -> Result<Self, Self::Error>

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

async fn list_all(config: &Self::Config) -> Result<Vec<String>, Self::Error>

Obtains the list of existing namespaces.

Source

async fn list_root_keys( config: &Self::Config, namespace: &str, ) -> Result<Vec<Vec<u8>>, Self::Error>

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

Source

async fn exists( config: &Self::Config, namespace: &str, ) -> Result<bool, Self::Error>

Tests if a given namespace exists.

Source

async fn create( config: &Self::Config, namespace: &str, ) -> Result<(), Self::Error>

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

Source

async fn delete( config: &Self::Config, namespace: &str, ) -> Result<(), Self::Error>

Deletes the given namespace.

Provided Methods§

Source

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

Deletes all the existing namespaces.

Source

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

Initializes a storage if missing and provides it.

Source

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

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

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§

Source§

impl<TraitVariantBlanketType: AdminKeyValueStore> LocalAdminKeyValueStore for TraitVariantBlanketType

Source§

type Config = <TraitVariantBlanketType as AdminKeyValueStore>::Config