Trait zff::HeaderCoding
source · [−]pub trait HeaderCoding {
type Item;
Show 13 methods
fn identifier() -> u32;
fn encode_header(&self) -> Vec<u8>;
fn version(&self) -> u8;
fn decode_content(data: Vec<u8>) -> Result<Self::Item>;
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.
Associated Types
Required methods
fn identifier() -> u32
fn identifier() -> u32
returns the identifier (=Magic bytes) of the header.
fn encode_header(&self) -> Vec<u8>
fn encode_header(&self) -> Vec<u8>
encodes the header.
Provided methods
fn header_size(&self) -> usize
fn header_size(&self) -> usize
returns the size of the encoded header (in bytes)
fn encode_directly(&self) -> Vec<u8>
fn encode_directly(&self) -> Vec<u8>
encodes the (header) value/object directly (= without key).
encodes a key to the (header) value/object.
decodes the length of the header.
fn 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.
helper method to check, if the key is on position.