pub trait RtdbAdapter:
Debug
+ Send
+ Sync {
Show 14 methods
// 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;
fn delete_tenant_databases<'life0, 'async_trait>(
&'life0 self,
tn_id: TnId,
) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn compact_storage<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClResult<CompactReport>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: '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§
Sourcefn 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 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.
While a transaction is open, no code path may call back into this trait
for the same file. A backend may hold the file’s maintenance barrier for
the transaction’s whole life, and re-entering through an adapter method
takes a second guard on it — which a queued compact_storage writer
deadlocks against permanently, hanging both the transaction and the
maintenance sweep. Every read a transaction needs is on Transaction
itself: Transaction::get, Transaction::query,
Transaction::check_lock.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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).
Sourcefn 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 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.
Sourcefn 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 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).
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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,
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).
Sourcefn delete_tenant_databases<'life0, 'async_trait>(
&'life0 self,
tn_id: TnId,
) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete_tenant_databases<'life0, 'async_trait>(
&'life0 self,
tn_id: TnId,
) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delete every RTDB database owned by the tenant.
Used by tenant purge orchestration. Implementations should treat a missing tenant store as success.
Provided Methods§
Sourcefn compact_storage<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClResult<CompactReport>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn compact_storage<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClResult<CompactReport>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Rewrite every storage file, returning the space already freed inside them to the filesystem.
Called from the nightly maintenance task, never from a request path: a backend may have to close and reopen its files, which blocks every reader and writer of the one being rewritten.
Defaults to a no-op report, the honest answer for a backend with nothing to compact.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".