pub trait Consensus: Debug {
    fn head<'life0, 'life1, 'async_trait>(
        &'life0 self,
        deadline: Instant,
        key: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<Option<VersionedData>, ExternalError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; fn compare_and_set<'life0, 'life1, 'async_trait>(
        &'life0 self,
        deadline: Instant,
        key: &'life1 str,
        expected: Option<SeqNo>,
        new: VersionedData
    ) -> Pin<Box<dyn Future<Output = Result<Result<(), Option<VersionedData>>, ExternalError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; fn scan<'life0, 'life1, 'async_trait>(
        &'life0 self,
        deadline: Instant,
        key: &'life1 str,
        from: SeqNo
    ) -> Pin<Box<dyn Future<Output = Result<Vec<VersionedData>, ExternalError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; fn truncate<'life0, 'life1, 'async_trait>(
        &'life0 self,
        deadline: Instant,
        key: &'life1 str,
        seqno: SeqNo
    ) -> Pin<Box<dyn Future<Output = Result<(), ExternalError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }
Expand description

An abstraction for VersionedData held in a location in persistent storage where the data are conditionally updated by version.

Users are expected to use this API with consistently increasing sequence numbers to allow multiple processes across multiple machines to agree to a total order of the evolution of the data. To make roundtripping through various forms of durable storage easier, sequence numbers used with Consensus need to be restricted to the range [0, i64::MAX].

Required methods

Returns a recent version of data, and the corresponding sequence number, if one exists at this location.

Update the VersionedData stored at this location to new, iff the current sequence number is exactly expected and new’s sequence number > the current sequence number.

Returns a recent version and data from this location iff the current sequence number does not equal expected or if new’s sequence number is less than or equal to the current sequence number. It is invalid to call this function with a new and expected such that new’s sequence number is <= expected. It is invalid to call this function with a sequence number outside of the range [0, i64::MAX].

This data is initialized to None, and the first call to compare_and_set needs to happen with None as the expected value to set the state.

Return all versions of data stored for this key at sequence numbers >= from, in ascending order of sequence number.

Returns an error if from is greater than the current sequence number or if there is no data at this key.

Deletes all historical versions of the data stored at key that are < seqno, iff seqno <= the current sequence number.

Returns an error if seqno is greater than the current sequence number, or if there is no data at this key.

Implementors