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§
sourcefn fold_transactions_from<D>(
&self,
offset: TxOffset,
decoder: D
) -> Result<(), D::Error>
fn fold_transactions_from<D>( &self, offset: TxOffset, decoder: D ) -> Result<(), D::Error>
Traverse the history of transactions from offset
and “fold” it into
the provided Decoder
.
sourcefn transactions_from<'a, D>(
&self,
offset: TxOffset,
decoder: &'a D
) -> impl Iterator<Item = Result<Transaction<Self::TxData>, D::Error>>
fn transactions_from<'a, D>( &self, offset: TxOffset, decoder: &'a D ) -> impl Iterator<Item = Result<Transaction<Self::TxData>, D::Error>>
Obtain an iterator over the history of transactions, starting from offset
.
Provided Methods§
sourcefn max_tx_offset(&self) -> Option<TxOffset>
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.