#integer #vlq #leb128 #encoding #varint #codec #binary-format

no-std vint64

Simple and efficient variable-length integer encoding compatible with some variants of VLQ (Variable-Length Quantity)

8 releases (2 stable)

1.0.1 Mar 31, 2020
1.0.0 Mar 17, 2020
0.3.0 Feb 28, 2020
0.2.1 Feb 25, 2020
0.1.2 Jan 31, 2020

#1207 in Parser implementations

Download history 818/week @ 2024-07-21 770/week @ 2024-07-28 1003/week @ 2024-08-04 1793/week @ 2024-08-11 934/week @ 2024-08-18 1344/week @ 2024-08-25 980/week @ 2024-09-01 997/week @ 2024-09-08 941/week @ 2024-09-15 746/week @ 2024-09-22 857/week @ 2024-09-29 624/week @ 2024-10-06 541/week @ 2024-10-13 518/week @ 2024-10-20 601/week @ 2024-10-27 819/week @ 2024-11-03

2,497 downloads per month
Used in 2 crates

Apache-2.0

18KB
247 lines

vint64 Crate Docs Apache 2.0 Licensed MSRV Safety Dance Build Status

vint64 is an implementation of a variable-length encoding for 64-bit little endian integers which optimizes for simplicity and performance.

Documentation

About

This crate implements a variable-length encoding for 64-bit little endian integers (sometimes also referred to as a variable-length quantity, or "VLQ") with a number of properties which make it superior in almost every way to other variable-length integer encodings like LEB128, SQLite "Varuints", or CBOR:

  • Capable of expressing the full 64-bit integer range with a maximum of 9-bytes
  • Total length of a vint64 can be determined via the first byte alone
  • Provides the most compact encoding possible for every value in range
  • No loops required to encode/decode

Some precedent for this sort of encoding can be found in the Extensible Binary Meta Language (used by e.g. the Matroska media container format), however note that the specific type of "vint" used by that format still requires a loop to decode.

License

Copyright © 2019-2020 Tony Arcieri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

No runtime deps