polars_parquet_format::thrift::varint

Trait VarInt

Source
pub trait VarInt: Sized + Copy {
    // Required methods
    fn required_space(self) -> usize;
    fn decode_var(src: &[u8]) -> Option<(Self, usize)>;
    fn encode_var(self, src: &mut [u8]) -> usize;

    // Provided method
    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§

Source

fn required_space(self) -> usize

Returns the number of bytes this number needs in its encoded form. Note: This varies depending on the actual number you want to encode.

Source

fn decode_var(src: &[u8]) -> Option<(Self, usize)>

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) return None if all bytes has MSB set.

Source

fn encode_var(self, src: &mut [u8]) -> usize

Encode a value into the slice. The slice must be at least required_space() bytes long. The number of bytes taken by the encoded integer is returned.

Provided Methods§

Source

fn encode_var_vec(self) -> Vec<u8>

Helper: Encode a value and return the encoded form as Vec. The Vec must be at least required_space() bytes long.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl VarInt for i8

Source§

fn required_space(self) -> usize

Source§

fn decode_var(src: &[u8]) -> Option<(Self, usize)>

Source§

fn encode_var(self, dst: &mut [u8]) -> usize

Source§

impl VarInt for i16

Source§

fn required_space(self) -> usize

Source§

fn decode_var(src: &[u8]) -> Option<(Self, usize)>

Source§

fn encode_var(self, dst: &mut [u8]) -> usize

Source§

impl VarInt for i32

Source§

fn required_space(self) -> usize

Source§

fn decode_var(src: &[u8]) -> Option<(Self, usize)>

Source§

fn encode_var(self, dst: &mut [u8]) -> usize

Source§

impl VarInt for i64

Source§

fn required_space(self) -> usize

Source§

fn decode_var(src: &[u8]) -> Option<(Self, usize)>

Source§

fn encode_var(self, dst: &mut [u8]) -> usize

Source§

impl VarInt for u8

Source§

fn required_space(self) -> usize

Source§

fn decode_var(src: &[u8]) -> Option<(Self, usize)>

Source§

fn encode_var(self, dst: &mut [u8]) -> usize

Source§

impl VarInt for u16

Source§

fn required_space(self) -> usize

Source§

fn decode_var(src: &[u8]) -> Option<(Self, usize)>

Source§

fn encode_var(self, dst: &mut [u8]) -> usize

Source§

impl VarInt for u32

Source§

fn required_space(self) -> usize

Source§

fn decode_var(src: &[u8]) -> Option<(Self, usize)>

Source§

fn encode_var(self, dst: &mut [u8]) -> usize

Source§

impl VarInt for u64

Source§

fn required_space(self) -> usize

Source§

fn decode_var(src: &[u8]) -> Option<(Self, usize)>

Source§

fn encode_var(self, dst: &mut [u8]) -> usize

Implementors§