pub struct KvStore<Backend: TransactionalBackend> { /* private fields */ }Expand description
A key-value store.
This is a key-value store where both the key and value are strings. There are no restrictions on the length or contents of either the key or value beyond restrictions implemented by the protobuf server.
Implementations§
Source§impl<Backend> KvStore<Backend>
impl<Backend> KvStore<Backend>
Sourcepub fn at_location(location: Location) -> Result<Self, Backend::Error>
pub fn at_location(location: Location) -> Result<Self, Backend::Error>
Create a new key-value store at the given location. If not pre-existing, the store will not be initialized until the first connection is made.
Sourcepub fn at_path<P>(path: P) -> Result<Self, Backend::Error>
pub fn at_path<P>(path: P) -> Result<Self, Backend::Error>
Create a new key-value at the given path on disk. If not pre-existing, the store will not be initialized until the first connection is made.
Sourcepub fn in_memory() -> Result<Self, Backend::Error>
pub fn in_memory() -> Result<Self, Backend::Error>
Create a new in-memory key-value store. This is useful for short-lived data.
Note that all in-memory connections share the same stream, so any asynchronous calls have a nondeterministic order. This is not a problem for on-disk connections.
Sourcepub fn create_index(&self, config: IndexConfig) -> Result<(), IndexError>
pub fn create_index(&self, config: IndexConfig) -> Result<(), IndexError>
Create a secondary index on the key-value store
Sourcepub fn drop_index(&self, name: &str) -> Result<(), IndexError>
pub fn drop_index(&self, name: &str) -> Result<(), IndexError>
Drop a secondary index
Sourcepub const fn index_manager(&self) -> &Arc<IndexManager>
pub const fn index_manager(&self) -> &Arc<IndexManager>
Get the index manager
Source§impl<Backend> KvStore<Backend>
impl<Backend> KvStore<Backend>
Sourcepub fn with_transactions(
location: Location,
transaction_timeout: Duration,
) -> Result<Self, Backend::Error>
👎Deprecated since 0.5.0: Transaction support over gRPC is problematic and will be removed. Use batch operations instead.
pub fn with_transactions( location: Location, transaction_timeout: Duration, ) -> Result<Self, Backend::Error>
Create a new key-value store with transaction support.
DEPRECATED: Transaction support over gRPC is being phased out. Use batch operations or client-side transaction management instead.
Trait Implementations§
Source§impl<Backend> Kv for KvStore<Backend>where
Backend: KvBackend<Error: IntoTonicStatus, GetStream: Send, SetStream: Send, DeleteStream: Send> + TransactionalBackend + 'static,
Backend::Error: Display + Debug,
impl<Backend> Kv for KvStore<Backend>where
Backend: KvBackend<Error: IntoTonicStatus, GetStream: Send, SetStream: Send, DeleteStream: Send> + TransactionalBackend + 'static,
Backend::Error: Display + Debug,
Source§type GetStream = <Backend as KvBackend>::GetStream
type GetStream = <Backend as KvBackend>::GetStream
Source§type SetStream = <Backend as KvBackend>::SetStream
type SetStream = <Backend as KvBackend>::SetStream
Source§type DeleteStream = <Backend as KvBackend>::DeleteStream
type DeleteStream = <Backend as KvBackend>::DeleteStream
Source§fn get<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<GetRequest>>,
) -> Pin<Box<dyn Future<Output = RpcResponse<Self::GetStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<GetRequest>>,
) -> Pin<Box<dyn Future<Output = RpcResponse<Self::GetStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn set<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<SetRequest>>,
) -> Pin<Box<dyn Future<Output = RpcResponse<Self::SetStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<SetRequest>>,
) -> Pin<Box<dyn Future<Output = RpcResponse<Self::SetStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn delete<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<DeleteRequest>>,
) -> Pin<Box<dyn Future<Output = RpcResponse<Self::DeleteStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<DeleteRequest>>,
) -> Pin<Box<dyn Future<Output = RpcResponse<Self::DeleteStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn eq<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<EqRequest>>,
) -> Pin<Box<dyn Future<Output = RpcResponse<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn eq<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<EqRequest>>,
) -> Pin<Box<dyn Future<Output = RpcResponse<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn not_eq<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<NotEqRequest>>,
) -> Pin<Box<dyn Future<Output = RpcResponse<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn not_eq<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<NotEqRequest>>,
) -> Pin<Box<dyn Future<Output = RpcResponse<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn begin_transaction<'life0, 'async_trait>(
&'life0 self,
_request: Request<BeginTransactionRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<BeginTransactionResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn begin_transaction<'life0, 'async_trait>(
&'life0 self,
_request: Request<BeginTransactionRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<BeginTransactionResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn commit_transaction<'life0, 'async_trait>(
&'life0 self,
_request: Request<CommitTransactionRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<CommitTransactionResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn commit_transaction<'life0, 'async_trait>(
&'life0 self,
_request: Request<CommitTransactionRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<CommitTransactionResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn rollback_transaction<'life0, 'async_trait>(
&'life0 self,
_request: Request<RollbackTransactionRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<RollbackTransactionResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn rollback_transaction<'life0, 'async_trait>(
&'life0 self,
_request: Request<RollbackTransactionRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<RollbackTransactionResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl<Backend> Freeze for KvStore<Backend>where
Backend: Freeze,
impl<Backend> RefUnwindSafe for KvStore<Backend>where
Backend: RefUnwindSafe,
impl<Backend> Send for KvStore<Backend>where
Backend: Send,
impl<Backend> Sync for KvStore<Backend>where
Backend: Sync,
impl<Backend> Unpin for KvStore<Backend>where
Backend: Unpin,
impl<Backend> UnwindSafe for KvStore<Backend>where
Backend: UnwindSafe,
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> 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