Skip to content

Commit 78aa2f5

Browse files
Merge branch 'develop' into develop
2 parents c097ed7 + a8b673d commit 78aa2f5

File tree

18 files changed

+967
-17
lines changed

18 files changed

+967
-17
lines changed

Cargo.lock

Lines changed: 493 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ members = [
88
"stdtx",
99
"subtle-encoding",
1010
"tai64",
11+
"vint64",
1112
"zeroize",
1213
"zeroize_derive"
1314
]

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# iqlusion crates <a href="https://www.iqlusion.io"><img src="https://storage.googleapis.com/iqlusion-production-web/img/logo/iqlusion-rings-sm.png" alt="iqlusion" width="24" height="24"></a> <a href="https://crates.io">📦</a>
1+
# iqlusion crates <a href="https://crates.io"><img src="https://storage.googleapis.com/iqlusion-production-web/github/companion-crate.png" alt="crate" width="24" height="24"></a> <a href="https://www.iqlusion.io"><img src="https://storage.googleapis.com/iqlusion-production-web/img/logo/iqlusion-rings-sm.png" alt="iqlusion" width="24" height="24"></a>
22

33
[![Apache 2.0 Licensed][license-image]][license-link]
44
![MSRV][msrv-image]
@@ -45,6 +45,7 @@ This repository contains the following crates:
4545
| [stdtx] | ![][stdtx-crate] | Cosmos StdTx builder/signer/serializer |
4646
| [subtle-encoding] | ![][subtle-encoding-crate] | Hex, Bech32, and Base64 in constant-time(ish) |
4747
| [tai64] | ![][tai64-crate] | TAI64(N) timestamp format |
48+
| [vint64] | ![][vint64-crate] | Simple and efficient 64-bit varint encoding |
4849
| [zeroize] | ![][zeroize-crate] | Securely zero memory |
4950

5051
## License
@@ -97,5 +98,7 @@ without any additional terms or conditions.
9798
[subtle-encoding-crate]: https://img.shields.io/crates/v/subtle-encoding.svg
9899
[tai64]: https://github.com/iqlusioninc/crates/tree/develop/tai64
99100
[tai64-crate]: https://img.shields.io/crates/v/tai64.svg
101+
[vint64]: https://github.com/iqlusioninc/crates/tree/develop/vint64
102+
[vint64-crate]: https://img.shields.io/crates/v/vint64.svg
100103
[zeroize]: https://github.com/iqlusioninc/crates/tree/develop/zeroize
101104
[zeroize-crate]: https://img.shields.io/crates/v/zeroize.svg

anomaly/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ without any additional terms or conditions.
8080
[rustc-image]: https://img.shields.io/badge/rustc-1.36+-blue.svg
8181
[safety-image]: https://img.shields.io/badge/unsafe-forbidden-success.svg
8282
[safety-link]: https://github.com/rust-secure-code/safety-dance/
83-
[build-image]: https://github.com/iqlusioninc/crates/workflows/Rust/badge.svg
83+
[build-image]: https://github.com/iqlusioninc/crates/workflows/Rust/badge.svg?branch=develop&event=push
8484
[build-link]: https://github.com/iqlusioninc/crates/actions
8585
[gitter-image]: https://badges.gitter.im/iqlusioninc/community.svg
8686
[gitter-link]: https://gitter.im/iqlusioninc/community

canonical-path/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ without any additional terms or conditions.
5555
[license-image]: https://img.shields.io/badge/license-Apache2.0-blue.svg
5656
[license-link]: https://github.com/iqlusioninc/crates/blob/develop/LICENSE
5757
[rustc-image]: https://img.shields.io/badge/rustc-1.39+-blue.svg
58-
[build-image]: https://github.com/iqlusioninc/crates/workflows/Rust/badge.svg
58+
[build-image]: https://github.com/iqlusioninc/crates/workflows/Rust/badge.svg?branch=develop&event=push
5959
[build-link]: https://github.com/iqlusioninc/crates/actions
6060
[gitter-image]: https://badges.gitter.im/iqlusioninc/community.svg
6161
[gitter-link]: https://gitter.im/iqlusioninc/community

harp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ without any additional terms or conditions.
5757
[rustc-image]: https://img.shields.io/badge/rustc-1.39+-blue.svg
5858
[safety-image]: https://img.shields.io/badge/unsafe-forbidden-success.svg
5959
[safety-link]: https://github.com/rust-secure-code/safety-dance/
60-
[build-image]: https://github.com/iqlusioninc/crates/workflows/Rust/badge.svg
60+
[build-image]: https://github.com/iqlusioninc/crates/workflows/Rust/badge.svg?branch=develop&event=push
6161
[build-link]: https://github.com/iqlusioninc/crates/actions
6262
[gitter-image]: https://badges.gitter.im/iqlusioninc/community.svg
6363
[gitter-link]: https://gitter.im/iqlusioninc/community

hkd32/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ without any additional terms or conditions.
5353
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
5454
[license-link]: https://github.com/iqlusioninc/crates/blob/develop/LICENSE
5555
[rustc-image]: https://img.shields.io/badge/rustc-1.39+-blue.svg
56-
[build-image]: https://github.com/iqlusioninc/crates/workflows/Rust/badge.svg
56+
[build-image]: hhttps://github.com/iqlusioninc/crates/workflows/Rust/badge.svg?branch=develop&event=push
5757
[build-link]: https://github.com/iqlusioninc/crates/actions
5858
[gitter-image]: https://badges.gitter.im/iqlusioninc/community.svg
5959
[gitter-link]: https://gitter.im/iqlusioninc/community

secrecy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ without any additional terms or conditions.
6464
[rustc-image]: https://img.shields.io/badge/rustc-1.39+-blue.svg
6565
[safety-image]: https://img.shields.io/badge/unsafe-forbidden-success.svg
6666
[safety-link]: https://github.com/rust-secure-code/safety-dance/
67-
[build-image]: https://github.com/iqlusioninc/crates/workflows/Rust/badge.svg
67+
[build-image]: https://github.com/iqlusioninc/crates/workflows/Rust/badge.svg?branch=develop&event=push
6868
[build-link]: https://github.com/iqlusioninc/crates/actions
6969
[gitter-image]: https://badges.gitter.im/iqlusioninc/community.svg
7070
[gitter-link]: https://gitter.im/iqlusioninc/community

stdtx/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ uses the [StdTx] format without requiring upstream modifications.
3131

3232
## License
3333

34-
Copyright © 2020 Tony Arcieri
34+
Copyright © 2020 iqlusion
3535

3636
Licensed under the Apache License, Version 2.0 (the "License");
3737
you may not use this file except in compliance with the License.

subtle-encoding/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ toplevel directory of this repository or [LICENSE-MIT] for details.
5151
[rustc-image]: https://img.shields.io/badge/rustc-1.39+-blue.svg
5252
[safety-image]: https://img.shields.io/badge/unsafe-forbidden-success.svg
5353
[safety-link]: https://github.com/rust-secure-code/safety-dance/
54-
[build-image]: https://github.com/iqlusioninc/crates/workflows/Rust/badge.svg
54+
[build-image]: https://github.com/iqlusioninc/crates/workflows/Rust/badge.svg?branch=develop&event=push
5555
[build-link]: https://github.com/iqlusioninc/crates/actions
5656
[gitter-image]: https://badges.gitter.im/iqlusioninc/community.svg
5757
[gitter-link]: https://gitter.im/iqlusioninc/community

tai64/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ without any additional terms or conditions.
5555
[rustc-image]: https://img.shields.io/badge/rustc-1.39+-blue.svg
5656
[safety-image]: https://img.shields.io/badge/unsafe-forbidden-success.svg
5757
[safety-link]: https://github.com/rust-secure-code/safety-dance/
58-
[build-image]: https://github.com/iqlusioninc/crates/workflows/Rust/badge.svg
58+
[build-image]: https://github.com/iqlusioninc/crates/workflows/Rust/badge.svg?branch=develop&event=push
5959
[build-link]: https://github.com/iqlusioninc/crates/actions
6060
[gitter-image]: https://badges.gitter.im/iqlusioninc/community.svg
6161
[gitter-link]: https://gitter.im/iqlusioninc/community

vint64/CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## 0.1.1 (2020-01-30)
2+
3+
- Documentation fixups
4+
5+
## 0.1.0 (2020-01-30)
6+
7+
- Initial release

vint64/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "vint64"
3+
description = "Simple and efficient variable-length integer encoding"
4+
version = "0.1.1" # Also update html_root_url in lib.rs when bumping this
5+
authors = ["Tony Arcieri <[email protected]>"]
6+
license = "Apache-2.0"
7+
edition = "2018"
8+
homepage = "https://github.com/iqlusioninc/crates/"
9+
repository = "https://github.com/iqlusioninc/crates/tree/develop/vint64"
10+
readme = "README.md"
11+
categories = ["no-std", "parser-implementations"]
12+
keywords = ["encoding", "integer", "leb128", "variable", "varint"]
13+
14+
[dev-dependencies]
15+
criterion = "0.3"
16+
criterion-cycles-per-byte = "0.1"
17+
18+
[[bench]]
19+
name = "vint64"
20+
harness = false

vint64/README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# vint64: simple and efficient variable-length integer encoding
2+
3+
[![Crate][crate-image]][crate-link]
4+
[![Docs][docs-image]][docs-link]
5+
[![Apache 2.0 Licensed][license-image]][license-link]
6+
![MSRV][rustc-image]
7+
[![Safety Dance][safety-image]][safety-link]
8+
[![Build Status][build-image]][build-link]
9+
[![Gitter Chat][gitter-image]][gitter-link]
10+
11+
`vint64` is an implementation of a variable-length encoding for 64-bit
12+
little endian integers which optimizes for simplicity and performance.
13+
14+
[Documentation][docs-link]
15+
16+
## About
17+
18+
This crate implements a variable-length encoding for 64-bit little endian
19+
integers with a number of properties which make it superior in almost every
20+
way to other variable-length integer encodings like [LEB128], SQLite "Varuints",
21+
or CBOR:
22+
23+
- Capable of expressing the full 64-bit integer range with a maximum of 9-bytes
24+
- Provides the most compact encoding possible for every value in range
25+
- No loops involved in decoding: just (unaligned) loads, masks, and shifts
26+
- No complex branch-heavy logic: decoding is CTZ + shifts and sanity checks
27+
- Total length of a `vint64` can be determined via the first byte alone
28+
29+
Some precedent for this sort of encoding can be found in the
30+
[Extensible Binary Meta Language] (used by e.g. the [Matroska]
31+
media container format), however note that the specific type of "vint"
32+
used by that format still requires a loop to decode.
33+
34+
## License
35+
36+
Copyright © 2019-2020 iqlusion
37+
38+
Licensed under the Apache License, Version 2.0 (the "License");
39+
you may not use this file except in compliance with the License.
40+
You may obtain a copy of the License at
41+
42+
https://www.apache.org/licenses/LICENSE-2.0
43+
44+
Unless required by applicable law or agreed to in writing, software
45+
distributed under the License is distributed on an "AS IS" BASIS,
46+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
47+
See the License for the specific language governing permissions and
48+
limitations under the License.
49+
50+
## Contribution
51+
52+
Unless you explicitly state otherwise, any contribution intentionally
53+
submitted for inclusion in the work by you shall be dual licensed as above,
54+
without any additional terms or conditions.
55+
56+
[//]: # (badges)
57+
58+
[crate-image]: https://img.shields.io/crates/v/vint64.svg
59+
[crate-link]: https://crates.io/crates/vint64
60+
[docs-image]: https://docs.rs/vint64/badge.svg
61+
[docs-link]: https://docs.rs/vint64/
62+
[license-image]: https://img.shields.io/badge/license-Apache2.0-blue.svg
63+
[license-link]: https://github.com/iqlusioninc/crates/blob/develop/LICENSE
64+
[rustc-image]: https://img.shields.io/badge/rustc-1.39+-blue.svg
65+
[safety-image]: https://img.shields.io/badge/unsafe-forbidden-success.svg
66+
[safety-link]: https://github.com/rust-secure-code/safety-dance/
67+
[build-image]: https://github.com/iqlusioninc/crates/workflows/Rust/badge.svg?branch=develop&event=push
68+
[build-link]: https://github.com/iqlusioninc/crates/actions
69+
[gitter-image]: https://badges.gitter.im/iqlusioninc/community.svg
70+
[gitter-link]: https://gitter.im/iqlusioninc/community
71+
72+
[//]: # (general links)
73+
74+
[LEB128]: https://cr.yp.to/libtai/vint.html
75+
[Extensible Binary Meta Language]: https://en.wikipedia.org/wiki/Extensible_Binary_Meta_Language
76+
[Matroska]: https://www.matroska.org/

vint64/benches/vint64.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//! vint64 benchmark (using criterion)
2+
3+
use criterion::{criterion_group, criterion_main, Criterion};
4+
use criterion_cycles_per_byte::CyclesPerByte;
5+
6+
const EXAMPLE_VALUES: [u64; 8] = [
7+
0,
8+
0x0f,
9+
0x0f0f,
10+
0x0f0f_f0f0,
11+
0x0f0f_f0f0_0f0f,
12+
0x0f0f_f0f0_0f0f_f0f0,
13+
0xffff_ffff_0f0f_f0f0,
14+
core::u64::MAX,
15+
];
16+
17+
fn bench(c: &mut Criterion<CyclesPerByte>) {
18+
let mut group = c.benchmark_group("vint64");
19+
20+
group.bench_function("encode", |b| {
21+
let mut n = 0;
22+
b.iter(|| {
23+
vint64::encode(EXAMPLE_VALUES[n]);
24+
n = (n + 1) & 0x07;
25+
});
26+
});
27+
28+
group.bench_function("decode", |b| {
29+
let examples = [
30+
vint64::encode(EXAMPLE_VALUES[0]),
31+
vint64::encode(EXAMPLE_VALUES[1]),
32+
vint64::encode(EXAMPLE_VALUES[2]),
33+
vint64::encode(EXAMPLE_VALUES[3]),
34+
vint64::encode(EXAMPLE_VALUES[4]),
35+
vint64::encode(EXAMPLE_VALUES[5]),
36+
vint64::encode(EXAMPLE_VALUES[6]),
37+
vint64::encode(EXAMPLE_VALUES[7]),
38+
];
39+
40+
let mut n = 0;
41+
42+
b.iter(|| {
43+
let mut slice = examples[n].as_ref();
44+
vint64::decode(&mut slice).unwrap();
45+
n = (n + 1) & 0x07;
46+
});
47+
});
48+
49+
group.finish();
50+
}
51+
52+
criterion_group!(
53+
name = benches;
54+
config = Criterion::default().with_measurement(CyclesPerByte);
55+
targets = bench
56+
);
57+
58+
criterion_main!(benches);

0 commit comments

Comments
 (0)