Trait spacetimedb_durability::Decoder

source ·
pub trait Decoder {
    type Record: Encode;
    type Error: From<DecodeError>;

    // Required method
    fn decode_record<'a, R>(
        &self,
        version: u8,
        tx_offset: u64,
        reader: &mut R
    ) -> Result<Self::Record, Self::Error>
       where R: BufReader<'a>;
}
Expand description

A decoder which can decode the transaction (aka record) format of the log.

Unlike Encode, this is not a datatype: the canonical commitlog format requires to look up row types during log traversal in order to be able to decode (see also [RowDecoder]).

Required Associated Types§

source

type Record: Encode

The type of records this decoder can decode. This is also the type which can be appended to a commitlog, and so must satisfy Encode.

source

type Error: From<DecodeError>

The type of decode errors, which must subsume DecodeError.

Required Methods§

source

fn decode_record<'a, R>( &self, version: u8, tx_offset: u64, reader: &mut R ) -> Result<Self::Record, Self::Error>
where R: BufReader<'a>,

Decode one Self::Record from the given buffer.

The version argument corresponds to the log format version of the current segment (see [segment::Header::log_format_version]).

The tx_argument is the transaction offset of the current record relative to the start of the log.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<const N: usize> Decoder for ArrayDecoder<N>