Trait bonsaidb::core::ordered_varint::Variable
pub trait Variable: Sized {
// Required methods
fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>
where W: Write;
fn decode_variable<R>(source: R) -> Result<Self, Error>
where R: Read;
// Provided method
fn to_variable_vec(&self) -> Result<Vec<u8>, Error> { ... }
}
Expand description
Encodes and decodes a type using a variable-length format.
Required Methods§
fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>where
W: Write,
fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>where
W: Write,
Encodes self
into destination
, returning the number of bytes written upon success.
fn decode_variable<R>(source: R) -> Result<Self, Error>where
R: Read,
fn decode_variable<R>(source: R) -> Result<Self, Error>where
R: Read,
Decodes a variable length value from source
.
Provided Methods§
fn to_variable_vec(&self) -> Result<Vec<u8>, Error>
fn to_variable_vec(&self) -> Result<Vec<u8>, Error>
Encodes self
into a new Vec<u8>
.
Object Safety§
This trait is not object safe.