Trait spacetimedb_commitlog::payload::txdata::Visitor
source · pub trait Visitor {
type Error: From<DecodeError>;
type Row;
// Required methods
fn visit_insert<'a, R: BufReader<'a>>(
&mut self,
table_id: TableId,
reader: &mut R
) -> Result<Self::Row, Self::Error>;
fn visit_delete<'a, R: BufReader<'a>>(
&mut self,
table_id: TableId,
reader: &mut R
) -> Result<Self::Row, Self::Error>;
// Provided methods
fn visit_truncate(&mut self, _table_id: TableId) -> Result<(), Self::Error> { ... }
fn visit_tx_start(&mut self, _offset: u64) -> Result<(), Self::Error> { ... }
fn visit_tx_end(&mut self) -> Result<(), Self::Error> { ... }
fn visit_inputs(&mut self, _inputs: &Inputs) -> Result<(), Self::Error> { ... }
fn visit_outputs(&mut self, _outputs: &Outputs) -> Result<(), Self::Error> { ... }
}Expand description
A visitor useful to implement stateful [Decoder]s of Txdata payloads.
Required Associated Types§
type Error: From<DecodeError>
sourcetype Row
type Row
The type corresponding to one element in Ops::rowdata.
Required Methods§
sourcefn visit_insert<'a, R: BufReader<'a>>(
&mut self,
table_id: TableId,
reader: &mut R
) -> Result<Self::Row, Self::Error>
fn visit_insert<'a, R: BufReader<'a>>( &mut self, table_id: TableId, reader: &mut R ) -> Result<Self::Row, Self::Error>
Called for each row in each Ops of a Mutations’ inserts.
The implementation is expected to determine the appropriate schema based
on the supplied TableId, and to decode the row data from the
supplied BufReader.
The reader’s position is assumed to be at the start of the next row after the method returns.
sourcefn visit_delete<'a, R: BufReader<'a>>(
&mut self,
table_id: TableId,
reader: &mut R
) -> Result<Self::Row, Self::Error>
fn visit_delete<'a, R: BufReader<'a>>( &mut self, table_id: TableId, reader: &mut R ) -> Result<Self::Row, Self::Error>
Called for each row in each Ops of a Mutations’ deletes.
Similar to Self::visit_insert, but allows the visitor to determine
the start of the next section in a Mutations payload.
Provided Methods§
sourcefn visit_tx_start(&mut self, _offset: u64) -> Result<(), Self::Error>
fn visit_tx_start(&mut self, _offset: u64) -> Result<(), Self::Error>
Called for each Txdata record in a crate::Commit.
The default implementation does nothing.
sourcefn visit_tx_end(&mut self) -> Result<(), Self::Error>
fn visit_tx_end(&mut self) -> Result<(), Self::Error>
Called after each successful decode of a Txdata payload.
The default implementation does nothing.