Skip to content

Commit f641a25

Browse files
committed
release: 0.5.2
2 parents 2d83eeb + 8022125 commit f641a25

14 files changed

+109
-75
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33

44

5+
## [0.5.2](https://github.com/Blobfolio/cdtoc/releases/tag/v0.5.2) - 2024-11-07
6+
7+
### Changed
8+
9+
* Add (more) inline hints
10+
* Add `Formatter` width/fill/align/etc. support for `AccurateRip`, `Cddb`, `ShaB64`
11+
* Improve docs, test coverage
12+
13+
14+
515
## [0.5.1](https://github.com/Blobfolio/cdtoc/releases/tag/v0.5.1) - 2024-10-10
616

717
### Changed

CREDITS.md

+31-16
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
11
# Project Dependencies
22
Package: cdtoc
3-
Version: 0.5.1
4-
Generated: 2024-10-11 03:12:14 UTC
3+
Version: 0.5.2
4+
Generated: 2024-11-08 06:38:45 UTC
55

6-
| Package | Version | Author(s) | License |
7-
| ---- | ---- | ---- | ---- |
8-
| [block-buffer](https://github.com/RustCrypto/utils) | 0.10.4 | RustCrypto Developers | Apache-2.0 or MIT |
9-
| [cfg-if](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:alex@alexcrichton.com) | Apache-2.0 or MIT |
10-
| [crypto-common](https://github.com/RustCrypto/traits) | 0.1.6 | RustCrypto Developers | Apache-2.0 or MIT |
11-
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.4 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
12-
| [digest](https://github.com/RustCrypto/traits) | 0.10.7 | RustCrypto Developers | Apache-2.0 or MIT |
13-
| [faster-hex](https://github.com/NervosFoundation/faster-hex) | 0.10.0 | [zhangsoledad](mailto:787953403@qq.com) | MIT |
14-
| [generic-array](https://github.com/fizyk20/generic-array.git) | 0.14.7 | [Bartłomiej Kamiński](mailto:fizyk20@gmail.com) and [Aaron Trent](mailto:novacrazy@gmail.com) | MIT |
15-
| [itoa](https://github.com/dtolnay/itoa) | 1.0.11 | [David Tolnay](mailto:dtolnay@gmail.com) | Apache-2.0 or MIT |
16-
| [serde](https://github.com/serde-rs/serde) | 1.0.210 | [Erick Tryzelaar](mailto:erick.tryzelaar@gmail.com) and [David Tolnay](mailto:dtolnay@gmail.com) | Apache-2.0 or MIT |
17-
| [sha1](https://github.com/RustCrypto/hashes) | 0.10.6 | RustCrypto Developers | Apache-2.0 or MIT |
18-
| [trimothy](https://github.com/Blobfolio/trimothy) | 0.3.1 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
19-
| [typenum](https://github.com/paholg/typenum) | 1.17.0 | [Paho Lurie-Gregg](mailto:paho@paholg.com) and [Andre Bogus](mailto:bogusandre@gmail.com) | Apache-2.0 or MIT |
6+
| Package | Version | Author(s) | License | Context |
7+
| ---- | ---- | ---- | ---- | ---- |
8+
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.4 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL | |
9+
| [faster-hex](https://github.com/NervosFoundation/faster-hex) | 0.10.0 | [zhangsoledad](mailto:787953403@qq.com) | MIT | |
10+
| [trimothy](https://github.com/Blobfolio/trimothy) | 0.3.1 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL | |
11+
| [block-buffer](https://github.com/RustCrypto/utils) | 0.10.4 | RustCrypto Developers | MIT OR Apache-2.0 | optional |
12+
| [byteorder](https://github.com/BurntSushi/byteorder) | 1.5.0 | [Andrew Gallant](mailto:jamslam@gmail.com) | Unlicense OR MIT | target-specific |
13+
| [cc](https://github.com/rust-lang/cc-rs) | 1.1.36 | [Alex Crichton](mailto:alex@alexcrichton.com) | MIT OR Apache-2.0 | optional, build, target-specific |
14+
| [cfg-if](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:alex@alexcrichton.com) | MIT OR Apache-2.0 | optional |
15+
| [cpufeatures](https://github.com/RustCrypto/utils) | 0.2.14 | RustCrypto Developers | MIT OR Apache-2.0 | optional, target-specific |
16+
| [crypto-common](https://github.com/RustCrypto/traits) | 0.1.6 | RustCrypto Developers | MIT OR Apache-2.0 | optional |
17+
| [digest](https://github.com/RustCrypto/traits) | 0.10.7 | RustCrypto Developers | MIT OR Apache-2.0 | optional |
18+
| [generic-array](https://github.com/fizyk20/generic-array.git) | 0.14.7 | [Bartłomiej Kamiński](mailto:fizyk20@gmail.com) and [Aaron Trent](mailto:novacrazy@gmail.com) | MIT | optional |
19+
| [hash32](https://github.com/japaric/hash32) | 0.3.1 | [Jorge Aparicio](mailto:jorge@japaric.io) | MIT OR Apache-2.0 | target-specific |
20+
| [heapless](https://github.com/rust-embedded/heapless) | 0.8.0 | [Jorge Aparicio](mailto:jorge@japaric.io), [Per Lindgren](mailto:per.lindgren@ltu.se), and [Emil Fresk](mailto:emil.fresk@gmail.com) | MIT OR Apache-2.0 | target-specific |
21+
| [itoa](https://github.com/dtolnay/itoa) | 1.0.11 | [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 | optional |
22+
| [libc](https://github.com/rust-lang/libc) | 0.2.162 | The Rust Project Developers | MIT OR Apache-2.0 | optional, target-specific |
23+
| [proc-macro2](https://github.com/dtolnay/proc-macro2) | 1.0.89 | [David Tolnay](mailto:dtolnay@gmail.com) and [Alex Crichton](mailto:alex@alexcrichton.com) | MIT OR Apache-2.0 | optional, build, target-specific |
24+
| [quote](https://github.com/dtolnay/quote) | 1.0.37 | [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 | optional, build, target-specific |
25+
| [serde](https://github.com/serde-rs/serde) | 1.0.214 | [Erick Tryzelaar](mailto:erick.tryzelaar@gmail.com) and [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 | optional |
26+
| [serde_derive](https://github.com/serde-rs/serde) | 1.0.214 | [Erick Tryzelaar](mailto:erick.tryzelaar@gmail.com) and [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 | optional |
27+
| [sha1](https://github.com/RustCrypto/hashes) | 0.10.6 | RustCrypto Developers | MIT OR Apache-2.0 | optional |
28+
| [sha1-asm](https://github.com/RustCrypto/asm-hashes) | 0.5.3 | RustCrypto Developers | MIT | optional, target-specific |
29+
| [shlex](https://github.com/comex/rust-shlex) | 1.3.0 | [comex](mailto:comexk@gmail.com), [Fenhl](mailto:fenhl@fenhl.net), [Adrian Taylor](mailto:adetaylor@chromium.org), [Alex Touchet](mailto:alextouchet@outlook.com), [Daniel Parks](mailto:dp+git@oxidized.org), and [Garrett Berg](mailto:googberg@gmail.com) | MIT OR Apache-2.0 | optional, build, target-specific |
30+
| [stable_deref_trait](https://github.com/storyyeller/stable_deref_trait) | 1.2.0 | [Robert Grosse](mailto:n210241048576@gmail.com) | MIT OR Apache-2.0 | target-specific |
31+
| [syn](https://github.com/dtolnay/syn) | 2.0.87 | [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 | optional, build, target-specific |
32+
| [typenum](https://github.com/paholg/typenum) | 1.17.0 | [Paho Lurie-Gregg](mailto:paho@paholg.com) and [Andre Bogus](mailto:bogusandre@gmail.com) | MIT OR Apache-2.0 | optional |
33+
| [unicode-ident](https://github.com/dtolnay/unicode-ident) | 1.0.13 | [David Tolnay](mailto:dtolnay@gmail.com) | (MIT OR Apache-2.0) AND Unicode-DFS-2016 | optional, build, target-specific |
34+
| [version_check](https://github.com/SergioBenitez/version_check) | 0.9.5 | [Sergio Benitez](mailto:sb@sergio.bz) | MIT OR Apache-2.0 | optional, build |

Cargo.toml

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "cdtoc"
3-
version = "0.5.1"
4-
authors = ["Blobfolio, LLC. <hello@blobfolio.com>"]
3+
version = "0.5.2"
4+
authors = ["Josh Stoik <josh@blobfolio.com>"]
55
edition = "2021"
66
rust-version = "1.81"
77
description = "Parser and tools for CDTOC metadata tags."
@@ -19,9 +19,6 @@ exclude = [
1919

2020
[package.metadata.bashman]
2121
name = "CDTOC"
22-
bash-dir = "./"
23-
man-dir = "./"
24-
credits-dir = "./"
2522

2623
[package.metadata.docs.rs]
2724
rustc-args = ["--cfg", "docsrs"]

README.md

-22
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,3 @@ The disc ID helpers require additional dependencies, so if you aren't using them
7272
version = "0.5.*"
7373
default-features = false
7474
```
75-
76-
77-
78-
## License
79-
80-
Copyright © 2024 [Blobfolio, LLC](https://blobfolio.com) &lt;hello@blobfolio.com&gt;
81-
82-
This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2.
83-
84-
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
85-
Version 2, December 2004
86-
87-
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
88-
89-
Everyone is permitted to copy and distribute verbatim or modified
90-
copies of this license document, and changing it is allowed as long
91-
as the name is changed.
92-
93-
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
94-
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
95-
96-
0. You just DO WHAT THE FUCK YOU WANT TO.

src/accuraterip.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,19 @@ const DRIVE_OFFSET_OFFSET_RNG: Range<i16> = -2940..2941;
7070
pub struct AccurateRip([u8; 13]);
7171

7272
impl AsRef<[u8]> for AccurateRip {
73+
#[inline]
7374
fn as_ref(&self) -> &[u8] { &self.0 }
7475
}
7576

7677
impl From<AccurateRip> for [u8; 13] {
78+
#[inline]
7779
fn from(src: AccurateRip) -> Self { src.0 }
7880
}
7981

8082
impl fmt::Display for AccurateRip {
83+
#[inline]
8184
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
82-
f.write_str(&self.pretty_print())
85+
f.pad(&self.pretty_print())
8386
}
8487
}
8588

@@ -412,6 +415,10 @@ impl AccurateRip {
412415
/// toc.accuraterip_id().pretty_print(),
413416
/// "013-0015deca-00d9b921-9a0a6e0d",
414417
/// );
418+
/// assert_eq!(
419+
/// toc.accuraterip_id().to_string(),
420+
/// "013-0015deca-00d9b921-9a0a6e0d",
421+
/// );
415422
/// ```
416423
pub fn pretty_print(&self) -> String {
417424
let mut out: Vec<u8> = vec![
@@ -545,6 +552,7 @@ mod tests {
545552
let toc = Toc::from_cdtoc(t).expect("Invalid TOC");
546553
let ar_id = toc.accuraterip_id();
547554
assert_eq!(ar_id.to_string(), id);
555+
assert_eq!(ar_id.pretty_print(), id);
548556

549557
// Test decoding three ways.
550558
assert_eq!(AccurateRip::decode(id), Ok(ar_id));

src/cddb.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl fmt::Display for Cddb {
5353
faster_hex::hex_encode_fallback(self.0.to_be_bytes().as_slice(), &mut buf);
5454
std::str::from_utf8(buf.as_slice())
5555
.map_err(|_| fmt::Error)
56-
.and_then(|s| f.write_str(s))
56+
.and_then(|s| f.pad(s))
5757
}
5858
}
5959

@@ -64,10 +64,12 @@ impl FromStr for Cddb {
6464
}
6565

6666
impl hash::Hash for Cddb {
67+
#[inline]
6768
fn hash<H: hash::Hasher>(&self, state: &mut H) { state.write_u32(self.0); }
6869
}
6970

7071
impl PartialEq for Cddb {
72+
#[inline]
7173
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
7274
}
7375

src/ctdb.rs

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ mod tests {
260260
let toc = Toc::from_cdtoc(t).expect("Invalid TOC");
261261
let ctdb_id = toc.ctdb_id();
262262
assert_eq!(ctdb_id.to_string(), id);
263+
assert_eq!(ctdb_id.pretty_print(), id);
263264
assert_eq!(toc.ctdb_checksum_url(), lookup);
264265

265266
// Test decoding three ways.

src/error.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -101,26 +101,26 @@ pub enum TocError {
101101

102102
impl fmt::Display for TocError {
103103
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
104-
match self {
105-
Self::CDDASampleCount => f.write_str("Invalid CDDA sample count."),
106-
Self::CDTOCChars => f.write_str("Invalid character(s), expecting only 0-9, A-F, +, and (rarely) X."),
107-
Self::Checksums => f.write_str("Unable to parse checksums."),
108-
Self::Format(kind) => write!(f, "This operation can't be applied to {kind} discs."),
109-
Self::LeadinSize => f.write_str("Leadin must be at least 150."),
110-
Self::NoAudio => f.write_str("At least one audio track is required."),
111-
Self::NoChecksums => f.write_str("No checksums were present."),
112-
Self::SectorCount(expected, found) => write!(f, "Expected {expected} audio sectors, found {found}."),
113-
Self::SectorOrder => f.write_str("Sectors are incorrectly ordered or overlap."),
114-
Self::SectorSize => f.write_str("Sector sizes may not exceed four bytes (u32)."),
115-
Self::TrackCount => f.write_str("The number of audio tracks must be between 1..=99."),
116-
117-
#[cfg(feature = "accuraterip")] Self::AccurateRipDecode => f.write_str("Invalid AccurateRip ID string."),
118-
#[cfg(feature = "accuraterip")] Self::DriveOffsetDecode => f.write_str("Unable to parse drive offsets."),
119-
#[cfg(feature = "accuraterip")] Self::NoDriveOffsets => f.write_str("No drive offsets were found."),
120-
121-
#[cfg(feature = "cddb")] Self::CddbDecode => f.write_str("Invalid CDDB ID string."),
122-
#[cfg(feature = "sha1")] Self::ShaB64Decode => f.write_str("Invalid sha/base64 ID string."),
123-
}
104+
f.write_str(match self {
105+
Self::CDDASampleCount => "Invalid CDDA sample count.",
106+
Self::CDTOCChars => "Invalid character(s), expecting only 0-9, A-F, +, and (rarely) X.",
107+
Self::Checksums => "Unable to parse checksums.",
108+
Self::Format(kind) => return write!(f, "This operation can't be applied to {kind} discs."),
109+
Self::LeadinSize => "Leadin must be at least 150.",
110+
Self::NoAudio => "At least one audio track is required.",
111+
Self::NoChecksums => "No checksums were present.",
112+
Self::SectorCount(expected, found) => return write!(f, "Expected {expected} audio sectors, found {found}."),
113+
Self::SectorOrder => "Sectors are incorrectly ordered or overlap.",
114+
Self::SectorSize => "Sector sizes may not exceed four bytes (u32).",
115+
Self::TrackCount => "The number of audio tracks must be between 1..=99.",
116+
117+
#[cfg(feature = "accuraterip")] Self::AccurateRipDecode => "Invalid AccurateRip ID string.",
118+
#[cfg(feature = "accuraterip")] Self::DriveOffsetDecode => "Unable to parse drive offsets.",
119+
#[cfg(feature = "accuraterip")] Self::NoDriveOffsets => "No drive offsets were found.",
120+
121+
#[cfg(feature = "cddb")] Self::CddbDecode => "Invalid CDDB ID string.",
122+
#[cfg(feature = "sha1")] Self::ShaB64Decode => "Invalid sha/base64 ID string.",
123+
})
124124
}
125125
}
126126

src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -979,9 +979,8 @@ pub enum TocKind {
979979
}
980980

981981
impl fmt::Display for TocKind {
982-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
983-
f.write_str(self.as_str())
984-
}
982+
#[inline]
983+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad(self.as_str()) }
985984
}
986985

987986
impl TocKind {

src/musicbrainz.rs

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ impl Toc {
3737
/// toc.musicbrainz_id().to_string(),
3838
/// "nljDXdC8B_pDwbdY1vZJvdrAZI4-",
3939
/// );
40+
/// assert_eq!(
41+
/// toc.musicbrainz_id().pretty_print(),
42+
/// "nljDXdC8B_pDwbdY1vZJvdrAZI4-",
43+
/// );
4044
/// ```
4145
pub fn musicbrainz_id(&self) -> ShaB64 {
4246
use sha1::Digest;
@@ -133,6 +137,7 @@ mod tests {
133137
let toc = Toc::from_cdtoc(t).expect("Invalid TOC");
134138
let mb_id = toc.musicbrainz_id();
135139
assert_eq!(mb_id.to_string(), id);
140+
assert_eq!(mb_id.pretty_print(), id);
136141

137142
// Test decoding three ways.
138143
assert_eq!(ShaB64::decode(id), Ok(mb_id));

src/serde.rs

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ macro_rules! serialize_with {
6464
($ty:ty, $fn:ident) => (
6565
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
6666
impl Serialize for $ty {
67+
#[inline]
6768
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
6869
where S: ser::Serializer { self.$fn().serialize(serializer) }
6970
}
@@ -86,6 +87,7 @@ serialize_with!(Toc, to_string);
8687

8788
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
8889
impl<'de> Deserialize<'de> for Duration {
90+
#[inline]
8991
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
9092
where D: de::Deserializer<'de> {
9193
u64::deserialize(deserializer).map(Self::from)
@@ -94,6 +96,7 @@ impl<'de> Deserialize<'de> for Duration {
9496

9597
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
9698
impl Serialize for Duration {
99+
#[inline]
97100
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
98101
where S: ser::Serializer { self.0.serialize(serializer) }
99102
}

src/shab64.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ use std::{
3030
pub struct ShaB64([u8; 20]);
3131

3232
impl fmt::Display for ShaB64 {
33+
#[inline]
3334
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34-
f.write_str(&self.pretty_print())
35+
f.pad(&self.pretty_print())
3536
}
3637
}
3738

3839
impl From<Sha1> for ShaB64 {
40+
#[inline]
3941
fn from(src: Sha1) -> Self { Self(<[u8; 20]>::from(src.finalize())) }
4042
}
4143

0 commit comments

Comments
 (0)