Trait integer_encoding::VarInt
source · pub trait VarInt: Sized + Copy {
// Required methods
fn required_space(self) -> usize;
fn decode_var(_: &[u8]) -> Self;
fn encode_var(self, _: &mut [u8]) -> usize;
// Provided methods
fn decode_var_vec(v: &Vec<u8>) -> Self { ... }
fn encode_var_vec(self) -> Vec<u8> { ... }
}
Expand description
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§
sourcefn required_space(self) -> usize
fn required_space(self) -> usize
Returns the number of bytes this number needs in its encoded form.
sourcefn decode_var(_: &[u8]) -> Self
fn decode_var(_: &[u8]) -> Self
Decode a value from the slice.
sourcefn encode_var(self, _: &mut [u8]) -> usize
fn encode_var(self, _: &mut [u8]) -> usize
Encode a value into the slice.
Provided Methods§
sourcefn decode_var_vec(v: &Vec<u8>) -> Self
fn decode_var_vec(v: &Vec<u8>) -> Self
Helper: (bit useless) - Decode value from the Vec.
sourcefn encode_var_vec(self) -> Vec<u8>
fn encode_var_vec(self) -> Vec<u8>
Helper: Encode a value and return the encoded form as Vec.
Object Safety§
This trait is not object safe.