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§
Sourcefn get_client(&mut self, client_id: Uuid) -> Result<Option<Client>>
fn get_client(&mut self, client_id: Uuid) -> Result<Option<Client>>
Get information about the given client
Sourcefn new_client(&mut self, client_id: Uuid, latest_version_id: Uuid) -> Result<()>
fn new_client(&mut self, client_id: Uuid, latest_version_id: Uuid) -> Result<()>
Create a new client with the given latest_version_id
Sourcefn set_snapshot(
&mut self,
client_id: Uuid,
snapshot: Snapshot,
data: Vec<u8>,
) -> Result<()>
fn set_snapshot( &mut self, client_id: Uuid, snapshot: Snapshot, data: Vec<u8>, ) -> Result<()>
Set the client’s most recent snapshot.
Sourcefn get_snapshot_data(
&mut self,
client_id: Uuid,
version_id: Uuid,
) -> Result<Option<Vec<u8>>>
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.
Sourcefn get_version_by_parent(
&mut self,
client_id: Uuid,
parent_version_id: Uuid,
) -> Result<Option<Version>>
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
Sourcefn get_version(
&mut self,
client_id: Uuid,
version_id: Uuid,
) -> Result<Option<Version>>
fn get_version( &mut self, client_id: Uuid, version_id: Uuid, ) -> Result<Option<Version>>
Get a version, indexed by its own version id