pub trait Decoder {
type Record: Encode;
type Error: From<DecodeError>;
// Required methods
fn decode_record<'a, R: BufReader<'a>>(
&self,
version: u8,
tx_offset: u64,
reader: &mut R,
) -> Result<Self::Record, Self::Error>;
fn skip_record<'a, R: BufReader<'a>>(
&self,
version: u8,
tx_offset: u64,
reader: &mut R,
) -> Result<(), Self::Error>;
// Provided method
fn consume_record<'a, R: BufReader<'a>>(
&self,
version: u8,
tx_offset: u64,
reader: &mut R,
) -> Result<(), Self::Error> { ... }
}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.
Required Associated Types§
Sourcetype Record: Encode
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.
Sourcetype Error: From<DecodeError>
type Error: From<DecodeError>
The type of decode errors, which must subsume DecodeError.
Required Methods§
Sourcefn decode_record<'a, R: BufReader<'a>>(
&self,
version: u8,
tx_offset: u64,
reader: &mut R,
) -> Result<Self::Record, Self::Error>
fn decode_record<'a, R: BufReader<'a>>( &self, version: u8, tx_offset: u64, reader: &mut R, ) -> Result<Self::Record, Self::Error>
Decode one Self::Record from the given buffer.
The version argument corresponds to the log format version of the
current segment (see crate::segment::Header::log_format_version).
The tx_argument is the transaction offset of the current record
relative to the start of the log.
Sourcefn skip_record<'a, R: BufReader<'a>>(
&self,
version: u8,
tx_offset: u64,
reader: &mut R,
) -> Result<(), Self::Error>
fn skip_record<'a, R: BufReader<'a>>( &self, version: u8, tx_offset: u64, reader: &mut R, ) -> Result<(), Self::Error>
Advance reader past the next Self::Record, without returning it
or including it in a fold.
Provided Methods§
Sourcefn consume_record<'a, R: BufReader<'a>>(
&self,
version: u8,
tx_offset: u64,
reader: &mut R,
) -> Result<(), Self::Error>
fn consume_record<'a, R: BufReader<'a>>( &self, version: u8, tx_offset: u64, reader: &mut R, ) -> Result<(), Self::Error>
Variant of Self::decode_record which discards the decoded
Self::Record.
Useful for folds which don’t need to yield or collect record values.
The default implementation just drops the record returned from
Self::decode_record. Implementations may want to override this, such
that the record is not allocated in the first place.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.