Struct KvStore

Source
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>
where Backend: DatabaseBackend + TransactionalBackend, Backend::Error: Display + Debug,

Source

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.

Source

pub fn at_path<P>(path: P) -> Result<Self, Backend::Error>
where P: Into<PathBuf>,

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.

Source

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.

Source

pub fn create_index(&self, config: IndexConfig) -> Result<(), IndexError>

Create a secondary index on the key-value store

Source

pub fn drop_index(&self, name: &str) -> Result<(), IndexError>

Drop a secondary index

Source

pub const fn index_manager(&self) -> &Arc<IndexManager>

Get the index manager

Source§

impl<Backend> KvStore<Backend>
where Backend: TransactionalBackend, Backend::Error: Display,

Source

pub 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.

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: Debug + TransactionalBackend> Debug for KvStore<Backend>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

Server streaming response type for the Get method.
Source§

type SetStream = <Backend as KvBackend>::SetStream

Server streaming response type for the Set method.
Source§

type DeleteStream = <Backend as KvBackend>::DeleteStream

Server streaming response type for the Delete method.
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,

Get a value for a given key.
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,

Set a value for a given key. If the key already exists, the value is updated. Read more
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,

Delete a value for a given key. Read more
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,

Determine if all provided keys have the same value. Read more
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,

Determine if all provided keys have different values. Read more
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,

Begin a new transaction. Returns a transaction ID that must be passed to subsequent operations.
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,

Commit a transaction. All operations within the transaction are made permanent.
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,

Rollback a transaction. All operations within the transaction are discarded.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more