Skip to content

Commit

Permalink
release: 0.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Nov 28, 2024
2 parents f641a25 + 74be1ca commit 829057d
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 55 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@



## [0.5.3](https://github.com/Blobfolio/cdtoc/releases/tag/v0.5.3) - 2024-11-28

### Changed

* Bump `brunch` to `0.7` (dev)
* Bump `dactyl` to `0.8`
* Bump `trimothy` to `0.6`
* Reduce intermediary allocations for AccurateRip::to_string, ::checksum_url
* Miscellaneous code changes and lints



## [0.5.2](https://github.com/Blobfolio/cdtoc/releases/tag/v0.5.2) - 2024-11-07

### Changed
Expand Down
69 changes: 38 additions & 31 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
# Project Dependencies
Package: cdtoc
Version: 0.5.2
Generated: 2024-11-08 06:38:45 UTC
Version: 0.5.3
Generated: 2024-11-28 19:27:46 UTC

| Package | Version | Author(s) | License | Context |
| ---- | ---- | ---- | ---- | ---- |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.4 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL | |
| [faster-hex](https://github.com/NervosFoundation/faster-hex) | 0.10.0 | [zhangsoledad](mailto:[email protected]) | MIT | |
| [trimothy](https://github.com/Blobfolio/trimothy) | 0.3.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL | |
| [block-buffer](https://github.com/RustCrypto/utils) | 0.10.4 | RustCrypto Developers | MIT OR Apache-2.0 | optional |
| [byteorder](https://github.com/BurntSushi/byteorder) | 1.5.0 | [Andrew Gallant](mailto:[email protected]) | Unlicense OR MIT | target-specific |
| [cc](https://github.com/rust-lang/cc-rs) | 1.1.36 | [Alex Crichton](mailto:[email protected]) | MIT OR Apache-2.0 | optional, build, target-specific |
| [cfg-if](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:[email protected]) | MIT OR Apache-2.0 | optional |
| [cpufeatures](https://github.com/RustCrypto/utils) | 0.2.14 | RustCrypto Developers | MIT OR Apache-2.0 | optional, target-specific |
| [crypto-common](https://github.com/RustCrypto/traits) | 0.1.6 | RustCrypto Developers | MIT OR Apache-2.0 | optional |
| [digest](https://github.com/RustCrypto/traits) | 0.10.7 | RustCrypto Developers | MIT OR Apache-2.0 | optional |
| [generic-array](https://github.com/fizyk20/generic-array.git) | 0.14.7 | [Bartłomiej Kamiński](mailto:[email protected]) and [Aaron Trent](mailto:[email protected]) | MIT | optional |
| [hash32](https://github.com/japaric/hash32) | 0.3.1 | [Jorge Aparicio](mailto:[email protected]) | MIT OR Apache-2.0 | target-specific |
| [heapless](https://github.com/rust-embedded/heapless) | 0.8.0 | [Jorge Aparicio](mailto:[email protected]), [Per Lindgren](mailto:[email protected]), and [Emil Fresk](mailto:[email protected]) | MIT OR Apache-2.0 | target-specific |
| [itoa](https://github.com/dtolnay/itoa) | 1.0.11 | [David Tolnay](mailto:[email protected]) | MIT OR Apache-2.0 | optional |
| [libc](https://github.com/rust-lang/libc) | 0.2.162 | The Rust Project Developers | MIT OR Apache-2.0 | optional, target-specific |
| [proc-macro2](https://github.com/dtolnay/proc-macro2) | 1.0.89 | [David Tolnay](mailto:[email protected]) and [Alex Crichton](mailto:[email protected]) | MIT OR Apache-2.0 | optional, build, target-specific |
| [quote](https://github.com/dtolnay/quote) | 1.0.37 | [David Tolnay](mailto:[email protected]) | MIT OR Apache-2.0 | optional, build, target-specific |
| [serde](https://github.com/serde-rs/serde) | 1.0.214 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | MIT OR Apache-2.0 | optional |
| [serde_derive](https://github.com/serde-rs/serde) | 1.0.214 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | MIT OR Apache-2.0 | optional |
| [sha1](https://github.com/RustCrypto/hashes) | 0.10.6 | RustCrypto Developers | MIT OR Apache-2.0 | optional |
| [sha1-asm](https://github.com/RustCrypto/asm-hashes) | 0.5.3 | RustCrypto Developers | MIT | optional, target-specific |
| [shlex](https://github.com/comex/rust-shlex) | 1.3.0 | [comex](mailto:[email protected]), [Fenhl](mailto:[email protected]), [Adrian Taylor](mailto:[email protected]), [Alex Touchet](mailto:[email protected]), [Daniel Parks](mailto:[email protected]), and [Garrett Berg](mailto:[email protected]) | MIT OR Apache-2.0 | optional, build, target-specific |
| [stable_deref_trait](https://github.com/storyyeller/stable_deref_trait) | 1.2.0 | [Robert Grosse](mailto:[email protected]) | MIT OR Apache-2.0 | target-specific |
| [syn](https://github.com/dtolnay/syn) | 2.0.87 | [David Tolnay](mailto:[email protected]) | MIT OR Apache-2.0 | optional, build, target-specific |
| [typenum](https://github.com/paholg/typenum) | 1.17.0 | [Paho Lurie-Gregg](mailto:[email protected]) and [Andre Bogus](mailto:[email protected]) | MIT OR Apache-2.0 | optional |
| [unicode-ident](https://github.com/dtolnay/unicode-ident) | 1.0.13 | [David Tolnay](mailto:[email protected]) | (MIT OR Apache-2.0) AND Unicode-DFS-2016 | optional, build, target-specific |
| [version_check](https://github.com/SergioBenitez/version_check) | 0.9.5 | [Sergio Benitez](mailto:[email protected]) | MIT OR Apache-2.0 | optional, build |
| Package | Version | Author(s) | License |
| ---- | ---- | ---- | ---- |
| [**dactyl**](https://github.com/Blobfolio/dactyl) | 0.8.0 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [**faster-hex**](https://github.com/NervosFoundation/faster-hex) | 0.10.0 | [zhangsoledad](mailto:[email protected]) | MIT |
| [**trimothy**](https://github.com/Blobfolio/trimothy) | 0.6.0 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [_block-buffer_](https://github.com/RustCrypto/utils) | 0.10.4 | RustCrypto Developers | MIT OR Apache-2.0 |
| [_byteorder_](https://github.com/BurntSushi/byteorder) | 1.5.0 | [Andrew Gallant](mailto:[email protected]) | Unlicense OR MIT |
| [_cc_](https://github.com/rust-lang/cc-rs) ⚒️ | 1.2.1 | [Alex Crichton](mailto:[email protected]) | MIT OR Apache-2.0 |
| [_cfg-if_](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:[email protected]) | MIT OR Apache-2.0 |
| [_cpufeatures_](https://github.com/RustCrypto/utils) | 0.2.16 | RustCrypto Developers | MIT OR Apache-2.0 |
| [_crypto-common_](https://github.com/RustCrypto/traits) | 0.1.6 | RustCrypto Developers | MIT OR Apache-2.0 |
| [_digest_](https://github.com/RustCrypto/traits) | 0.10.7 | RustCrypto Developers | MIT OR Apache-2.0 |
| [_generic-array_](https://github.com/fizyk20/generic-array.git) | 0.14.7 | [Bartłomiej Kamiński](mailto:[email protected]) and [Aaron Trent](mailto:[email protected]) | MIT |
| [_hash32_](https://github.com/japaric/hash32) | 0.3.1 | [Jorge Aparicio](mailto:[email protected]) | MIT OR Apache-2.0 |
| [_heapless_](https://github.com/rust-embedded/heapless) | 0.8.0 | [Jorge Aparicio](mailto:[email protected]), [Per Lindgren](mailto:[email protected]), and [Emil Fresk](mailto:[email protected]) | MIT OR Apache-2.0 |
| [**_itoa_**](https://github.com/dtolnay/itoa) | 1.0.14 | [David Tolnay](mailto:[email protected]) | MIT OR Apache-2.0 |
| [_libc_](https://github.com/rust-lang/libc) | 0.2.166 | The Rust Project Developers | MIT OR Apache-2.0 |
| [_proc-macro2_](https://github.com/dtolnay/proc-macro2) ⚒️ | 1.0.92 | [David Tolnay](mailto:[email protected]) and [Alex Crichton](mailto:[email protected]) | MIT OR Apache-2.0 |
| [_quote_](https://github.com/dtolnay/quote) ⚒️ | 1.0.37 | [David Tolnay](mailto:[email protected]) | MIT OR Apache-2.0 |
| [**_serde_**](https://github.com/serde-rs/serde) | 1.0.215 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | MIT OR Apache-2.0 |
| [_serde_derive_](https://github.com/serde-rs/serde) | 1.0.215 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | MIT OR Apache-2.0 |
| [**_sha1_**](https://github.com/RustCrypto/hashes) | 0.10.6 | RustCrypto Developers | MIT OR Apache-2.0 |
| [_sha1-asm_](https://github.com/RustCrypto/asm-hashes) | 0.5.3 | RustCrypto Developers | MIT |
| [_shlex_](https://github.com/comex/rust-shlex) ⚒️ | 1.3.0 | [comex](mailto:[email protected]), [Fenhl](mailto:[email protected]), [Adrian Taylor](mailto:[email protected]), [Alex Touchet](mailto:[email protected]), [Daniel Parks](mailto:dp+[email protected]), and [Garrett Berg](mailto:[email protected]) | MIT OR Apache-2.0 |
| [_stable_deref_trait_](https://github.com/storyyeller/stable_deref_trait) | 1.2.0 | [Robert Grosse](mailto:[email protected]) | MIT OR Apache-2.0 |
| [_syn_](https://github.com/dtolnay/syn) ⚒️ | 2.0.89 | [David Tolnay](mailto:[email protected]) | MIT OR Apache-2.0 |
| [_typenum_](https://github.com/paholg/typenum) | 1.17.0 | [Paho Lurie-Gregg](mailto:[email protected]) and [Andre Bogus](mailto:[email protected]) | MIT OR Apache-2.0 |
| [_unicode-ident_](https://github.com/dtolnay/unicode-ident) ⚒️ | 1.0.14 | [David Tolnay](mailto:[email protected]) | (MIT OR Apache-2.0) AND Unicode-3.0 |
| [_version_check_](https://github.com/SergioBenitez/version_check) ⚒️ | 0.9.5 | [Sergio Benitez](mailto:[email protected]) | MIT OR Apache-2.0 |

### Legend

* **Direct Dependency**
* Child Dependency
* _Optional Dependency_
* ⚒️ Build-Only
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cdtoc"
version = "0.5.2"
version = "0.5.3"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
rust-version = "1.81"
Expand All @@ -27,12 +27,12 @@ features = [ "accuraterip", "cddb", "ctdb", "musicbrainz", "serde" ]
default-target = "x86_64-unknown-linux-gnu"

[dev-dependencies]
brunch = "0.6.*"
brunch = "0.7.*"
serde_json = "1.0.*"

[dependencies]
dactyl = "0.7.*"
trimothy = "0.3.*"
dactyl = "0.8.*"
trimothy = "0.6.*"

[dependencies.faster-hex]
version = "0.10.*"
Expand Down
63 changes: 48 additions & 15 deletions src/accuraterip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ impl From<AccurateRip> for [u8; 13] {
}

impl fmt::Display for AccurateRip {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad(&self.pretty_print())
let disc_id = self.encode();
std::str::from_utf8(disc_id.as_slice())
.map_err(|_| fmt::Error)
.and_then(|s| f.pad(s))
}
}

Expand Down Expand Up @@ -158,6 +160,7 @@ impl AccurateRip {
/// ```
pub const fn audio_len(&self) -> u8 { self.0[0] }

#[expect(unsafe_code, reason = "For performance.")]
#[must_use]
/// # AccurateRip Checksum URL.
///
Expand All @@ -180,18 +183,22 @@ impl AccurateRip {
/// );
/// ```
pub fn checksum_url(&self) -> String {
let disc_id = self.to_string();
[
"http://www.accuraterip.com/accuraterip/",
&disc_id[11..12],
"/",
&disc_id[10..11],
"/",
&disc_id[9..10],
"/dBAR-",
&disc_id,
".bin",
].concat()
// First things first, build the disc ID.
let disc_id = self.encode();
debug_assert!(disc_id.is_ascii(), "Bug: AccurateRip ID is not ASCII?!");

let mut out = String::with_capacity(84);
out.push_str("http://www.accuraterip.com/accuraterip/");
out.push(char::from(disc_id[11]));
out.push('/');
out.push(char::from(disc_id[10]));
out.push('/');
out.push(char::from(disc_id[9]));
out.push_str("/dBAR-");
// Safety: all bytes are ASCII.
out.push_str(unsafe { std::str::from_utf8_unchecked(disc_id.as_slice()) });
out.push_str(".bin");
out
}

#[must_use]
Expand Down Expand Up @@ -436,13 +443,39 @@ impl AccurateRip {
faster_hex::hex_encode_fallback(&[self.0[8], self.0[7], self.0[6], self.0[5]], &mut out[13..21]);
faster_hex::hex_encode_fallback(&[self.0[12], self.0[11], self.0[10], self.0[9]], &mut out[22..]);

debug_assert!(out.is_ascii(), "Bug: AccurateRip checksum is not ASCII?!");
debug_assert!(out.is_ascii(), "Bug: AccurateRip ID is not ASCII?!");

// Safety: all bytes are ASCII.
unsafe { String::from_utf8_unchecked(out) }
}
}

impl AccurateRip {
#[inline]
/// # Encode to Buffer.
///
/// Format the AccurateRip ID for display, returning the bytes as a
/// fixed-length array.
fn encode(&self) -> [u8; 30] {
let mut disc_id: [u8; 30] = [
b'0', b'0', b'0',
b'-', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0',
b'-', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0',
b'-', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0',
];

// Length.
disc_id[..3].copy_from_slice(dactyl::NiceU8::from(self.0[0]).as_bytes3());

// ID Parts.
faster_hex::hex_encode_fallback(&[self.0[4], self.0[3], self.0[2], self.0[1]], &mut disc_id[4..12]);
faster_hex::hex_encode_fallback(&[self.0[8], self.0[7], self.0[6], self.0[5]], &mut disc_id[13..21]);
faster_hex::hex_encode_fallback(&[self.0[12], self.0[11], self.0[10], self.0[9]], &mut disc_id[22..]);

disc_id
}
}



impl Toc {
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ impl fmt::Display for Toc {
($v:expr) => (
faster_hex::hex_encode_fallback($v.to_be_bytes().as_slice(), &mut buf);
out.push(b'+');
out.extend_from_slice(buf.trim_start_matches(|b| b == b'0'));
out.extend_from_slice(buf.trim_start_matches(b'0'));
);
}

Expand All @@ -267,7 +267,7 @@ impl fmt::Display for Toc {
faster_hex::hex_encode_fallback(self.data.to_be_bytes().as_slice(), &mut buf);
out.push(b'+');
out.push(b'X');
out.extend_from_slice(buf.trim_start_matches(|b| b == b'0'));
out.extend_from_slice(buf.trim_start_matches(b'0'));
},
}

Expand Down
2 changes: 1 addition & 1 deletion src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<'de> Deserialize<'de> for TrackPosition {
/// # Visitor Instance.
struct Visitor;

impl<'de> de::Visitor<'de> for Visitor {
impl de::Visitor<'_> for Visitor {
type Value = TrackPosition;

fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
8 changes: 6 additions & 2 deletions src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,18 @@ impl Duration {
pub fn to_string_pretty(self) -> String {
let (d, h, m, s, f) = self.dhmsf();
let mut parts: Vec<String> = Vec::new();
if d != 0 { parts.push(d.nice_inflect("day", "days")); }

// Days work the same way as the other parts, but have a different
// integer type.
if d != 0 { parts.push(d.nice_inflect("day", "days").to_string()); }

for (num, single, plural) in [
(h, "hour", "hours"),
(m, "minute", "minutes"),
(s, "second", "seconds"),
(f, "frame", "frames"),
] {
if num != 0 { parts.push(num.nice_inflect(single, plural)); }
if num != 0 { parts.push(num.nice_inflect(single, plural).to_string()); }
}

match parts.len() {
Expand Down

0 comments on commit 829057d

Please sign in to comment.