Trait Adapter

Source
pub trait Adapter:
    Send
    + Sync
    + Debug
    + Unpin
    + 'static {
    type Scanner: Scan;

    // Required methods
    fn info(&self) -> Info;
    fn get(
        &self,
        path: &str,
    ) -> impl Future<Output = Result<Option<Buffer>>> + MaybeSend;
    fn set(
        &self,
        path: &str,
        value: Buffer,
    ) -> impl Future<Output = Result<()>> + MaybeSend;
    fn delete(&self, path: &str) -> impl Future<Output = Result<()>> + MaybeSend;

    // Provided methods
    fn blocking_get(&self, path: &str) -> Result<Option<Buffer>> { ... }
    fn blocking_set(&self, path: &str, value: Buffer) -> Result<()> { ... }
    fn blocking_delete(&self, path: &str) -> Result<()> { ... }
    fn scan(
        &self,
        path: &str,
    ) -> impl Future<Output = Result<Self::Scanner>> + MaybeSend { ... }
    fn blocking_scan(&self, path: &str) -> Result<Vec<String>> { ... }
    fn append(
        &self,
        path: &str,
        value: &[u8],
    ) -> impl Future<Output = Result<()>> + MaybeSend { ... }
    fn blocking_append(&self, path: &str, value: &[u8]) -> Result<()> { ... }
}
Expand description

KvAdapter is the adapter to underlying kv services.

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

Required Associated Types§

Source

type Scanner: Scan

TODO: use default associate type = () after stabilized

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<Buffer>>> + MaybeSend

Get a key from service.

  • return Ok(None) if this key is not exist.
Source

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

Set a key into service.

Source

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

Delete a key from service.

  • return Ok(()) even if this key is not exist.

Provided Methods§

Source

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

The blocking version of get.

Source

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

The blocking version of set.

Source

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

Delete a key from service in blocking way.

  • return Ok(()) even if this key is not exist.
Source

fn scan( &self, path: &str, ) -> impl Future<Output = Result<Self::Scanner>> + 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.

Source

fn append( &self, path: &str, value: &[u8], ) -> impl Future<Output = Result<()>> + MaybeSend

Append a key into service

Source

fn blocking_append(&self, path: &str, value: &[u8]) -> Result<()>

Append a key into service 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§