Skip to main content

Transaction

Trait Transaction 

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

Source

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.

Source

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.

Source

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.

Source

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 transaction
  • Err if read operation fails
Source

fn commit<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Commit the transaction, applying all changes atomically.

Source

fn rollback<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Rollback the transaction, discarding all changes.

Implementors§