Skip to main content

RtdbAdapter

Trait RtdbAdapter 

Source
pub trait RtdbAdapter:
    Debug
    + Send
    + Sync {
    // Required methods
    fn transaction<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tn_id: TnId,
        db_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = ClResult<Box<dyn Transaction>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn close_db<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tn_id: TnId,
        db_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn query<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        tn_id: TnId,
        db_id: &'life1 str,
        path: &'life2 str,
        opts: QueryOptions,
    ) -> Pin<Box<dyn Future<Output = ClResult<Vec<Value>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        tn_id: TnId,
        db_id: &'life1 str,
        path: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = ClResult<Option<Value>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn subscribe<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tn_id: TnId,
        db_id: &'life1 str,
        opts: SubscriptionOptions,
    ) -> Pin<Box<dyn Future<Output = ClResult<Pin<Box<dyn Stream<Item = ChangeEvent> + Send>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn create_index<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        tn_id: TnId,
        db_id: &'life1 str,
        path: &'life2 str,
        field: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn stats<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tn_id: TnId,
        db_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = ClResult<DbStats>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn export_all<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tn_id: TnId,
        db_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = ClResult<Vec<(Box<str>, Value)>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn acquire_lock<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        tn_id: TnId,
        db_id: &'life1 str,
        path: &'life2 str,
        user_id: &'life3 str,
        mode: LockMode,
        conn_id: &'life4 str,
    ) -> Pin<Box<dyn Future<Output = ClResult<Option<LockInfo>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn release_lock<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        tn_id: TnId,
        db_id: &'life1 str,
        path: &'life2 str,
        user_id: &'life3 str,
        conn_id: &'life4 str,
    ) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn check_lock<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        tn_id: TnId,
        db_id: &'life1 str,
        path: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = ClResult<Option<LockInfo>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn release_all_locks<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        tn_id: TnId,
        db_id: &'life1 str,
        user_id: &'life2 str,
        conn_id: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

Real-Time Database Adapter trait.

Unified interface for database backends. Provides transaction-based writes, queries, and real-time subscriptions.

Required Methods§

Source

fn transaction<'life0, 'life1, 'async_trait>( &'life0 self, tn_id: TnId, db_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = ClResult<Box<dyn Transaction>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Begin a new transaction for write operations.

Source

fn close_db<'life0, 'life1, 'async_trait>( &'life0 self, tn_id: TnId, db_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Close a database instance, flushing pending changes to disk.

Source

fn query<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, tn_id: TnId, db_id: &'life1 str, path: &'life2 str, opts: QueryOptions, ) -> Pin<Box<dyn Future<Output = ClResult<Vec<Value>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Query documents at a path with optional filtering, sorting, and pagination.

Source

fn get<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, tn_id: TnId, db_id: &'life1 str, path: &'life2 str, ) -> Pin<Box<dyn Future<Output = ClResult<Option<Value>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get a document at a specific path. Returns None if not found.

Source

fn subscribe<'life0, 'life1, 'async_trait>( &'life0 self, tn_id: TnId, db_id: &'life1 str, opts: SubscriptionOptions, ) -> Pin<Box<dyn Future<Output = ClResult<Pin<Box<dyn Stream<Item = ChangeEvent> + Send>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Subscribe to real-time changes at a path. Returns a stream of ChangeEvents.

Source

fn create_index<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, tn_id: TnId, db_id: &'life1 str, path: &'life2 str, field: &'life3 str, ) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Create an index on a field to improve query performance.

Source

fn stats<'life0, 'life1, 'async_trait>( &'life0 self, tn_id: TnId, db_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = ClResult<DbStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get database statistics (size, record count, table count).

Source

fn export_all<'life0, 'life1, 'async_trait>( &'life0 self, tn_id: TnId, db_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = ClResult<Vec<(Box<str>, Value)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Export all documents from a database.

Returns all (path, document) pairs. The path is relative to the db_id (e.g., posts/abc123). Used for duplicating RTDB files.

Source

fn acquire_lock<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, tn_id: TnId, db_id: &'life1 str, path: &'life2 str, user_id: &'life3 str, mode: LockMode, conn_id: &'life4 str, ) -> Pin<Box<dyn Future<Output = ClResult<Option<LockInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Acquire a lock on a document path.

Returns Ok(None) if the lock was acquired successfully. Returns Ok(Some(LockInfo)) if the path is already locked by another user (denied).

Source

fn release_lock<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, tn_id: TnId, db_id: &'life1 str, path: &'life2 str, user_id: &'life3 str, conn_id: &'life4 str, ) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Release a lock on a document path.

Source

fn check_lock<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, tn_id: TnId, db_id: &'life1 str, path: &'life2 str, ) -> Pin<Box<dyn Future<Output = ClResult<Option<LockInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Check if a path has an active lock. Returns the lock info if locked.

Source

fn release_all_locks<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, tn_id: TnId, db_id: &'life1 str, user_id: &'life2 str, conn_id: &'life3 str, ) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Release all locks held by a specific user (called on disconnect).

Implementors§