Crate varing

Source
Expand description

varing

Protobuf’s varint encoding/decoding for LEB128 friendly types with full const context operations supports.

github LoC Build codecov

docs.rs crates.io crates.io license

§Installation

[dependencies]
varing = "0.5"

§Optional Features

§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_intarbitrary-int
LEB128 encoding/decoding for u1, u2 .. u127
bnumbnum_0_13
LEB128 encoding/decoding for bnum types.
chronochrono_0_4
LEB128 encoding/decoding for chrono types.
chrono_tzchrono-tz_0_10
LEB128 encoding/decoding for chrono-tz types.
ethereum_typesethereum-types_0_15
LEB128 encoding/decoding for ethereum-types types.
num_complexnum-complex_0_4
LEB128 encoding/decoding for num-complex types.
num_rationalnum-rational_0_4
LEB128 encoding/decoding for num-rational types.
primitive_typesprimitive-types_0_13
LEB128 encoding/decoding for primitive-types types.
timetime_0_3
LEB128 encoding/decoding for time types.
utils
Utilities for encoding and decoding LEB128 variable length integers.

Enums§

DecodeError
Decoding varint error.
EncodeError
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 char in LEB128 encoded format from the buffer.
decode_duration
Decodes a Duration in LEB128 encoded format from the buffer.
decode_i8_varint
Decodes an u8 in LEB128 encoded format from the buffer.
decode_i16_varint
Decodes an u16 in LEB128 encoded format from the buffer.
decode_i32_varint
Decodes an u32 in LEB128 encoded format from the buffer.
decode_i64_varint
Decodes an u64 in LEB128 encoded format from the buffer.
decode_i128_varint
Decodes an u128 in LEB128 encoded format from the buffer.
decode_u8_varint
Decodes an i8 in LEB128 encoded format from the buffer.
decode_u16_varint
Decodes an i16 in LEB128 encoded format from the buffer.
decode_u32_varint
Decodes an i32 in LEB128 encoded format from the buffer.
decode_u64_varint
Decodes an i64 in LEB128 encoded format from the buffer.
decode_u128_varint
Decodes an i128 in LEB128 encoded format from the buffer.
encode_char
Encodes a char value into LEB128 variable length format, and writes it to the buffer.
encode_char_to
Encodes a char value into LEB128 variable length format, and writes it to the buffer.
encode_duration
Encodes a Duration value into LEB128 variable length format, and writes it to the buffer.
encode_duration_to
Encodes a Duration value into LEB128 variable length format, and writes it to the buffer.
encode_i8_varint
Encodes an i8 value into LEB128 variable length format, and writes it to the buffer.
encode_i8_varint_to
Encodes an i8 value into LEB128 variable length format, and writes it to the buffer.
encode_i16_varint
Encodes an i16 value into LEB128 variable length format, and writes it to the buffer.
encode_i16_varint_to
Encodes an i16 value into LEB128 variable length format, and writes it to the buffer.
encode_i32_varint
Encodes an i32 value into LEB128 variable length format, and writes it to the buffer.
encode_i32_varint_to
Encodes an i32 value into LEB128 variable length format, and writes it to the buffer.
encode_i64_varint
Encodes an i64 value into LEB128 variable length format, and writes it to the buffer.
encode_i64_varint_to
Encodes an i64 value into LEB128 variable length format, and writes it to the buffer.
encode_i128_varint
Encodes an i128 value into LEB128 variable length format, and writes it to the buffer.
encode_i128_varint_to
Encodes an i128 value into LEB128 variable length format, and writes it to the buffer.
encode_u8_varint
Encodes an u8 value into LEB128 variable length format, and writes it to the buffer.
encode_u8_varint_to
Encodes an u8 value into LEB128 variable length format, and writes it to the buffer.
encode_u16_varint
Encodes an u16 value into LEB128 variable length format, and writes it to the buffer.
encode_u16_varint_to
Encodes an u16 value into LEB128 variable length format, and writes it to the buffer.
encode_u32_varint
Encodes an u32 value into LEB128 variable length format, and writes it to the buffer.
encode_u32_varint_to
Encodes an u32 value into LEB128 variable length format, and writes it to the buffer.
encode_u64_varint
Encodes an u64 value into LEB128 variable length format, and writes it to the buffer.
encode_u64_varint_to
Encodes an u64 value into LEB128 variable length format, and writes it to the buffer.
encode_u128_varint
Encodes an u128 value into LEB128 variable length format, and writes it to the buffer.
encode_u128_varint_to
Encodes an u128 value 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§

CharBuffer
A buffer for storing LEB128 encoded char value.