Skip to main content

VibeDbClient

Struct VibeDbClient 

Source
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

Source

pub fn new() -> Self

Creates a database client using the default store backend.

§Returns

A VibeDbClient with its worker loop initialized.

Source

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

Source

pub async fn close(&self) -> Result<(), VibeEngineError>

Closes the worker channel and database backend.

§Returns

Ok(()) when closed or already closed, otherwise VibeEngineError.

Source

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

Source

pub async fn set( &self, key: String, value: VibeKvValue, ) -> Result<(), VibeEngineError>

Sets a value in the default bucket.

§Returns

Ok(()) when the value is written.

Source

pub async fn set_str( &self, key: String, value: String, ) -> Result<(), VibeEngineError>

Sets a string value in the default bucket.

§Returns

Ok(()) when the value is written.

Source

pub async fn set_bool( &self, key: String, value: bool, ) -> Result<(), VibeEngineError>

Sets a boolean value in the default bucket.

§Returns

Ok(()) when the value is written.

Source

pub async fn set_i32( &self, key: String, value: i32, ) -> Result<(), VibeEngineError>

Sets an i32 value in the default bucket.

§Returns

Ok(()) when the value is written.

Source

pub async fn get( &self, key: String, ) -> Result<Option<VibeKvValue>, VibeEngineError>

Gets a value from the default bucket.

§Returns

Ok(Some(value)), Ok(None), or VibeEngineError.

Source

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.

Source

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.

Source

pub async fn get_i32(&self, key: String) -> Result<Option<i32>, VibeEngineError>

Gets an i32 value from the default bucket.

§Returns

Ok(Some(i32)) only when the value is an i32.

Source

pub async fn remove(&self, key: String) -> Result<bool, VibeEngineError>

Removes a key from the default bucket.

§Returns

Ok(true) when the key existed and was removed.

Source

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.

Source

pub async fn list_keys(&self) -> Result<Vec<String>, VibeEngineError>

Lists keys in the default bucket.

§Returns

A vector of key names.

Source

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

Source

pub async fn set_in_bucket( &self, bucket: String, key: String, value: VibeKvValue, expires_at_ms: i64, ) -> Result<(), VibeEngineError>

Sets a value in a named bucket.

§Returns

Ok(()) when the value is written.

Source

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.

Source

pub async fn remove_in_bucket( &self, bucket: String, key: String, ) -> Result<bool, VibeEngineError>

Removes a key from a named bucket.

§Returns

Ok(true) when the key existed and was removed.

Source

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.

Source

pub async fn list_keys_in_bucket( &self, bucket: String, ) -> Result<Vec<String>, VibeEngineError>

Lists keys in a named bucket.

§Returns

A vector of key names.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn purge_expired(&self) -> Result<usize, VibeEngineError>

Purges expired rows from the backend.

§Returns

Number of rows removed by the backend.

Source§

impl VibeDbClient

Source

pub async fn insert_or_replace_key_val( &self, table: VibeTableKeyVal, ) -> Result<(), VibeEngineError>

Inserts or replaces a low-level key-value row.

§Returns

Ok(()) when the row is written.

Source

pub async fn get_key_val( &self, user_id: String, bucket: String, key: String, ) -> Result<Option<VibeTableKeyVal>, VibeEngineError>

Gets a low-level key-value row.

§Returns

Ok(Some(row)), Ok(None), or VibeEngineError.

Source

pub async fn get_key_val_vec( &self, user_id: String, bucket: String, keys: Vec<String>, ) -> Result<Vec<VibeTableKeyVal>, VibeEngineError>

Gets multiple low-level key-value rows.

§Returns

A vector of matching rows.

Source

pub async fn remove_key_val( &self, user_id: String, bucket: String, key: String, ) -> Result<bool, VibeEngineError>

Removes a low-level key-value row.

§Returns

Ok(true) when a row was removed.

Source

pub async fn contains_key_val( &self, user_id: String, bucket: String, key: String, ) -> Result<bool, VibeEngineError>

Checks whether a low-level key-value row exists.

§Returns

Ok(true) when the row exists.

Source

pub async fn list_key_vals( &self, user_id: String, bucket: String, ) -> Result<Vec<String>, VibeEngineError>

Lists low-level key names for a user and bucket.

§Returns

A vector of key names.

Trait Implementations§

Source§

impl Clone for VibeDbClient

Source§

fn clone(&self) -> VibeDbClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AggregateExpressionMethods for T

Source§

fn aggregate_distinct(self) -> Self::Output
where Self: DistinctDsl,

DISTINCT modifier for aggregate functions Read more
Source§

fn aggregate_all(self) -> Self::Output
where Self: AllDsl,

ALL modifier for aggregate functions Read more
Source§

fn aggregate_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add an aggregate function filter Read more
Source§

fn aggregate_order<O>(self, o: O) -> Self::Output
where Self: OrderAggregateDsl<O>,

Add an aggregate function order Read more
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoSql for T

Source§

fn into_sql<T>(self) -> Self::Expression

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> WindowExpressionMethods for T

Source§

fn over(self) -> Self::Output
where Self: OverDsl,

Turn a function call into a window function call Read more
Source§

fn window_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add a filter to the current window function Read more
Source§

fn partition_by<E>(self, expr: E) -> Self::Output
where Self: PartitionByDsl<E>,

Add a partition clause to the current window function Read more
Source§

fn window_order<E>(self, expr: E) -> Self::Output
where Self: OrderWindowDsl<E>,

Add a order clause to the current window function Read more
Source§

fn frame_by<E>(self, expr: E) -> Self::Output
where Self: FrameDsl<E>,

Add a frame clause to the current window function Read more