Trait StorageTxn

Source
pub trait StorageTxn {
    // Required methods
    fn get_client<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Client>>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn new_client<'life0, 'async_trait>(
        &'life0 mut self,
        latest_version_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn set_snapshot<'life0, 'async_trait>(
        &'life0 mut self,
        snapshot: Snapshot,
        data: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_snapshot_data<'life0, 'async_trait>(
        &'life0 mut self,
        version_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_version_by_parent<'life0, 'async_trait>(
        &'life0 mut self,
        parent_version_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Version>>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_version<'life0, 'async_trait>(
        &'life0 mut self,
        version_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Version>>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn add_version<'life0, 'async_trait>(
        &'life0 mut self,
        version_id: Uuid,
        parent_version_id: Uuid,
        history_segment: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn commit<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A transaction in the storage backend.

Transactions must be sequentially consistent. That is, the results of transactions performed in storage must be as if each were executed sequentially in some order. In particular, un-committed changes must not be read by another transaction, but committed changes must be visible to subequent transations. Together, this guarantees that add_version reliably constructs a linear sequence of versions.

Transactions with different client IDs cannot share any data, so it is safe to handle them concurrently.

Changes in a transaction that is dropped without calling commit must not appear in any other transaction.

Required Methods§

Source

fn get_client<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<Client>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get information about the client for this transaction

Source

fn new_client<'life0, 'async_trait>( &'life0 mut self, latest_version_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create the client for this transaction, with the given latest_version_id. The client must not already exist.

Source

fn set_snapshot<'life0, 'async_trait>( &'life0 mut self, snapshot: Snapshot, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set the client’s most recent snapshot.

Source

fn get_snapshot_data<'life0, 'async_trait>( &'life0 mut self, version_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the data for the most recent snapshot. The version_id is used to verify that the snapshot is for the correct version.

Source

fn get_version_by_parent<'life0, 'async_trait>( &'life0 mut self, parent_version_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<Version>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a version, indexed by parent version id

Source

fn get_version<'life0, 'async_trait>( &'life0 mut self, version_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<Version>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a version, indexed by its own version id

Source

fn add_version<'life0, 'async_trait>( &'life0 mut self, version_id: Uuid, parent_version_id: Uuid, history_segment: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add a version (that must not already exist), and

  • update latest_version_id from parent_version_id to version_id
  • increment snapshot.versions_since Fails if the existing latest_version_id is not equal to parent_version_id. Check this by calling get_client earlier in the same transaction.
Source

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

Commit any changes made in the transaction. It is an error to call this more than once. It is safe to skip this call for read-only operations.

Implementors§