VarintEncodingScheme

Trait VarintEncodingScheme 

Source
pub trait VarintEncodingScheme: Sized {
    // Required methods
    fn encode_varint<I: UnsignedInteger>(
        val: I,
        writer: &mut impl Write,
    ) -> Result<usize>;
    fn decode_varint<I: UnsignedInteger>(reader: &mut impl Read) -> Result<I>;
    fn encode_bool(val: bool, writer: &mut impl Write) -> Result<usize>;
    fn decode_bool(reader: &mut impl Read) -> Result<bool>;

    // Provided methods
    fn encode_varint_signed<I: SignedInteger>(
        val: I,
        writer: &mut impl Write,
    ) -> Result<usize> { ... }
    fn decode_varint_signed<I: SignedInteger>(
        reader: &mut impl Read,
    ) -> Result<I> { ... }
}
Expand description

A trait describing a variable‑length integer and boolean encoding scheme.

Required Methods§

Source

fn encode_varint<I: UnsignedInteger>( val: I, writer: &mut impl Write, ) -> Result<usize>

Encodes an unsigned integer value using the scheme, writing to the given Write.

Source

fn decode_varint<I: UnsignedInteger>(reader: &mut impl Read) -> Result<I>

Decodes an unsigned integer value using the scheme, reading from the given Read.

Source

fn encode_bool(val: bool, writer: &mut impl Write) -> Result<usize>

Encodes a boolean value using the scheme, writing to the given Write.

Source

fn decode_bool(reader: &mut impl Read) -> Result<bool>

Decodes a boolean value using the scheme, reading from the given Read.

Provided Methods§

Source

fn encode_varint_signed<I: SignedInteger>( val: I, writer: &mut impl Write, ) -> Result<usize>

Encodes a signed integer value using the scheme, writing to the given Write.

Source

fn decode_varint_signed<I: SignedInteger>(reader: &mut impl Read) -> Result<I>

Decodes a signed integer value using the scheme, reading from the given Read.

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.

Implementors§