pub struct InMemorySessionKv { /* private fields */ }Expand description
Bounded in-memory store, for embedders without durable storage and for state that must not outlive its owner.
Implementations§
Source§impl InMemorySessionKv
impl InMemorySessionKv
pub fn new(limits: SessionKvLimits) -> Self
Sourcepub fn used_bytes(&self) -> u64
pub fn used_bytes(&self) -> u64
Retained bytes: payloads plus keys plus per-entry overhead.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn get_now(&self, key: &[u16]) -> Result<Option<Vec<u16>>, SessionKvError>
pub fn has_now(&self, key: &[u16]) -> Result<bool, SessionKvError>
pub fn set_now( &self, key: &[u16], payload: &[u16], ) -> Result<(), SessionKvError>
pub fn remove_now(&self, key: &[u16]) -> Result<bool, SessionKvError>
pub fn scan_now( &self, after: Option<&[u16]>, prefix: &[u16], max_scan: usize, ) -> Result<SessionKvPage, SessionKvError>
Trait Implementations§
Source§impl Default for InMemorySessionKv
impl Default for InMemorySessionKv
Source§impl SessionKvStore for InMemorySessionKv
impl SessionKvStore for InMemorySessionKv
Source§fn get<'a>(&'a self, key: &'a [u16]) -> SessionKvFuture<'a, Option<Vec<u16>>>
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.fn has<'a>(&'a self, key: &'a [u16]) -> SessionKvFuture<'a, bool>
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>
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>
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.fn limits(&self) -> SessionKvLimits
Auto Trait Implementations§
impl !Freeze for InMemorySessionKv
impl RefUnwindSafe for InMemorySessionKv
impl Send for InMemorySessionKv
impl Sync for InMemorySessionKv
impl Unpin for InMemorySessionKv
impl UnsafeUnpin for InMemorySessionKv
impl UnwindSafe for InMemorySessionKv
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more