pub trait Codec: Sized {
fn encode(&self, _output: &mut Vec<u8>) { ... }
fn decode(_reader: &mut Reader<'_>) -> CodecResult<Self> { ... }
fn skip(reader: &mut Reader<'_>) -> CodecResult<()> { ... }
fn value_type() -> ValueType { ... }
fn encode_bytes(&self) -> Vec<u8> { ... }
}
Expand description
Trait for implementing things that can be decoded from a Reader and encoded to a byte Vec
Provided Methods
sourcefn encode(&self, _output: &mut Vec<u8>)
fn encode(&self, _output: &mut Vec<u8>)
Function for implementing encoding of Self to the provided vec of bytes
sourcefn decode(_reader: &mut Reader<'_>) -> CodecResult<Self>
fn decode(_reader: &mut Reader<'_>) -> CodecResult<Self>
Function for implementing decoding of Self from the provided Reader. Will return None if self cannot be decoded
sourcefn skip(reader: &mut Reader<'_>) -> CodecResult<()>
fn skip(reader: &mut Reader<'_>) -> CodecResult<()>
Function to provide functionality for skipping this data type (e.g. read the bytes without using them)
sourcefn value_type() -> ValueType
fn value_type() -> ValueType
Optional additional specifier for Tdf types that tells which type this is
sourcefn encode_bytes(&self) -> Vec<u8>
fn encode_bytes(&self) -> Vec<u8>
Shortcut function for encoding self directly to a Vec of bytes