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,

Encodes self into destination, returning the number of bytes written upon success.

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>

Encodes self into a new Vec<u8>.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl Variable for i8

§

fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>
where W: Write,

§

fn decode_variable<R>(source: R) -> Result<i8, Error>
where R: Read,

§

impl Variable for i16

§

fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>
where W: Write,

§

fn decode_variable<R>(source: R) -> Result<i16, Error>
where R: Read,

§

impl Variable for i32

§

fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>
where W: Write,

§

fn decode_variable<R>(source: R) -> Result<i32, Error>
where R: Read,

§

impl Variable for i64

§

fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>
where W: Write,

§

fn decode_variable<R>(source: R) -> Result<i64, Error>
where R: Read,

§

impl Variable for i128

§

fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>
where W: Write,

§

fn decode_variable<R>(source: R) -> Result<i128, Error>
where R: Read,

§

impl Variable for isize

§

fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>
where W: Write,

§

fn decode_variable<R>(source: R) -> Result<isize, Error>
where R: Read,

§

impl Variable for u8

§

fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>
where W: Write,

§

fn decode_variable<R>(source: R) -> Result<u8, Error>
where R: Read,

§

impl Variable for u16

§

fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>
where W: Write,

§

fn decode_variable<R>(source: R) -> Result<u16, Error>
where R: Read,

§

impl Variable for u32

§

fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>
where W: Write,

§

fn decode_variable<R>(source: R) -> Result<u32, Error>
where R: Read,

§

impl Variable for u64

§

fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>
where W: Write,

§

fn decode_variable<R>(source: R) -> Result<u64, Error>
where R: Read,

§

impl Variable for u128

§

fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>
where W: Write,

§

fn decode_variable<R>(source: R) -> Result<u128, Error>
where R: Read,

§

impl Variable for usize

§

fn encode_variable<W>(&self, destination: W) -> Result<usize, Error>
where W: Write,

§

fn decode_variable<R>(source: R) -> Result<usize, Error>
where R: Read,

Implementors§