pub struct VibeDbClient { /* private fields */ }Expand description
Database client exposed for advanced integrations. Client used by the SDK to coordinate database worker operations.
Implementations§
Source§impl VibeDbClient
impl VibeDbClient
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a database client using the default store backend.
§Returns
A VibeDbClient with its worker loop initialized.
Sourcepub fn with_backend(backend: VibeStoreBackend) -> Self
pub fn with_backend(backend: VibeStoreBackend) -> Self
Creates a database client using a specific store backend.
§Returns
A VibeDbClient with its worker loop initialized for backend.
§Examples
use vibe_ready::{VibeDbClient, VibeStoreBackend};
let client = VibeDbClient::with_backend(VibeStoreBackend::Noop);
drop(client);Source§impl VibeDbClient
impl VibeDbClient
Sourcepub async fn close(&self) -> Result<(), VibeEngineError>
pub async fn close(&self) -> Result<(), VibeEngineError>
Closes the worker channel and database backend.
§Returns
Ok(()) when closed or already closed, otherwise VibeEngineError.
Sourcepub async fn try_open(
&self,
store_path: PathBuf,
user_id: String,
is_encrypt: bool,
) -> Result<(), VibeEngineError>
pub async fn try_open( &self, store_path: PathBuf, user_id: String, is_encrypt: bool, ) -> Result<(), VibeEngineError>
Opens the configured backend at store_path for user_id.
§Returns
Ok(()) when the backend is ready, or VibeEngineError on open failure.
Source§impl VibeDbClient
impl VibeDbClient
Sourcepub async fn set(
&self,
key: String,
value: VibeKvValue,
) -> Result<(), VibeEngineError>
pub async fn set( &self, key: String, value: VibeKvValue, ) -> Result<(), VibeEngineError>
Sourcepub async fn get(
&self,
key: String,
) -> Result<Option<VibeKvValue>, VibeEngineError>
pub async fn get( &self, key: String, ) -> Result<Option<VibeKvValue>, VibeEngineError>
Sourcepub async fn get_str(
&self,
key: String,
) -> Result<Option<String>, VibeEngineError>
pub async fn get_str( &self, key: String, ) -> Result<Option<String>, VibeEngineError>
Gets a string value from the default bucket.
§Returns
Ok(Some(String)) only when the value is a string.
Sourcepub async fn get_bool(
&self,
key: String,
) -> Result<Option<bool>, VibeEngineError>
pub async fn get_bool( &self, key: String, ) -> Result<Option<bool>, VibeEngineError>
Gets a boolean value from the default bucket.
§Returns
Ok(Some(bool)) only when the value is a boolean.
Sourcepub async fn contains(&self, key: String) -> Result<bool, VibeEngineError>
pub async fn contains(&self, key: String) -> Result<bool, VibeEngineError>
Checks whether a key exists in the default bucket.
§Returns
Ok(true) when the key exists and is not expired.
Sourcepub async fn current_user_id(&self) -> Result<String, VibeEngineError>
pub async fn current_user_id(&self) -> Result<String, VibeEngineError>
Returns the user id associated with the open backend.
§Returns
Ok(String) after VibeDbClient::try_open, otherwise a database-not-open error.
Source§impl VibeDbClient
impl VibeDbClient
Sourcepub async fn set_in_bucket(
&self,
bucket: String,
key: String,
value: VibeKvValue,
expires_at_ms: i64,
) -> Result<(), VibeEngineError>
pub async fn set_in_bucket( &self, bucket: String, key: String, value: VibeKvValue, expires_at_ms: i64, ) -> Result<(), VibeEngineError>
Sourcepub async fn get_in_bucket(
&self,
bucket: String,
key: String,
) -> Result<Option<VibeKvValue>, VibeEngineError>
pub async fn get_in_bucket( &self, bucket: String, key: String, ) -> Result<Option<VibeKvValue>, VibeEngineError>
Gets a value from a named bucket.
§Returns
Ok(Some(value)), Ok(None) for missing/expired keys, or an error.
Sourcepub async fn remove_in_bucket(
&self,
bucket: String,
key: String,
) -> Result<bool, VibeEngineError>
pub async fn remove_in_bucket( &self, bucket: String, key: String, ) -> Result<bool, VibeEngineError>
Sourcepub async fn contains_in_bucket(
&self,
bucket: String,
key: String,
) -> Result<bool, VibeEngineError>
pub async fn contains_in_bucket( &self, bucket: String, key: String, ) -> Result<bool, VibeEngineError>
Checks whether a key exists in a named bucket.
§Returns
Ok(true) when the key exists and is not expired.
Sourcepub async fn list_keys_in_bucket(
&self,
bucket: String,
) -> Result<Vec<String>, VibeEngineError>
pub async fn list_keys_in_bucket( &self, bucket: String, ) -> Result<Vec<String>, VibeEngineError>
Sourcepub async fn get_many_in_bucket(
&self,
bucket: String,
keys: Vec<String>,
) -> Result<Vec<(String, VibeKvValue)>, VibeEngineError>
pub async fn get_many_in_bucket( &self, bucket: String, keys: Vec<String>, ) -> Result<Vec<(String, VibeKvValue)>, VibeEngineError>
Reads multiple keys from a named bucket.
§Returns
A vector of (key, value) pairs for existing, non-expired keys.
Sourcepub async fn set_many_in_bucket(
&self,
bucket: String,
items: Vec<(String, VibeKvValue, i64)>,
) -> Result<(), VibeEngineError>
pub async fn set_many_in_bucket( &self, bucket: String, items: Vec<(String, VibeKvValue, i64)>, ) -> Result<(), VibeEngineError>
Writes multiple values to a named bucket in one transaction.
§Returns
Ok(()) when the batch commit succeeds.
Sourcepub async fn remove_many_in_bucket(
&self,
bucket: String,
keys: Vec<String>,
) -> Result<(), VibeEngineError>
pub async fn remove_many_in_bucket( &self, bucket: String, keys: Vec<String>, ) -> Result<(), VibeEngineError>
Removes multiple keys from a named bucket in one transaction.
§Returns
Ok(()) when the batch commit succeeds.
Sourcepub async fn transaction_ops(
&self,
ops: Vec<DbKvOp>,
) -> Result<(), VibeEngineError>
pub async fn transaction_ops( &self, ops: Vec<DbKvOp>, ) -> Result<(), VibeEngineError>
Apply pre-built ops (already user-scoped) inside one DB transaction.
§Returns
Ok(()) when every operation commits atomically.
Sourcepub async fn purge_expired(&self) -> Result<usize, VibeEngineError>
pub async fn purge_expired(&self) -> Result<usize, VibeEngineError>
Source§impl VibeDbClient
impl VibeDbClient
Sourcepub async fn insert_or_replace_key_val(
&self,
table: VibeTableKeyVal,
) -> Result<(), VibeEngineError>
pub async fn insert_or_replace_key_val( &self, table: VibeTableKeyVal, ) -> Result<(), VibeEngineError>
Sourcepub async fn get_key_val(
&self,
user_id: String,
bucket: String,
key: String,
) -> Result<Option<VibeTableKeyVal>, VibeEngineError>
pub async fn get_key_val( &self, user_id: String, bucket: String, key: String, ) -> Result<Option<VibeTableKeyVal>, VibeEngineError>
Sourcepub async fn get_key_val_vec(
&self,
user_id: String,
bucket: String,
keys: Vec<String>,
) -> Result<Vec<VibeTableKeyVal>, VibeEngineError>
pub async fn get_key_val_vec( &self, user_id: String, bucket: String, keys: Vec<String>, ) -> Result<Vec<VibeTableKeyVal>, VibeEngineError>
Sourcepub async fn remove_key_val(
&self,
user_id: String,
bucket: String,
key: String,
) -> Result<bool, VibeEngineError>
pub async fn remove_key_val( &self, user_id: String, bucket: String, key: String, ) -> Result<bool, VibeEngineError>
Sourcepub async fn contains_key_val(
&self,
user_id: String,
bucket: String,
key: String,
) -> Result<bool, VibeEngineError>
pub async fn contains_key_val( &self, user_id: String, bucket: String, key: String, ) -> Result<bool, VibeEngineError>
Sourcepub async fn list_key_vals(
&self,
user_id: String,
bucket: String,
) -> Result<Vec<String>, VibeEngineError>
pub async fn list_key_vals( &self, user_id: String, bucket: String, ) -> Result<Vec<String>, VibeEngineError>
Trait Implementations§
Source§impl Clone for VibeDbClient
impl Clone for VibeDbClient
Source§fn clone(&self) -> VibeDbClient
fn clone(&self) -> VibeDbClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for VibeDbClient
impl !UnwindSafe for VibeDbClient
impl Freeze for VibeDbClient
impl Send for VibeDbClient
impl Sync for VibeDbClient
impl Unpin for VibeDbClient
impl UnsafeUnpin for VibeDbClient
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read more