Trait spacetimedb_durability::History

source ·
pub trait History {
    type TxData;

    // Required methods
    fn fold_transactions_from<D>(
        &self,
        offset: TxOffset,
        decoder: D
    ) -> Result<(), D::Error>
       where D: Decoder,
             D::Error: From<Traversal>;
    fn transactions_from<'a, D>(
        &self,
        offset: TxOffset,
        decoder: &'a D
    ) -> impl Iterator<Item = Result<Transaction<Self::TxData>, D::Error>>
       where D: Decoder<Record = Self::TxData>,
             D::Error: From<Traversal>,
             Self::TxData: 'a;

    // Provided method
    fn max_tx_offset(&self) -> Option<TxOffset> { ... }
}
Expand description

Access to the durable history.

The durable history is the sequence of transactions in the order Durability::append_tx was called.

Some Durability implementations will be able to also implement this trait, but others may not. A database may also use a Durability implementation to persist transactions, but a separate History implementation to obtain the history.

Required Associated Types§

Required Methods§

source

fn fold_transactions_from<D>( &self, offset: TxOffset, decoder: D ) -> Result<(), D::Error>
where D: Decoder, D::Error: From<Traversal>,

Traverse the history of transactions from offset and “fold” it into the provided Decoder.

source

fn transactions_from<'a, D>( &self, offset: TxOffset, decoder: &'a D ) -> impl Iterator<Item = Result<Transaction<Self::TxData>, D::Error>>
where D: Decoder<Record = Self::TxData>, D::Error: From<Traversal>, Self::TxData: 'a,

Obtain an iterator over the history of transactions, starting from offset.

Provided Methods§

source

fn max_tx_offset(&self) -> Option<TxOffset>

Get the maximum transaction offset contained in this history.

Similar to std::iter::Iterator::size_hint, this is considered an estimation: the upper bound may not be known, or it may change after this method was called because more data was added to the log.

Callers should thus only rely on it for informational purposes.

The default implementation returns None, which is correct for any history implementation.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T: History> History for Arc<T>

§

type TxData = <T as History>::TxData

source§

fn fold_transactions_from<D>( &self, offset: TxOffset, decoder: D ) -> Result<(), D::Error>
where D: Decoder, D::Error: From<Traversal>,

source§

fn transactions_from<'a, D>( &self, offset: TxOffset, decoder: &'a D ) -> impl Iterator<Item = Result<Transaction<Self::TxData>, D::Error>>
where D: Decoder<Record = Self::TxData>, D::Error: From<Traversal>, Self::TxData: 'a,

source§

fn max_tx_offset(&self) -> Option<TxOffset>

Implementors§

source§

impl<T: Encode + 'static> History for Local<T>

§

type TxData = Txdata<T>