Trait VarInt

Source
pub trait VarInt: Copy + Sized {
    type Unsigned: Copy + VarIntOps;

    // Required methods
    fn to_unsigned(self) -> Self::Unsigned;
    fn from_unsigned(value: Self::Unsigned) -> Self;
    fn varint_size(self) -> usize;
}
Expand description

Generic trait for variable-length integer encoding

Required Associated Types§

Source

type Unsigned: Copy + VarIntOps

The corresponding unsigned type used for internal encoding operations

Required Methods§

Source

fn to_unsigned(self) -> Self::Unsigned

Convert to the corresponding unsigned type

Source

fn from_unsigned(value: Self::Unsigned) -> Self

Convert from the corresponding unsigned type

Source

fn varint_size(self) -> usize

Determine how many bytes are needed to encode this value

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§

type Unsigned = u8

Source§

fn to_unsigned(self) -> Self::Unsigned

Source§

fn from_unsigned(value: Self::Unsigned) -> Self

Source§

fn varint_size(self) -> usize

Source§

impl VarInt for i16

Source§

type Unsigned = u16

Source§

fn to_unsigned(self) -> Self::Unsigned

Source§

fn from_unsigned(value: Self::Unsigned) -> Self

Source§

fn varint_size(self) -> usize

Source§

impl VarInt for i32

Source§

type Unsigned = u32

Source§

fn to_unsigned(self) -> Self::Unsigned

Source§

fn from_unsigned(value: Self::Unsigned) -> Self

Source§

fn varint_size(self) -> usize

Source§

impl VarInt for i64

Source§

type Unsigned = u64

Source§

fn to_unsigned(self) -> Self::Unsigned

Source§

fn from_unsigned(value: Self::Unsigned) -> Self

Source§

fn varint_size(self) -> usize

Source§

impl VarInt for i128

Source§

impl VarInt for u8

Source§

type Unsigned = u8

Source§

fn to_unsigned(self) -> Self::Unsigned

Source§

fn from_unsigned(value: Self::Unsigned) -> Self

Source§

fn varint_size(self) -> usize

Source§

impl VarInt for u16

Source§

type Unsigned = u16

Source§

fn to_unsigned(self) -> Self::Unsigned

Source§

fn from_unsigned(value: Self::Unsigned) -> Self

Source§

fn varint_size(self) -> usize

Source§

impl VarInt for u32

Source§

type Unsigned = u32

Source§

fn to_unsigned(self) -> Self::Unsigned

Source§

fn from_unsigned(value: Self::Unsigned) -> Self

Source§

fn varint_size(self) -> usize

Source§

impl VarInt for u64

Source§

type Unsigned = u64

Source§

fn to_unsigned(self) -> Self::Unsigned

Source§

fn from_unsigned(value: Self::Unsigned) -> Self

Source§

fn varint_size(self) -> usize

Source§

impl VarInt for u128

Implementors§