pub struct KvClient { /* private fields */ }
Expand description
Key-value store client interface
Implements CRUD operations with configurable consistency levels. All write operations use strong consistency.
Implementations§
Source§impl KvClient
impl KvClient
Sourcepub async fn put(
&self,
key: impl AsRef<[u8]>,
value: impl AsRef<[u8]>,
) -> Result<(), ClientApiError>
pub async fn put( &self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>, ) -> Result<(), ClientApiError>
Stores a value with strong consistency
§Errors
crate::ClientApiError::Network
on network failures- [
crate::ClientApiError::InvalidResponse
] for malformed server responses
Sourcepub async fn delete(&self, key: impl AsRef<[u8]>) -> Result<(), ClientApiError>
pub async fn delete(&self, key: impl AsRef<[u8]>) -> Result<(), ClientApiError>
Deletes a key with strong consistency guarantees
Permanently removes the specified key and its associated value from the store.
§Parameters
key
: The byte-serialized key to delete. Supports any type implementingAsRef<[u8]>
(e.g.String
,&str
,Vec<u8>
)
§Errors
- [
Error::FailedToSendWriteRequestError
] if unable to reach the leader node - [
Error::InvalidResponse
] for malformed server responses
Sourcepub async fn get(
&self,
key: impl AsRef<[u8]>,
linear: bool,
) -> Result<Option<ClientResult>, ClientApiError>
pub async fn get( &self, key: impl AsRef<[u8]>, linear: bool, ) -> Result<Option<ClientResult>, ClientApiError>
Sourcepub async fn get_multi(
&self,
keys: impl IntoIterator<Item = impl AsRef<[u8]>>,
linear: bool,
) -> Result<Vec<Option<ClientResult>>, ClientApiError>
pub async fn get_multi( &self, keys: impl IntoIterator<Item = impl AsRef<[u8]>>, linear: bool, ) -> Result<Vec<Option<ClientResult>>, ClientApiError>
Fetches values for multiple keys from the cluster
§Parameters
keys
: Iterable collection of keys to fetchlinear
: Whether to use linearizable read consistency
§Returns
Ordered list of results matching input keys. Missing keys return None
.
§Errors
Error::EmptyKeys
if no keys providedError::FailedToSendReadRequestError
on network failures
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KvClient
impl !RefUnwindSafe for KvClient
impl Send for KvClient
impl Sync for KvClient
impl Unpin for KvClient
impl !UnwindSafe for KvClient
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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