Skip to main content

Backend

Trait Backend 

Source
pub trait Backend: Sized {
    type Lock;

    // Required methods
    fn lock(&self) -> impl Future<Output = Result<Self::Lock, String>>;
    fn get(
        &self,
        name: &str,
    ) -> impl Future<Output = Result<Option<Vec<u8>>, String>>;
    fn get_range(
        &self,
        name: &str,
        from: u64,
        len: u64,
    ) -> impl Future<Output = Result<Option<Vec<u8>>, String>>;
    fn put(
        &self,
        name: &str,
        bytes: &[u8],
    ) -> impl Future<Output = Result<(), String>>;
    fn delete(&self, name: &str) -> impl Future<Output = Result<bool, String>>;
    fn list(&self) -> impl Future<Output = Result<Vec<(String, u64)>, String>>;
    fn staging(&self) -> impl Future<Output = Result<Self, String>>;
    fn rename(
        &self,
        name: &str,
        to: &Self,
    ) -> impl Future<Output = Result<bool, String>>;
}
Expand description

Named bytes. A put is whole or absent: no reader sees half of one.

Required Associated Types§

Required Methods§

Source

fn lock(&self) -> impl Future<Output = Result<Self::Lock, String>>

The one exclusive lock over these names, shared by every store over them.

Source

fn get( &self, name: &str, ) -> impl Future<Output = Result<Option<Vec<u8>>, String>>

Source

fn get_range( &self, name: &str, from: u64, len: u64, ) -> impl Future<Output = Result<Option<Vec<u8>>, String>>

At most len bytes from from on, fewer where the name ends sooner.

Source

fn put( &self, name: &str, bytes: &[u8], ) -> impl Future<Output = Result<(), String>>

Source

fn delete(&self, name: &str) -> impl Future<Output = Result<bool, String>>

False where another holder has name open, so it stays.

Source

fn list(&self) -> impl Future<Output = Result<Vec<(String, u64)>, String>>

Each name, with its size in bytes.

Source

fn staging(&self) -> impl Future<Output = Result<Self, String>>

An area beside these names that no other store writes and list never names.

Source

fn rename( &self, name: &str, to: &Self, ) -> impl Future<Output = Result<bool, String>>

name moved from here into to in one step, over whatever to held under it; as delete, false where either is open.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§