Trait checkpoint::storage::Storage
[−]
[src]
pub trait Storage { type Committed: CommittedCheckpoint; type Uncommitted: UncommittedCheckpoint; fn create_checkpoint(
&mut self,
identifier: &str
) -> Result<Self::Uncommitted>; fn commit_checkpoint(
&mut self,
uncommitted: Self::Uncommitted
) -> Result<Self::Committed>; fn load_checkpoint(&mut self, identifier: &str) -> Result<Self::Committed>; fn remove_checkpoint(&mut self, identifier: &str) -> Result<()>; fn checkpoint_identifiers(&mut self) -> Result<Vec<String>>; }
The Storage
trait allows checkpoints to be created, committed, loaded, and removed from the
underlying storage medium.
Associated Types
type Committed: CommittedCheckpoint
The type representing committed checkpoints.
type Uncommitted: UncommittedCheckpoint
The type representing uncommitted checkpoints.
Required Methods
fn create_checkpoint(&mut self, identifier: &str) -> Result<Self::Uncommitted>
Creates a new checkpoint with the specified identifier.
The checkpoint will not be saved permanently until it has been committed via the
commit_checkpoint
method.
Care must be taken to ensure that the same identifier isn't used for multiple uncommitted
checkpoints. It is recommended that types which implement Storage
be wrapped in the
GuardWrapper
type
(or implement its functionality) to prevent uncommitted checkpoints from being given the
same identifier.
fn commit_checkpoint(
&mut self,
uncommitted: Self::Uncommitted
) -> Result<Self::Committed>
&mut self,
uncommitted: Self::Uncommitted
) -> Result<Self::Committed>
Commits an uncommitted checkpoint, permanently saving its data to the underlying storage medium.
fn load_checkpoint(&mut self, identifier: &str) -> Result<Self::Committed>
Loads the committed checkpoint associated with the provided identifier, allowing its data to be retrieved.
fn remove_checkpoint(&mut self, identifier: &str) -> Result<()>
Removes the committed checkpoint associated with the provided identifier.
Care must be taken to ensure that checkpoints which are in use (i.e. have a binding created
by either the commit_checkpoint
method or the load_checkpoint
method) are not removed.
It is recommended that types which implement Storage
be wrapped in the
GuardWrapper
type
(or implement its functionality) to prevent accidental removal of checkpoints which are in
use.
fn checkpoint_identifiers(&mut self) -> Result<Vec<String>>
Returns a list of all committed checkpoint identifiers in the underlying storage medium.
Implementors
impl Storage for FileStorage type Committed = Committed; type Uncommitted = Uncommitted;
impl Storage for MemoryStorage type Committed = Committed; type Uncommitted = Uncommitted;
impl<S: Storage> Storage for ChecksumWrapper<S> type Committed = Committed<S::Committed>; type Uncommitted = Uncommitted<S::Uncommitted>;
impl<T: Storage> Storage for GuardWrapper<T> type Committed = Committed<T::Committed>; type Uncommitted = Uncommitted<T::Uncommitted>;
impl<S: Storage> Storage for HmacWrapper<S> type Committed = Committed<S::Committed>; type Uncommitted = Uncommitted<S::Uncommitted>;