Expand description
§pw_varint
pw_varint
provides support for encoding and decoding variable length
integers. Small values require less memory than they do with fixed
encoding. Signed integers are first zig-zag encoded to allow small
negative numbers to realize the memory savings. For more information see
Pigweed’s pw_varint documentation.
The encoding format used is compatible with Protocol Buffers.
Encoding and decoding is provided through the VarintEncode and VarintDecode traits.
§Example
use pw_varint::{VarintEncode, VarintDecode};
let mut buffer = [0u8; 64];
let encoded_len = (-1i64).varint_encode(&mut buffer).unwrap();
let (decoded_len, val) = i64::varint_decode(&buffer ).unwrap();
Traits§
- A trait for objects than can be decoded from a varint.
- A trait for objects than can be encoded into a varint.