pub trait HeaderCoding {
type Item;
Show 13 methods
// Required methods
fn identifier() -> u32;
fn encode_header(&self) -> Vec<u8> ⓘ;
fn version(&self) -> u8;
fn decode_content(data: Vec<u8>) -> Result<Self::Item>;
// Provided methods
fn header_size(&self) -> usize { ... }
fn encode_key<K: Into<String>>(key: K) -> Vec<u8> ⓘ { ... }
fn encode_directly(&self) -> Vec<u8> ⓘ { ... }
fn encode_for_key<K: Into<String>>(&self, key: K) -> Vec<u8> ⓘ { ... }
fn decode_header_length<R: Read>(data: &mut R) -> Result<u64> { ... }
fn check_identifier<R: Read>(data: &mut R) -> bool { ... }
fn check_key_on_position<K: Into<String>, R: Read>(
data: &mut R,
key: K,
) -> bool { ... }
fn decode_directly<R: Read>(data: &mut R) -> Result<Self::Item> { ... }
fn decode_for_key<K: Into<String>, R: Read>(
data: &mut R,
key: K,
) -> Result<Self::Item> { ... }
}Expand description
The HeaderCoding trait specifies an interface for the common header methods and the encoding and decoding methods.
Required Associated Types§
Required Methods§
Sourcefn identifier() -> u32
fn identifier() -> u32
returns the identifier (=Magic bytes) of the header.
Sourcefn encode_header(&self) -> Vec<u8> ⓘ
fn encode_header(&self) -> Vec<u8> ⓘ
encodes the header.
Provided Methods§
Sourcefn header_size(&self) -> usize
fn header_size(&self) -> usize
returns the size of the encoded header (in bytes)
Sourcefn encode_directly(&self) -> Vec<u8> ⓘ
fn encode_directly(&self) -> Vec<u8> ⓘ
encodes the (header) value/object directly (= without key).
Sourcefn encode_for_key<K: Into<String>>(&self, key: K) -> Vec<u8> ⓘ
fn encode_for_key<K: Into<String>>(&self, key: K) -> Vec<u8> ⓘ
encodes a key to the (header) value/object.
Sourcefn decode_header_length<R: Read>(data: &mut R) -> Result<u64>
fn decode_header_length<R: Read>(data: &mut R) -> Result<u64>
decodes the length of the header.
Sourcefn check_identifier<R: Read>(data: &mut R) -> bool
fn check_identifier<R: Read>(data: &mut R) -> bool
checks if the read identifier is valid for this header.
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.