pub trait KeyFormat {
// Required methods
fn prefix() -> u8;
fn size() -> usize;
fn encode_atoms(self, atoms: &mut Vec<Vec<u8>>);
fn decode_atoms(data: &[u8]) -> Self
where Self: Sized;
// Provided methods
fn encode_partial(self, count: usize) -> Vec<u8> ⓘ
where Self: Sized { ... }
fn encode(self) -> Vec<u8> ⓘ
where Self: Sized { ... }
fn decode(data: &[u8]) -> Option<Self>
where Self: Sized { ... }
}Expand description
A key formatting helper trait to be used together with key-value backends for constructing keys.
Required Methods§
Sourcefn encode_atoms(self, atoms: &mut Vec<Vec<u8>>)
fn encode_atoms(self, atoms: &mut Vec<Vec<u8>>)
Encode the given key format into a set of atoms.
Sourcefn decode_atoms(data: &[u8]) -> Selfwhere
Self: Sized,
fn decode_atoms(data: &[u8]) -> Selfwhere
Self: Sized,
Decode the given key format from data (without prefix).
The caller must ensure that the size of the passed data is at
least the minimum size returned by size.
Provided Methods§
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.