Expand description
§Note: This crate is renamed to varing.
const-varint
Protobuf’s varint encoding/decoding with full const context operations supports. (This project is renamed to varing)
§Installation
[dependencies]
const-varint = "0.4"-
For
u1,u2,u3, ..,u127const-varint = { version = "0.4", features = "arbitrary-int" } -
For
ruint::Uint<BITS, LBITS>support (not compatible inconstcontext)const-varint = { version = "0.4", features = ["ruint"] } -
For
primitive-typessupport (not compatible inconstcontext)const-varint = { version = "0.4", features = ["primitive-types"] } -
For
ethereum-typessupport (not compatible inconstcontext)const-varint = { version = "0.4", features = ["ethereum-types"] }
§License
const-varint 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
Structs§
- I8Varint
Buffer - A buffer for storing LEB128 encoded i8 values.
- I16Varint
Buffer - A buffer for storing LEB128 encoded i16 values.
- I32Varint
Buffer - A buffer for storing LEB128 encoded i32 values.
- I64Varint
Buffer - A buffer for storing LEB128 encoded i64 values.
- I128
Varint Buffer - A buffer for storing LEB128 encoded i128 values.
- U8Varint
Buffer - A buffer for storing LEB128 encoded u8 values.
- U16Varint
Buffer - A buffer for storing LEB128 encoded u16 values.
- U32Varint
Buffer - A buffer for storing LEB128 encoded u32 values.
- U64Varint
Buffer - A buffer for storing LEB128 encoded u64 values.
- U128
Varint Buffer - A buffer for storing LEB128 encoded u128 values.
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. - Duration
Buffer - A buffer for storing LEB128 encoded
Durationvalue.