Skip to main content

VarIntSupportMut

Trait VarIntSupportMut 

Source
pub trait VarIntSupportMut: BufMut {
    // Provided methods
    fn put_u16_varint(&mut self, value: u16) { ... }
    fn put_u32_varint(&mut self, value: u32) { ... }
    fn put_u64_varint(&mut self, value: u64) { ... }
    fn put_u128_varint(&mut self, value: u128) { ... }
    fn put_usize_varint(&mut self, value: usize) { ... }
    fn put_i16_varint(&mut self, value: i16) { ... }
    fn put_i32_varint(&mut self, value: i32) { ... }
    fn put_i64_varint(&mut self, value: i64) { ... }
    fn put_i128_varint(&mut self, value: i128) { ... }
    fn put_isize_varint(&mut self, value: isize) { ... }
}
Expand description

Functions for writing variable-length encoded integers.

This trait is not meant to be implemented by application code, but is the basis for a blanket implementation for bytes::BufMut.

Importing the trait makes the functions available on any BufMut instance:

use bytes_varint::*;

fn get_number(buf: &mut impl bytes::BufMut, n: u32) {
    buf.put_u32_varint(n);
}

Provided Methods§

Source

fn put_u16_varint(&mut self, value: u16)

Write a u16 to a buffer using variable-length encoding.

Source

fn put_u32_varint(&mut self, value: u32)

Write a u32 to a buffer using variable-length encoding.

Source

fn put_u64_varint(&mut self, value: u64)

Write a u64 to a buffer using variable-length encoding.

Source

fn put_u128_varint(&mut self, value: u128)

Write a u128 to a buffer using variable-length encoding.

Source

fn put_usize_varint(&mut self, value: usize)

Write a usize to a buffer using variable-length encoding. Note that the use of var-length encoding allows using usize for external interfaces without introducing platform dependencies.

Source

fn put_i16_varint(&mut self, value: i16)

Write an i16 to a buffer using variable-length zig-zag encoding.

Source

fn put_i32_varint(&mut self, value: i32)

Write an i32 to a buffer using variable-length zig-zag encoding.

Source

fn put_i64_varint(&mut self, value: i64)

Write an i64 to a buffer using variable-length zig-zag encoding.

Source

fn put_i128_varint(&mut self, value: i128)

Write an i128 to a buffer using variable-length zig-zag encoding.

Source

fn put_isize_varint(&mut self, value: isize)

Write an isize to a buffer using variable-length encoding. Note that the use of var-length encoding allows using usize for external interfaces without introducing platform dependencies.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§