vu64
The variable length integer encoding of u64. This is a simple and fast encoder/decoder.
Features
- integer value length compaction
- minimum support rustc 1.58.1 (db9d1b20b 2022-01-20)
format pattern
| Prefix | Precision | Total Bytes |
|---|---|---|
0xxxxxxx |
7 bits | 1 byte |
10xxxxxx |
14 bits | 2 bytes |
110xxxxx |
21 bits | 3 bytes |
1110xxxx |
28 bits | 4 bytes |
11110xxx |
35 bits | 5 bytes |
111110xx |
42 bits | 6 bytes |
1111110x |
49 bits | 7 bytes |
11111110 |
56 bits | 8 bytes |
11111111 |
64 bits | 9 bytes |
This format is a like vint64,
but 0x00 is represented by 0x00.
Examples
Encode
use encode;
assert_eq!;
Decode
use decode;
let slice = .as_ref;
assert_eq!;
Encode and decode
use ;
let val = 1234;
assert_eq!;
Read from buffer and decode
use ReadVu64;
let vec: = vec!;
let mut crsr = new;
let r = crsr.read_and_decode_vu64;
assert!;
assert_eq!;
Encode and write to buffer
use WriteVu64;
let vec_0: = vec!;
let vec: = Vecnew;
let mut crsr = new;
let r = crsr.encode_and_write_vu64;
assert!;
assert_eq!;
Changelogs
References
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.