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
, ..,u127
const-varint = { version = "0.4", features = "arbitrary-int" }
-
For
ruint::Uint<BITS, LBITS>
support (not compatible inconst
context)const-varint = { version = "0.4", features = ["ruint"] }
-
For
primitive-types
support (not compatible inconst
context)const-varint = { version = "0.4", features = ["primitive-types"] }
-
For
ethereum-types
support (not compatible inconst
context)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
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§
- Char
Buffer - A buffer for storing LEB128 encoded
char
value. - Duration
Buffer - A buffer for storing LEB128 encoded
Duration
value.