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