Skip to main content

SessionKvStore

Trait SessionKvStore 

Source
pub trait SessionKvStore: Send + Sync {
    // Required methods
    fn get<'a>(
        &'a self,
        key: &'a [u16],
    ) -> SessionKvFuture<'a, Option<Vec<u16>>>;
    fn has<'a>(&'a self, key: &'a [u16]) -> SessionKvFuture<'a, bool>;
    fn set<'a>(
        &'a self,
        key: &'a [u16],
        payload: &'a [u16],
    ) -> SessionKvFuture<'a, ()>;
    fn remove<'a>(&'a self, key: &'a [u16]) -> SessionKvFuture<'a, bool>;
    fn scan<'a>(
        &'a self,
        after: Option<&'a [u16]>,
        prefix: &'a [u16],
        max_scan: usize,
    ) -> SessionKvFuture<'a, SessionKvPage>;
    fn limits(&self) -> SessionKvLimits;
}
Expand description

Session-scoped key-value storage.

Every operation is atomic and commits only after validation and capacity checks succeed, so a rejected write leaves the previous entry intact. Operations on one session serialize: two writers cannot both spend the same headroom, and concurrent writes to one key resolve last-committed-write.

Required Methods§

Source

fn get<'a>(&'a self, key: &'a [u16]) -> SessionKvFuture<'a, Option<Vec<u16>>>

Ok(None) is an absent key. A present entry holding a serialized null returns Ok(Some(..)) — callers distinguish the two.

Source

fn has<'a>(&'a self, key: &'a [u16]) -> SessionKvFuture<'a, bool>

Source

fn set<'a>( &'a self, key: &'a [u16], payload: &'a [u16], ) -> SessionKvFuture<'a, ()>

Source

fn remove<'a>(&'a self, key: &'a [u16]) -> SessionKvFuture<'a, bool>

Ok(true) when an entry existed and was removed.

Source

fn scan<'a>( &'a self, after: Option<&'a [u16]>, prefix: &'a [u16], max_scan: usize, ) -> SessionKvFuture<'a, SessionKvPage>

Keys in UTF-16 code-unit order, strictly after after when given and starting with prefix. Scans at most max_scan keys; matching is exact code units, with no normalization or path semantics. One page is one consistent read.

Source

fn limits(&self) -> SessionKvLimits

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§