Trait Adapter

Source
pub trait Adapter:
    Send
    + Sync
    + Debug
    + Unpin
    + 'static {
    // Required methods
    fn info(&self) -> Info;
    fn get(
        &self,
        path: &str,
    ) -> impl Future<Output = Result<Option<Value>>> + MaybeSend;
    fn blocking_get(&self, path: &str) -> Result<Option<Value>>;
    fn set(
        &self,
        path: &str,
        value: Value,
    ) -> impl Future<Output = Result<()>> + MaybeSend;
    fn blocking_set(&self, path: &str, value: Value) -> Result<()>;
    fn delete(&self, path: &str) -> impl Future<Output = Result<()>> + MaybeSend;
    fn blocking_delete(&self, path: &str) -> Result<()>;

    // Provided methods
    fn scan(
        &self,
        path: &str,
    ) -> impl Future<Output = Result<Vec<String>>> + MaybeSend { ... }
    fn blocking_scan(&self, path: &str) -> Result<Vec<String>> { ... }
}
Expand description

Adapter is the typed adapter to underlying kv services.

By implement this trait, any kv service can work as an OpenDAL Service.

§Notes

typed_kv::Adapter is the typed version of kv::Adapter. It’s more efficient if the underlying kv service can store data with its type. For example, we can store Bytes along with its metadata so that we don’t need to serialize/deserialize it when we get it from the service.

Ideally, we should use typed_kv::Adapter instead of kv::Adapter for in-memory rust libs like moka and dashmap.

Required Methods§

Source

fn info(&self) -> Info

Return the info of this key value accessor.

Source

fn get( &self, path: &str, ) -> impl Future<Output = Result<Option<Value>>> + MaybeSend

Get a value from adapter.

Source

fn blocking_get(&self, path: &str) -> Result<Option<Value>>

Get a value from adapter.

Source

fn set( &self, path: &str, value: Value, ) -> impl Future<Output = Result<()>> + MaybeSend

Set a value into adapter.

Source

fn blocking_set(&self, path: &str, value: Value) -> Result<()>

Set a value into adapter.

Source

fn delete(&self, path: &str) -> impl Future<Output = Result<()>> + MaybeSend

Delete a value from adapter.

Source

fn blocking_delete(&self, path: &str) -> Result<()>

Delete a value from adapter.

Provided Methods§

Source

fn scan( &self, path: &str, ) -> impl Future<Output = Result<Vec<String>>> + MaybeSend

Scan a key prefix to get all keys that start with this key.

Source

fn blocking_scan(&self, path: &str) -> Result<Vec<String>>

Scan a key prefix to get all keys that start with this key in blocking way.

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§