Trait ordered_varint::Variable
source · pub trait Variable: Sized {
fn encode_variable<W: Write>(&self, destination: W) -> Result<usize>;
fn decode_variable<R: Read>(source: R) -> Result<Self>;
fn to_variable_vec(&self) -> Result<Vec<u8>> { ... }
}
Expand description
Encodes and decodes a type using a variable-length format.
Required Methods§
sourcefn encode_variable<W: Write>(&self, destination: W) -> Result<usize>
fn encode_variable<W: Write>(&self, destination: W) -> Result<usize>
Encodes self
into destination
, returning the number of bytes written upon success.
sourcefn decode_variable<R: Read>(source: R) -> Result<Self>
fn decode_variable<R: Read>(source: R) -> Result<Self>
Decodes a variable length value from source
.
Provided Methods§
sourcefn to_variable_vec(&self) -> Result<Vec<u8>>
fn to_variable_vec(&self) -> Result<Vec<u8>>
Encodes self
into a new Vec<u8>
.