Skip to content

Commit bf0b61a

Browse files
committed
Add more types
1 parent 7af9936 commit bf0b61a

10 files changed

Lines changed: 1736 additions & 247 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ documentation = "https://docs.rs/fastvlq"
55
repository = "https://github.com/bbqsrc/fastvlq"
66
version = "2.0.0"
77
authors = ["Brendan Molloy <brendan@bbqsrc.net>"]
8-
categories = ["algorithms", "compression", "encoding", "no-std"]
8+
categories = ["algorithms", "compression", "data-structures", "encoding", "no-std"]
99
edition = "2024"
1010
license = "Apache-2.0 OR MIT"
1111

LICENSE-MIT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019-2020 Brendan Molloy <brendan@bbqsrc.net>
1+
Copyright (c) 2019-2025 Brendan Molloy <brendan@bbqsrc.net>
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,51 @@
33
[![Actions Status](https://github.com/bbqsrc/fastvlq/workflows/CI/badge.svg)](https://github.com/bbqsrc/fastvlq/actions)
44
[![Documentation](https://docs.rs/fastvlq/badge.svg)](https://docs.rs/fastvlq)
55

6-
Encode and decode with a variant of [variable-length quantity](https://en.wikipedia.org/wiki/Variable-length_quantity) data.
6+
A fast variant of [variable-length quantity](https://en.wikipedia.org/wiki/Variable-length_quantity) encoding with a focus on speed and `no_std` support.
77

8-
The algorithm uses leading zeros to count how many bytes are required for decoding.
8+
The algorithm uses leading zeros in the first byte to determine how many bytes are required for decoding, allowing the length to be known immediately without parsing the entire value.
9+
10+
## Supported Types
11+
12+
| Type | Max Bytes |
13+
|------|-----------|
14+
| `Vu32` | 5 |
15+
| `Vi32` | 5 |
16+
| `Vu64` | 9 |
17+
| `Vi64` | 9 |
18+
| `Vu128` | 18 |
19+
| `Vi128` | 18 |
20+
21+
Signed types (`Vi*`) use zigzag encoding for efficient storage of small absolute values.
22+
23+
## Vu64 Compression
24+
25+
| Bytes | Min | Max |
26+
|-------|-----|-----|
27+
| 1 | 0 | 127 (0x7F) |
28+
| 2 | 128 (0x80) | 16,511 (0x407F) |
29+
| 3 | 16,512 (0x4080) | 2,113,663 (0x20407F) |
30+
| 4 | 2,113,664 (0x204080) | 270,549,119 (0x1020407F) |
31+
| 5 | 270,549,120 (0x10204080) | 34,630,287,487 (0x81020407F) |
32+
| 6 | 34,630,287,488 (0x810204080) | 4,432,676,798,591 (0x4081020407F) |
33+
| 7 | 4,432,676,798,592 (0x40810204080) | 567,382,630,219,903 (0x204081020407F) |
34+
| 8 | 567,382,630,219,904 (0x2040810204080) | 72,624,976,668,147,839 (0x10204081020407F) |
35+
| 9 | 72,624,976,668,147,840 (0x102040810204080) | 18,446,744,073,709,551,615 (0xFFFFFFFFFFFFFFFF) |
936

1037
## Usage
1138

1239
Add this to your `Cargo.toml`:
1340

1441
```toml
1542
[dependencies]
16-
fastvlq = "1"
43+
fastvlq = "2"
1744
```
1845

46+
## Features
47+
48+
- `std` (default) - Enables `Read`/`Write` extension traits
49+
- `async` - Enables async `Read`/`Write` extension traits via `futures-io`
50+
1951
## Where is this used?
2052

2153
* [box](https://github.com/bbqsrc/box) - a modern replacement for the zip file format

0 commit comments

Comments
 (0)