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::Networkon 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
pub async fn get_linearizable( &self, key: impl AsRef<[u8]>, ) -> Result<Option<ClientResult>, ClientApiError>
pub async fn get_lease( &self, key: impl AsRef<[u8]>, ) -> Result<Option<ClientResult>, ClientApiError>
pub async fn get_eventual( &self, key: impl AsRef<[u8]>, ) -> Result<Option<ClientResult>, ClientApiError>
Sourcepub async fn get(
&self,
key: impl AsRef<[u8]>,
) -> Result<Option<ClientResult>, ClientApiError>
pub async fn get( &self, key: impl AsRef<[u8]>, ) -> Result<Option<ClientResult>, ClientApiError>
Retrieves a single key’s value using server’s default consistency policy
Uses the cluster’s configured default consistency policy as defined in the server’s ReadConsistencyConfig.default_policy setting.
§Parameters
key- The key to retrieve, accepts any type implementingAsRef<[u8]>
§Returns
Ok(Some(ClientResult))- Key exists, returns key-value pairOk(None)- Key does not exist in the storeErr(ClientApiError)- Read failed due to network or consistency issues
Sourcepub async fn get_with_policy(
&self,
key: impl AsRef<[u8]>,
consistency_policy: Option<ReadConsistencyPolicy>,
) -> Result<Option<ClientResult>, ClientApiError>
pub async fn get_with_policy( &self, key: impl AsRef<[u8]>, consistency_policy: Option<ReadConsistencyPolicy>, ) -> Result<Option<ClientResult>, ClientApiError>
Retrieves a single key’s value with explicit consistency policy
Allows client to override server’s default consistency policy for this specific request. If server’s allow_client_override is false, the override will be ignored.
§Parameters
key- The key to retrieve, accepts any type implementingAsRef<[u8]>policy- Explicit consistency policy for this request
Sourcepub async fn get_multi(
&self,
keys: impl IntoIterator<Item = impl AsRef<[u8]>>,
) -> Result<Vec<Option<ClientResult>>, ClientApiError>
pub async fn get_multi( &self, keys: impl IntoIterator<Item = impl AsRef<[u8]>>, ) -> Result<Vec<Option<ClientResult>>, ClientApiError>
Fetches multiple keys using server’s default consistency policy
Uses the cluster’s configured default consistency policy as defined in the server’s ReadConsistencyConfig.default_policy setting.
Sourcepub async fn get_multi_with_policy(
&self,
keys: impl IntoIterator<Item = impl AsRef<[u8]>>,
consistency_policy: Option<ReadConsistencyPolicy>,
) -> Result<Vec<Option<ClientResult>>, ClientApiError>
pub async fn get_multi_with_policy( &self, keys: impl IntoIterator<Item = impl AsRef<[u8]>>, consistency_policy: Option<ReadConsistencyPolicy>, ) -> Result<Vec<Option<ClientResult>>, ClientApiError>
Fetches multiple keys with explicit consistency policy override
Allows client to override server’s default consistency policy for this batch request. If server’s allow_client_override is false, the override will be ignored.
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
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>
T in a tonic::Request