pub struct Store { /* private fields */ }Expand description
Main user-facing database handle.
Implementations§
Source§impl Store
impl Store
Sourcepub fn builder() -> StoreBuilder
pub fn builder() -> StoreBuilder
Creates a store builder.
Sourcepub fn from_parts(
driver: Arc<dyn Driver>,
codec: Arc<dyn Codec>,
namespace: Namespace,
) -> Self
pub fn from_parts( driver: Arc<dyn Driver>, codec: Arc<dyn Codec>, namespace: Namespace, ) -> Self
Creates a store from parts.
Sourcepub async fn initialise(&self) -> Result<()>
pub async fn initialise(&self) -> Result<()>
Prepares the underlying driver for use.
Sourcepub fn capabilities(&self) -> Capabilities
pub fn capabilities(&self) -> Capabilities
Returns the active driver capabilities.
Sourcepub async fn get<T, K>(&self, key: K) -> Result<Option<T>>
pub async fn get<T, K>(&self, key: K) -> Result<Option<T>>
Reads a typed value from the default collection.
Sourcepub async fn set<T, K>(&self, key: K, value: &T) -> Result<()>
pub async fn set<T, K>(&self, key: K, value: &T) -> Result<()>
Writes a typed value to the default collection.
Sourcepub async fn delete<K>(&self, key: K) -> Result<bool>
pub async fn delete<K>(&self, key: K) -> Result<bool>
Deletes a value from the default collection.
Sourcepub async fn exists<K>(&self, key: K) -> Result<bool>
pub async fn exists<K>(&self, key: K) -> Result<bool>
Returns whether a key exists in the default collection.
Sourcepub async fn scan_prefix<T>(
&self,
prefix: impl Into<String>,
) -> Result<Vec<(Key, T)>>where
T: DeserializeOwned,
pub async fn scan_prefix<T>(
&self,
prefix: impl Into<String>,
) -> Result<Vec<(Key, T)>>where
T: DeserializeOwned,
Scans typed values by key prefix in the default collection.
Sourcepub fn collection<T, C>(&self, name: C) -> Result<Collection<T>>
pub fn collection<T, C>(&self, name: C) -> Result<Collection<T>>
Creates a typed collection handle.
Sourcepub async fn get_from_collection<T, K>(
&self,
collection: &CollectionName,
key: K,
) -> Result<Option<T>>
pub async fn get_from_collection<T, K>( &self, collection: &CollectionName, key: K, ) -> Result<Option<T>>
Reads a typed value from a specific collection.
Sourcepub async fn set_in_collection<T, K>(
&self,
collection: &CollectionName,
key: K,
value: &T,
) -> Result<()>
pub async fn set_in_collection<T, K>( &self, collection: &CollectionName, key: K, value: &T, ) -> Result<()>
Writes a typed value to a specific collection.
Sourcepub async fn set_in_collection_with_options<T, K>(
&self,
collection: &CollectionName,
key: K,
value: &T,
options: WriteOptions,
) -> Result<()>
pub async fn set_in_collection_with_options<T, K>( &self, collection: &CollectionName, key: K, value: &T, options: WriteOptions, ) -> Result<()>
Writes a typed value to a specific collection with options.
Sourcepub async fn delete_from_collection<K>(
&self,
collection: &CollectionName,
key: K,
) -> Result<bool>
pub async fn delete_from_collection<K>( &self, collection: &CollectionName, key: K, ) -> Result<bool>
Deletes a value from a specific collection.
Sourcepub async fn exists_in_collection<K>(
&self,
collection: &CollectionName,
key: K,
) -> Result<bool>
pub async fn exists_in_collection<K>( &self, collection: &CollectionName, key: K, ) -> Result<bool>
Returns whether a key exists in a specific collection.
Sourcepub async fn scan_prefix_in_collection<T>(
&self,
collection: &CollectionName,
prefix: impl Into<String>,
) -> Result<Vec<(Key, T)>>where
T: DeserializeOwned,
pub async fn scan_prefix_in_collection<T>(
&self,
collection: &CollectionName,
prefix: impl Into<String>,
) -> Result<Vec<(Key, T)>>where
T: DeserializeOwned,
Scans typed values by key prefix in a specific collection.