Trait integer_encoding::VarInt [] [src]

pub trait VarInt: Sized + Copy {
    fn required_space(self) -> usize;
fn decode_var(_: &[u8]) -> (Self, usize);
fn encode_var(self, _: &mut [u8]) -> usize; fn decode_var_vec(v: &Vec<u8>) -> (Self, usize) { ... }
fn encode_var_vec(self) -> Vec<u8> { ... } }

Varint (variable length integer) encoding, as described in https://developers.google.com/protocol-buffers/docs/encoding. Uses zigzag encoding (also described there) for signed integer representation.

Required Methods

Returns the number of bytes this number needs in its encoded form.

Decode a value from the slice. Returns the value and the number of bytes read from the slice (can be used to read several consecutive values from a big slice)

Encode a value into the slice.

Provided Methods

Helper: (bit useless) - Decode value from the Vec.

Helper: Encode a value and return the encoded form as Vec.

Implementations on Foreign Types

impl VarInt for usize
[src]

[src]

[src]

[src]

[src]

[src]

impl VarInt for u32
[src]

[src]

[src]

[src]

[src]

[src]

impl VarInt for u16
[src]

[src]

[src]

[src]

[src]

[src]

impl VarInt for u8
[src]

[src]

[src]

[src]

[src]

[src]

impl VarInt for isize
[src]

[src]

[src]

[src]

[src]

[src]

impl VarInt for i32
[src]

[src]

[src]

[src]

[src]

[src]

impl VarInt for i16
[src]

[src]

[src]

[src]

[src]

[src]

impl VarInt for i8
[src]

[src]

[src]

[src]

[src]

[src]

impl VarInt for u64
[src]

[src]

[src]

[src]

[src]

[src]

impl VarInt for i64
[src]

[src]

[src]

[src]

[src]

[src]

Implementors