pub trait Transaction: Send + Sync {
// Required methods
fn create<'life0, 'life1, 'async_trait>(
&'life0 mut self,
path: &'life1 str,
data: Value,
) -> Pin<Box<dyn Future<Output = ClResult<Box<str>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn update<'life0, 'life1, 'async_trait>(
&'life0 mut self,
path: &'life1 str,
data: Value,
) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 mut self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClResult<Option<Value>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
opts: &'life2 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 check_lock<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClResult<Option<LockInfo>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn commit<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn rollback<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Transaction for atomic write operations.
All write operations must be performed within a transaction to ensure atomicity.
Required Methods§
Sourcefn create<'life0, 'life1, 'async_trait>(
&'life0 mut self,
path: &'life1 str,
data: Value,
) -> Pin<Box<dyn Future<Output = ClResult<Box<str>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create<'life0, 'life1, 'async_trait>(
&'life0 mut self,
path: &'life1 str,
data: Value,
) -> Pin<Box<dyn Future<Output = ClResult<Box<str>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Create a new document with auto-generated ID. Returns the generated ID.
Sourcefn update<'life0, 'life1, 'async_trait>(
&'life0 mut self,
path: &'life1 str,
data: Value,
) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update<'life0, 'life1, 'async_trait>(
&'life0 mut self,
path: &'life1 str,
data: Value,
) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Update an existing document (stores the provided data as-is).
Note: This method performs a full document replacement at the storage level. Merge/PATCH semantics should be handled by the caller before invoking this method.
Sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 mut self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 mut self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete a document at a path.
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClResult<Option<Value>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClResult<Option<Value>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read a document from the transaction’s view.
This method provides transaction-local reads with “read-your-own-writes” semantics:
- Returns uncommitted changes made by this transaction
- Provides snapshot isolation from other concurrent transactions
- Essential for atomic operations like increment, append, etc.
§Returns
Ok(Some(value))if document exists (either committed or written by this transaction)Ok(None)if document doesn’t exist or was deleted by this transactionErrif read operation fails
Sourcefn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
opts: &'life2 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,
path: &'life1 str,
opts: &'life2 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 from the transaction’s view, with the same
read-your-own-writes semantics as Transaction::get.
Exists so a caller inside a transaction never has to reach back into
RtdbAdapter::query — see RtdbAdapter::transaction for why that
deadlocks.
Sourcefn check_lock<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClResult<Option<LockInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn check_lock<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClResult<Option<LockInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read a hard/soft lock from the transaction’s view.
Same reason as Transaction::query: the adapter-level
RtdbAdapter::check_lock must not be called while a transaction on the
same file is open.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".