taskchampion_sync_server_core

Trait StorageTxn

Source
pub trait StorageTxn {
    // Required methods
    fn get_client(&mut self, client_id: Uuid) -> Result<Option<Client>>;
    fn new_client(
        &mut self,
        client_id: Uuid,
        latest_version_id: Uuid,
    ) -> Result<()>;
    fn set_snapshot(
        &mut self,
        client_id: Uuid,
        snapshot: Snapshot,
        data: Vec<u8>,
    ) -> Result<()>;
    fn get_snapshot_data(
        &mut self,
        client_id: Uuid,
        version_id: Uuid,
    ) -> Result<Option<Vec<u8>>>;
    fn get_version_by_parent(
        &mut self,
        client_id: Uuid,
        parent_version_id: Uuid,
    ) -> Result<Option<Version>>;
    fn get_version(
        &mut self,
        client_id: Uuid,
        version_id: Uuid,
    ) -> Result<Option<Version>>;
    fn add_version(
        &mut self,
        client_id: Uuid,
        version_id: Uuid,
        parent_version_id: Uuid,
        history_segment: Vec<u8>,
    ) -> Result<()>;
    fn commit(&mut self) -> Result<()>;
}
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, the Client.latest_version must not change between a call to get_client and add_version.

Required Methods§

Source

fn get_client(&mut self, client_id: Uuid) -> Result<Option<Client>>

Get information about the given client

Source

fn new_client(&mut self, client_id: Uuid, latest_version_id: Uuid) -> Result<()>

Create a new client with the given latest_version_id

Source

fn set_snapshot( &mut self, client_id: Uuid, snapshot: Snapshot, data: Vec<u8>, ) -> Result<()>

Set the client’s most recent snapshot.

Source

fn get_snapshot_data( &mut self, client_id: Uuid, version_id: Uuid, ) -> Result<Option<Vec<u8>>>

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( &mut self, client_id: Uuid, parent_version_id: Uuid, ) -> Result<Option<Version>>

Get a version, indexed by parent version id

Source

fn get_version( &mut self, client_id: Uuid, version_id: Uuid, ) -> Result<Option<Version>>

Get a version, indexed by its own version id

Source

fn add_version( &mut self, client_id: Uuid, version_id: Uuid, parent_version_id: Uuid, history_segment: Vec<u8>, ) -> Result<()>

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

  • update latest_version_id
  • increment snapshot.versions_since
Source

fn commit(&mut self) -> Result<()>

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§