Expand description
varing
Protobuf’s varint encoding/decoding for LEB128 friendly types with full const context operations supports.
§Installation
[dependencies]
varing = "0.5"§Optional Features
arbitrary-int: Support encode/decodearbitrary-inttypes by using LEB128.bnum: Support encode/decodebnumtypes by using LEB128.chrono: Support encode/decodechronotypes by using LEB128 (not fully compatible inconstcontext).chrono-tz: Support encode/decodechrono-tztypes by using LEB128.ethereum-types: Support encode/decodeethereum-typestypes by using LEB128.num-complex: Support encode/decodenum-complextypes by using LEB128.num-rational: Support encode/decodenum-rationaltypes by using LEB128.primitive-types: Support encode/decodeprimitive-typestypes by using LEB128.ruint: Support encode/decoderuinttypes by using LEB128 (not compatible inconstcontext).time: Support encode/decodetimetypes by using LEB128.
§Testing
This crate is tested with the quickcheck crate and cargo fuzz (including all optional features).
§License
varing is under the terms of both the MIT license and the
Apache License (Version 2.0).
See LICENSE-APACHE, LICENSE-MIT for details.
Copyright (c) 2025 Al Liu.
Modules§
- arbitrary_
int arbitrary-int - LEB128 encoding/decoding for
u1,u2..u127 - bnum
bnum_0_13 - LEB128 encoding/decoding for
bnumtypes. - chrono
chrono_0_4 - LEB128 encoding/decoding for
chronotypes. - chrono_
tz chrono-tz_0_10 - LEB128 encoding/decoding for
chrono-tztypes. - ethereum_
types ethereum-types_0_15 - LEB128 encoding/decoding for
ethereum-typestypes. - num_
complex num-complex_0_4 - LEB128 encoding/decoding for
num-complextypes. - num_
rational num-rational_0_4 - LEB128 encoding/decoding for
num-rationaltypes. - primitive_
types primitive-types_0_13 - LEB128 encoding/decoding for
primitive-typestypes. - time
time_0_3 - LEB128 encoding/decoding for
timetypes. - utils
- Utilities for encoding and decoding LEB128 variable length integers.
Enums§
- Decode
Error - Decoding varint error.
- Encode
Error - Encode varint error
Traits§
- Varint
- A trait for types that can be encoded as variable-length integers (varints).
Functions§
- consume_
varint - Calculates the number of bytes occupied by a varint encoded value in the buffer.
- decode_
char - Decodes a
charin LEB128 encoded format from the buffer. - decode_
duration - Decodes a
Durationin LEB128 encoded format from the buffer. - decode_
i8_ varint - Decodes an
u8in LEB128 encoded format from the buffer. - decode_
i16_ varint - Decodes an
u16in LEB128 encoded format from the buffer. - decode_
i32_ varint - Decodes an
u32in LEB128 encoded format from the buffer. - decode_
i64_ varint - Decodes an
u64in LEB128 encoded format from the buffer. - decode_
i128_ varint - Decodes an
u128in LEB128 encoded format from the buffer. - decode_
u8_ varint - Decodes an
i8in LEB128 encoded format from the buffer. - decode_
u16_ varint - Decodes an
i16in LEB128 encoded format from the buffer. - decode_
u32_ varint - Decodes an
i32in LEB128 encoded format from the buffer. - decode_
u64_ varint - Decodes an
i64in LEB128 encoded format from the buffer. - decode_
u128_ varint - Decodes an
i128in LEB128 encoded format from the buffer. - encode_
char - Encodes a
charvalue into LEB128 variable length format, and writes it to the buffer. - encode_
char_ to - Encodes a
charvalue into LEB128 variable length format, and writes it to the buffer. - encode_
duration - Encodes a
Durationvalue into LEB128 variable length format, and writes it to the buffer. - encode_
duration_ to - Encodes a
Durationvalue into LEB128 variable length format, and writes it to the buffer. - encode_
i8_ varint - Encodes an
i8value into LEB128 variable length format, and writes it to the buffer. - encode_
i8_ varint_ to - Encodes an
i8value into LEB128 variable length format, and writes it to the buffer. - encode_
i16_ varint - Encodes an
i16value into LEB128 variable length format, and writes it to the buffer. - encode_
i16_ varint_ to - Encodes an
i16value into LEB128 variable length format, and writes it to the buffer. - encode_
i32_ varint - Encodes an
i32value into LEB128 variable length format, and writes it to the buffer. - encode_
i32_ varint_ to - Encodes an
i32value into LEB128 variable length format, and writes it to the buffer. - encode_
i64_ varint - Encodes an
i64value into LEB128 variable length format, and writes it to the buffer. - encode_
i64_ varint_ to - Encodes an
i64value into LEB128 variable length format, and writes it to the buffer. - encode_
i128_ varint - Encodes an
i128value into LEB128 variable length format, and writes it to the buffer. - encode_
i128_ varint_ to - Encodes an
i128value into LEB128 variable length format, and writes it to the buffer. - encode_
u8_ varint - Encodes an
u8value into LEB128 variable length format, and writes it to the buffer. - encode_
u8_ varint_ to - Encodes an
u8value into LEB128 variable length format, and writes it to the buffer. - encode_
u16_ varint - Encodes an
u16value into LEB128 variable length format, and writes it to the buffer. - encode_
u16_ varint_ to - Encodes an
u16value into LEB128 variable length format, and writes it to the buffer. - encode_
u32_ varint - Encodes an
u32value into LEB128 variable length format, and writes it to the buffer. - encode_
u32_ varint_ to - Encodes an
u32value into LEB128 variable length format, and writes it to the buffer. - encode_
u64_ varint - Encodes an
u64value into LEB128 variable length format, and writes it to the buffer. - encode_
u64_ varint_ to - Encodes an
u64value into LEB128 variable length format, and writes it to the buffer. - encode_
u128_ varint - Encodes an
u128value into LEB128 variable length format, and writes it to the buffer. - encode_
u128_ varint_ to - Encodes an
u128value into LEB128 variable length format, and writes it to the buffer. - encoded_
char_ len - Returns the encoded length of the value in LEB128 variable length format.
The returned value will be in range
char::ENCODED_LEN_RANGE. - encoded_
duration_ len - Returns the encoded length of the value in LEB128 variable length format.
The returned value will be in range
Duration::ENCODED_LEN_RANGE. - encoded_
i8_ varint_ len - Returns the encoded length of the value in LEB128 variable length format.
The returned value will be in range of
i8::ENCODED_LEN_RANGE. - encoded_
i16_ varint_ len - Returns the encoded length of the value in LEB128 variable length format.
The returned value will be in range of
i16::ENCODED_LEN_RANGE. - encoded_
i32_ varint_ len - Returns the encoded length of the value in LEB128 variable length format.
The returned value will be in range of
i32::ENCODED_LEN_RANGE. - encoded_
i64_ varint_ len - Returns the encoded length of the value in LEB128 variable length format.
The returned value will be in range
i64::ENCODED_LEN_RANGE. - encoded_
i128_ varint_ len - Returns the encoded length of the value in LEB128 variable length format.
The returned value will be in range
i128::ENCODED_LEN_RANGE. - encoded_
u8_ varint_ len - Returns the encoded length of the value in LEB128 variable length format.
The returned value will be in range of
u8::ENCODED_LEN_RANGE. - encoded_
u16_ varint_ len - Returns the encoded length of the value in LEB128 variable length format.
The returned value will be in range of
u16::ENCODED_LEN_RANGE. - encoded_
u32_ varint_ len - Returns the encoded length of the value in LEB128 variable length format.
The returned value will be in range of
u32::ENCODED_LEN_RANGE. - encoded_
u64_ varint_ len - Returns the encoded length of the value in LEB128 variable length format.
The returned value will be in range
u64::ENCODED_LEN_RANGE. - encoded_
u128_ varint_ len - Returns the encoded length of the value in LEB128 variable length format.
The returned value will be in range
u128::ENCODED_LEN_RANGE.
Type Aliases§
- Char
Buffer - A buffer for storing LEB128 encoded
charvalue.