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§

source

type Error: From<DecodeError>

source

type Row

The type corresponding to one element in Ops::rowdata.

Required Methods§

source

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 Mutationsinserts.

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.

source

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 Mutationsdeletes.

Similar to Self::visit_insert, but allows the visitor to determine the start of the next section in a Mutations payload.

Provided Methods§

source

fn visit_truncate(&mut self, _table_id: TableId) -> Result<(), Self::Error>

Called for each TableId encountered in the truncates section of a Mutations.

The default implementation does nothing.

source

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.

source

fn visit_tx_end(&mut self) -> Result<(), Self::Error>

Called after each successful decode of a Txdata payload.

The default implementation does nothing.

source

fn visit_inputs(&mut self, _inputs: &Inputs) -> Result<(), Self::Error>

Called for each Inputs encountered in a Txdata payload.

The default implementation does nothing.

source

fn visit_outputs(&mut self, _outputs: &Outputs) -> Result<(), Self::Error>

Called for each Outputs encountered in a Txdata payload.

The default implementation does nothing.

Object Safety§

This trait is not object safe.

Implementors§