Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move v3-preview to its own branch #120

Merged
merged 2 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 2 additions & 82 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- uses: actions/checkout@v4
- run: rustup install nightly
- run: rustup component add --toolchain=nightly clippy miri rustfmt
- run: cargo +nightly install cargo-audit --locked
- name: cd lib && cargo +nightly fmt -- --check
run: cargo +nightly fmt -- --check
working-directory: lib
Expand Down Expand Up @@ -76,24 +77,6 @@ jobs:
- name: cd lib && cargo +nightly build --release --no-default-features
run: cargo +nightly build --release --no-default-features
working-directory: lib
- name: cd lib && cargo +nightly build --features=v3-preview
run: cargo +nightly build --features=v3-preview
working-directory: lib
- name: cd lib && cargo +nightly build --release --features=v3-preview
run: cargo +nightly build --release --features=v3-preview
working-directory: lib
- name: cd lib && cargo +nightly build --no-default-features --features=alloc --features=v3-preview
run: cargo +nightly build --no-default-features --features=alloc --features=v3-preview
working-directory: lib
- name: cd lib && cargo +nightly build --release --no-default-features --features=alloc --features=v3-preview
run: cargo +nightly build --release --no-default-features --features=alloc --features=v3-preview
working-directory: lib
- name: cd lib && cargo +nightly build --no-default-features --features=v3-preview
run: cargo +nightly build --no-default-features --features=v3-preview
working-directory: lib
- name: cd lib && cargo +nightly build --release --no-default-features --features=v3-preview
run: cargo +nightly build --release --no-default-features --features=v3-preview
working-directory: lib
- name: cd lib/macro/internal && cargo +nightly build
run: cargo +nightly build
working-directory: lib/macro/internal
Expand Down Expand Up @@ -127,9 +110,6 @@ jobs:
- name: cd lib && cargo +nightly test
run: cargo +nightly test
working-directory: lib
- name: cd lib && cargo +nightly test --features=v3-preview
run: cargo +nightly test --features=v3-preview
working-directory: lib
- name: cd lib/macro/internal && cargo +nightly test
run: cargo +nightly test
working-directory: lib/macro/internal
Expand Down Expand Up @@ -160,15 +140,9 @@ jobs:
- name: cd lib && cargo +nightly miri test
run: cargo +nightly miri test
working-directory: lib
- name: cd lib && cargo +nightly miri test --features=v3-preview
run: cargo +nightly miri test --features=v3-preview
working-directory: lib
- name: cd lib && cargo +nightly bench
run: cargo +nightly bench
working-directory: lib
- name: cd lib && cargo +nightly bench --features=v3-preview
run: cargo +nightly bench --features=v3-preview
working-directory: lib
- run: cd bin && ./bench.sh +nightly
- name: cd lib && cargo +nightly audit --deny=warnings
run: cargo +nightly audit --deny=warnings
Expand All @@ -195,7 +169,7 @@ jobs:
run: cargo +nightly audit --deny=warnings
working-directory: www
- run: rustup install stable
- run: cargo +stable install cargo-semver-checks
- run: cargo +stable install cargo-semver-checks --locked
- name: cd lib && cargo +stable build
run: cargo +stable build
working-directory: lib
Expand All @@ -214,24 +188,6 @@ jobs:
- name: cd lib && cargo +stable build --release --no-default-features
run: cargo +stable build --release --no-default-features
working-directory: lib
- name: cd lib && cargo +stable build --features=v3-preview
run: cargo +stable build --features=v3-preview
working-directory: lib
- name: cd lib && cargo +stable build --release --features=v3-preview
run: cargo +stable build --release --features=v3-preview
working-directory: lib
- name: cd lib && cargo +stable build --no-default-features --features=alloc --features=v3-preview
run: cargo +stable build --no-default-features --features=alloc --features=v3-preview
working-directory: lib
- name: cd lib && cargo +stable build --release --no-default-features --features=alloc --features=v3-preview
run: cargo +stable build --release --no-default-features --features=alloc --features=v3-preview
working-directory: lib
- name: cd lib && cargo +stable build --no-default-features --features=v3-preview
run: cargo +stable build --no-default-features --features=v3-preview
working-directory: lib
- name: cd lib && cargo +stable build --release --no-default-features --features=v3-preview
run: cargo +stable build --release --no-default-features --features=v3-preview
working-directory: lib
- name: cd lib/macro/internal && cargo +stable build
run: cargo +stable build
working-directory: lib/macro/internal
Expand Down Expand Up @@ -322,24 +278,6 @@ jobs:
- name: cd lib && cargo +nightly build --release --no-default-features
run: cargo +nightly build --release --no-default-features
working-directory: lib
- name: cd lib && cargo +nightly build --features=v3-preview
run: cargo +nightly build --features=v3-preview
working-directory: lib
- name: cd lib && cargo +nightly build --release --features=v3-preview
run: cargo +nightly build --release --features=v3-preview
working-directory: lib
- name: cd lib && cargo +nightly build --no-default-features --features=alloc --features=v3-preview
run: cargo +nightly build --no-default-features --features=alloc --features=v3-preview
working-directory: lib
- name: cd lib && cargo +nightly build --release --no-default-features --features=alloc --features=v3-preview
run: cargo +nightly build --release --no-default-features --features=alloc --features=v3-preview
working-directory: lib
- name: cd lib && cargo +nightly build --no-default-features --features=v3-preview
run: cargo +nightly build --no-default-features --features=v3-preview
working-directory: lib
- name: cd lib && cargo +nightly build --release --no-default-features --features=v3-preview
run: cargo +nightly build --release --no-default-features --features=v3-preview
working-directory: lib
- name: cd lib/macro/internal && cargo +nightly build
run: cargo +nightly build
working-directory: lib/macro/internal
Expand Down Expand Up @@ -377,24 +315,6 @@ jobs:
- name: cd lib && cargo +stable build --release --no-default-features
run: cargo +stable build --release --no-default-features
working-directory: lib
- name: cd lib && cargo +stable build --features=v3-preview
run: cargo +stable build --features=v3-preview
working-directory: lib
- name: cd lib && cargo +stable build --release --features=v3-preview
run: cargo +stable build --release --features=v3-preview
working-directory: lib
- name: cd lib && cargo +stable build --no-default-features --features=alloc --features=v3-preview
run: cargo +stable build --no-default-features --features=alloc --features=v3-preview
working-directory: lib
- name: cd lib && cargo +stable build --release --no-default-features --features=alloc --features=v3-preview
run: cargo +stable build --release --no-default-features --features=alloc --features=v3-preview
working-directory: lib
- name: cd lib && cargo +stable build --no-default-features --features=v3-preview
run: cargo +stable build --no-default-features --features=v3-preview
working-directory: lib
- name: cd lib && cargo +stable build --release --no-default-features --features=v3-preview
run: cargo +stable build --release --no-default-features --features=v3-preview
working-directory: lib
- name: cd lib/macro/internal && cargo +stable build
run: cargo +stable build
working-directory: lib/macro/internal
Expand Down
2 changes: 1 addition & 1 deletion bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ name = "data-encoding"
path = "src/main.rs"

[dependencies]
data-encoding = { version = "2.6.1-git", path = "../lib" }
data-encoding = { version = "2.7.0-git", path = "../lib" }
getopts = "0.2"
6 changes: 5 additions & 1 deletion lib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## 2.6.1-git
## 2.7.0-git

### Minor

- Add `Encoding::encode_display()` for easier formatting (fixes #118)

### Patch

Expand Down
3 changes: 1 addition & 2 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "data-encoding"
version = "2.6.1-git"
version = "2.7.0-git"
authors = ["Julien Cretin <[email protected]>"]
license = "MIT"
edition = "2018"
Expand All @@ -21,4 +21,3 @@ rustdoc-args = ["--cfg=docsrs"]
default = ["std"]
alloc = []
std = ["alloc"]
v3-preview = []
45 changes: 10 additions & 35 deletions lib/benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@

extern crate test;

#[cfg(feature = "v3-preview")]
use std::convert::TryFrom as _;

#[cfg(not(feature = "v3-preview"))]
use data_encoding as constants;
#[cfg(feature = "v3-preview")]
use data_encoding::v3_preview as constants;
#[cfg(feature = "v3-preview")]
use data_encoding::v3_preview::{Bit1, Bit2, Bit3, Bit6, Encoding, False, True};
use data_encoding::Specification;
use test::Bencher;

Expand All @@ -21,8 +12,6 @@ fn base02_encode_base(b: &mut Bencher) {
let mut spec = Specification::new();
spec.symbols.push_str("01");
let base = spec.encoding().unwrap();
#[cfg(feature = "v3-preview")]
let base = Encoding::<Bit1, True, False, False, False>::try_from(base).unwrap();
b.iter(|| base.encode_mut(input, output));
}

Expand All @@ -33,8 +22,6 @@ fn base02_decode_base(b: &mut Bencher) {
let mut spec = Specification::new();
spec.symbols.push_str("01");
let base = spec.encoding().unwrap();
#[cfg(feature = "v3-preview")]
let base = Encoding::<Bit1, True, False, False, False>::try_from(base).unwrap();
b.iter(|| base.decode_mut(input, output));
}

Expand All @@ -45,8 +32,6 @@ fn base04_encode_base(b: &mut Bencher) {
let mut spec = Specification::new();
spec.symbols.push_str("0123");
let base = spec.encoding().unwrap();
#[cfg(feature = "v3-preview")]
let base = Encoding::<Bit2, True, False, False, False>::try_from(base).unwrap();
b.iter(|| base.encode_mut(input, output));
}

Expand All @@ -57,8 +42,6 @@ fn base04_decode_base(b: &mut Bencher) {
let mut spec = Specification::new();
spec.symbols.push_str("0123");
let base = spec.encoding().unwrap();
#[cfg(feature = "v3-preview")]
let base = Encoding::<Bit2, True, False, False, False>::try_from(base).unwrap();
b.iter(|| base.decode_mut(input, output));
}

Expand All @@ -69,8 +52,6 @@ fn base08_encode_base(b: &mut Bencher) {
let mut spec = Specification::new();
spec.symbols.push_str("01234567");
let base = spec.encoding().unwrap();
#[cfg(feature = "v3-preview")]
let base = Encoding::<Bit3, True, False, False, False>::try_from(base).unwrap();
b.iter(|| base.encode_mut(input, output));
}

Expand All @@ -81,58 +62,56 @@ fn base08_decode_base(b: &mut Bencher) {
let mut spec = Specification::new();
spec.symbols.push_str("01234567");
let base = spec.encoding().unwrap();
#[cfg(feature = "v3-preview")]
let base = Encoding::<Bit3, True, False, False, False>::try_from(base).unwrap();
b.iter(|| base.decode_mut(input, output));
}

#[bench]
fn base16_encode_base(b: &mut Bencher) {
let input = &[0u8; 4096];
let output = &mut [0u8; 8192];
b.iter(|| constants::HEXLOWER.encode_mut(input, output));
b.iter(|| data_encoding::HEXLOWER.encode_mut(input, output));
}

#[bench]
fn base16_decode_base(b: &mut Bencher) {
let input = &[b'0'; 4096];
let output = &mut [0u8; 2048];
b.iter(|| constants::HEXLOWER.decode_mut(input, output));
b.iter(|| data_encoding::HEXLOWER.decode_mut(input, output));
}

#[bench]
fn base32_encode_base(b: &mut Bencher) {
let input = &[0u8; 4096];
let output = &mut [0u8; 6560];
b.iter(|| constants::BASE32.encode_mut(input, output));
b.iter(|| data_encoding::BASE32.encode_mut(input, output));
}

#[bench]
fn base32_decode_base(b: &mut Bencher) {
let input = &[b'A'; 4096];
let output = &mut [0u8; 2560];
b.iter(|| constants::BASE32.decode_mut(input, output));
b.iter(|| data_encoding::BASE32.decode_mut(input, output));
}

#[bench]
fn base64_encode_base(b: &mut Bencher) {
let input = &[0u8; 4096];
let output = &mut [0u8; 5462];
b.iter(|| constants::BASE64_NOPAD.encode_mut(input, output));
b.iter(|| data_encoding::BASE64_NOPAD.encode_mut(input, output));
}

#[bench]
fn base64_decode_base(b: &mut Bencher) {
let input = &[b'A'; 4096];
let output = &mut [0u8; 3072];
b.iter(|| constants::BASE64_NOPAD.decode_mut(input, output));
b.iter(|| data_encoding::BASE64_NOPAD.decode_mut(input, output));
}

#[bench]
fn base64_encode_pad(b: &mut Bencher) {
let input = &mut [b'A'; 4096];
let output = &mut [0u8; 5464];
b.iter(|| constants::BASE64.encode_mut(input, output));
b.iter(|| data_encoding::BASE64.encode_mut(input, output));
}

#[bench]
Expand All @@ -146,7 +125,7 @@ fn base64_decode_pad(b: &mut Bencher) {
}
}
let output = &mut [0u8; 3072];
b.iter(|| constants::BASE64.decode_mut(input, output).unwrap());
b.iter(|| data_encoding::BASE64.decode_mut(input, output).unwrap());
}

#[bench]
Expand All @@ -157,8 +136,6 @@ fn base64_encode_wrap(b: &mut Bencher) {
spec.wrap.width = 76;
spec.wrap.separator.push_str("\r\n");
let base64 = spec.encoding().unwrap();
#[cfg(feature = "v3-preview")]
let base64 = Encoding::<Bit6, True, True, True, True>::try_from(base64).unwrap();
b.iter(|| base64.encode_mut(input, output));
}

Expand All @@ -174,21 +151,19 @@ fn base64_decode_wrap(b: &mut Bencher) {
spec.wrap.width = 76;
spec.wrap.separator.push_str("\r\n");
let base64 = spec.encoding().unwrap();
#[cfg(feature = "v3-preview")]
let base64 = Encoding::<Bit6, True, True, True, True>::try_from(base64).unwrap();
b.iter(|| base64.decode_mut(input, output).unwrap());
}

#[bench]
fn dnscurve_decode_base(b: &mut Bencher) {
let input = &[b'0'; 4096];
let output = &mut [0u8; 2560];
b.iter(|| constants::BASE32_DNSCURVE.decode_mut(input, output));
b.iter(|| data_encoding::BASE32_DNSCURVE.decode_mut(input, output));
}

#[bench]
fn dnscurve_encode_base(b: &mut Bencher) {
let input = &[0u8; 4096];
let output = &mut [0u8; 6554];
b.iter(|| constants::BASE32_DNSCURVE.encode_mut(input, output));
b.iter(|| data_encoding::BASE32_DNSCURVE.encode_mut(input, output));
}
7 changes: 0 additions & 7 deletions lib/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,3 @@ name = "encode_write"
path = "fuzz_targets/encode_write.rs"
test = false
doc = false

[[bin]]
name = "v3-preview"
path = "fuzz_targets/v3-preview.rs"
test = false
doc = false
required-features = ["data-encoding/v3-preview"]
Loading
Loading