pub struct AsyncKvStore<'conn> { /* private fields */ }Expand description
A handle to one named key-value store over an AsyncConnection.
The async twin of KvStore; see it for semantics. Open
one with AsyncConnection::kv_store.
§Examples
use hyperdb_api::{AsyncConnection, CreateMode, Result};
async fn demo(conn: &AsyncConnection) -> Result<()> {
let kv = conn.kv_store("settings").await?;
kv.set("theme", "dark").await?;
assert_eq!(kv.get("theme").await?, Some("dark".to_string()));
Ok(())
}Implementations§
Source§impl<'conn> AsyncKvStore<'conn>
impl<'conn> AsyncKvStore<'conn>
Sourcepub async fn clear(&self) -> Result<u64>
pub async fn clear(&self) -> Result<u64>
Deletes every key in this store; returns the number removed.
The shared backing table survives; only this store’s rows are removed.
§Errors
See KvStore::clear.
Sourcepub async fn pop(&self) -> Result<Option<(String, String)>>
pub async fn pop(&self) -> Result<Option<(String, String)>>
Removes and returns the lowest-ordered pair, or None if empty.
The peek and delete run in one transaction, so they apply atomically — either both commit, or neither does (on error the transaction is rolled back). A SQL-NULL value is returned as an empty string.
§Errors
See KvStore::pop.
Trait Implementations§
Auto Trait Implementations§
impl<'conn> !RefUnwindSafe for AsyncKvStore<'conn>
impl<'conn> !UnwindSafe for AsyncKvStore<'conn>
impl<'conn> Freeze for AsyncKvStore<'conn>
impl<'conn> Send for AsyncKvStore<'conn>
impl<'conn> Sync for AsyncKvStore<'conn>
impl<'conn> Unpin for AsyncKvStore<'conn>
impl<'conn> UnsafeUnpin for AsyncKvStore<'conn>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request