Skip to content

Commit

Permalink
release: 0.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Nov 8, 2024
2 parents 2d83eeb + 8022125 commit f641a25
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 75 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@



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

### Changed

* Add (more) inline hints
* Add `Formatter` width/fill/align/etc. support for `AccurateRip`, `Cddb`, `ShaB64`
* Improve docs, test coverage



## [0.5.1](https://github.com/Blobfolio/cdtoc/releases/tag/v0.5.1) - 2024-10-10

### Changed
Expand Down
47 changes: 31 additions & 16 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
# Project Dependencies
Package: cdtoc
Version: 0.5.1
Generated: 2024-10-11 03:12:14 UTC
Version: 0.5.2
Generated: 2024-11-08 06:38:45 UTC

| Package | Version | Author(s) | License |
| ---- | ---- | ---- | ---- |
| [block-buffer](https://github.com/RustCrypto/utils) | 0.10.4 | RustCrypto Developers | Apache-2.0 or MIT |
| [cfg-if](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
| [crypto-common](https://github.com/RustCrypto/traits) | 0.1.6 | RustCrypto Developers | Apache-2.0 or MIT |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.4 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [digest](https://github.com/RustCrypto/traits) | 0.10.7 | RustCrypto Developers | Apache-2.0 or MIT |
| [faster-hex](https://github.com/NervosFoundation/faster-hex) | 0.10.0 | [zhangsoledad](mailto:[email protected]) | MIT |
| [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 |
| [itoa](https://github.com/dtolnay/itoa) | 1.0.11 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [serde](https://github.com/serde-rs/serde) | 1.0.210 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [sha1](https://github.com/RustCrypto/hashes) | 0.10.6 | RustCrypto Developers | Apache-2.0 or MIT |
| [trimothy](https://github.com/Blobfolio/trimothy) | 0.3.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [typenum](https://github.com/paholg/typenum) | 1.17.0 | [Paho Lurie-Gregg](mailto:[email protected]) and [Andre Bogus](mailto:[email protected]) | Apache-2.0 or MIT |
| 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 |
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "cdtoc"
version = "0.5.1"
authors = ["Blobfolio, LLC. <hello@blobfolio.com>"]
version = "0.5.2"
authors = ["Josh Stoik <josh@blobfolio.com>"]
edition = "2021"
rust-version = "1.81"
description = "Parser and tools for CDTOC metadata tags."
Expand All @@ -19,9 +19,6 @@ exclude = [

[package.metadata.bashman]
name = "CDTOC"
bash-dir = "./"
man-dir = "./"
credits-dir = "./"

[package.metadata.docs.rs]
rustc-args = ["--cfg", "docsrs"]
Expand Down
22 changes: 0 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,3 @@ The disc ID helpers require additional dependencies, so if you aren't using them
version = "0.5.*"
default-features = false
```



## License

Copyright © 2024 [Blobfolio, LLC](https://blobfolio.com) &lt;[email protected]&gt;

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.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.
10 changes: 9 additions & 1 deletion src/accuraterip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,19 @@ const DRIVE_OFFSET_OFFSET_RNG: Range<i16> = -2940..2941;
pub struct AccurateRip([u8; 13]);

impl AsRef<[u8]> for AccurateRip {
#[inline]
fn as_ref(&self) -> &[u8] { &self.0 }
}

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

impl fmt::Display for AccurateRip {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.pretty_print())
f.pad(&self.pretty_print())
}
}

Expand Down Expand Up @@ -412,6 +415,10 @@ impl AccurateRip {
/// toc.accuraterip_id().pretty_print(),
/// "013-0015deca-00d9b921-9a0a6e0d",
/// );
/// assert_eq!(
/// toc.accuraterip_id().to_string(),
/// "013-0015deca-00d9b921-9a0a6e0d",
/// );
/// ```
pub fn pretty_print(&self) -> String {
let mut out: Vec<u8> = vec![
Expand Down Expand Up @@ -545,6 +552,7 @@ mod tests {
let toc = Toc::from_cdtoc(t).expect("Invalid TOC");
let ar_id = toc.accuraterip_id();
assert_eq!(ar_id.to_string(), id);
assert_eq!(ar_id.pretty_print(), id);

// Test decoding three ways.
assert_eq!(AccurateRip::decode(id), Ok(ar_id));
Expand Down
4 changes: 3 additions & 1 deletion src/cddb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl fmt::Display for Cddb {
faster_hex::hex_encode_fallback(self.0.to_be_bytes().as_slice(), &mut buf);
std::str::from_utf8(buf.as_slice())
.map_err(|_| fmt::Error)
.and_then(|s| f.write_str(s))
.and_then(|s| f.pad(s))
}
}

Expand All @@ -64,10 +64,12 @@ impl FromStr for Cddb {
}

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

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

Expand Down
1 change: 1 addition & 0 deletions src/ctdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ mod tests {
let toc = Toc::from_cdtoc(t).expect("Invalid TOC");
let ctdb_id = toc.ctdb_id();
assert_eq!(ctdb_id.to_string(), id);
assert_eq!(ctdb_id.pretty_print(), id);
assert_eq!(toc.ctdb_checksum_url(), lookup);

// Test decoding three ways.
Expand Down
40 changes: 20 additions & 20 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,26 @@ pub enum TocError {

impl fmt::Display for TocError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::CDDASampleCount => f.write_str("Invalid CDDA sample count."),
Self::CDTOCChars => f.write_str("Invalid character(s), expecting only 0-9, A-F, +, and (rarely) X."),
Self::Checksums => f.write_str("Unable to parse checksums."),
Self::Format(kind) => write!(f, "This operation can't be applied to {kind} discs."),
Self::LeadinSize => f.write_str("Leadin must be at least 150."),
Self::NoAudio => f.write_str("At least one audio track is required."),
Self::NoChecksums => f.write_str("No checksums were present."),
Self::SectorCount(expected, found) => write!(f, "Expected {expected} audio sectors, found {found}."),
Self::SectorOrder => f.write_str("Sectors are incorrectly ordered or overlap."),
Self::SectorSize => f.write_str("Sector sizes may not exceed four bytes (u32)."),
Self::TrackCount => f.write_str("The number of audio tracks must be between 1..=99."),

#[cfg(feature = "accuraterip")] Self::AccurateRipDecode => f.write_str("Invalid AccurateRip ID string."),
#[cfg(feature = "accuraterip")] Self::DriveOffsetDecode => f.write_str("Unable to parse drive offsets."),
#[cfg(feature = "accuraterip")] Self::NoDriveOffsets => f.write_str("No drive offsets were found."),

#[cfg(feature = "cddb")] Self::CddbDecode => f.write_str("Invalid CDDB ID string."),
#[cfg(feature = "sha1")] Self::ShaB64Decode => f.write_str("Invalid sha/base64 ID string."),
}
f.write_str(match self {
Self::CDDASampleCount => "Invalid CDDA sample count.",
Self::CDTOCChars => "Invalid character(s), expecting only 0-9, A-F, +, and (rarely) X.",
Self::Checksums => "Unable to parse checksums.",
Self::Format(kind) => return write!(f, "This operation can't be applied to {kind} discs."),
Self::LeadinSize => "Leadin must be at least 150.",
Self::NoAudio => "At least one audio track is required.",
Self::NoChecksums => "No checksums were present.",
Self::SectorCount(expected, found) => return write!(f, "Expected {expected} audio sectors, found {found}."),
Self::SectorOrder => "Sectors are incorrectly ordered or overlap.",
Self::SectorSize => "Sector sizes may not exceed four bytes (u32).",
Self::TrackCount => "The number of audio tracks must be between 1..=99.",

#[cfg(feature = "accuraterip")] Self::AccurateRipDecode => "Invalid AccurateRip ID string.",
#[cfg(feature = "accuraterip")] Self::DriveOffsetDecode => "Unable to parse drive offsets.",
#[cfg(feature = "accuraterip")] Self::NoDriveOffsets => "No drive offsets were found.",

#[cfg(feature = "cddb")] Self::CddbDecode => "Invalid CDDB ID string.",
#[cfg(feature = "sha1")] Self::ShaB64Decode => "Invalid sha/base64 ID string.",
})
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,9 +979,8 @@ pub enum TocKind {
}

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

impl TocKind {
Expand Down
5 changes: 5 additions & 0 deletions src/musicbrainz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ impl Toc {
/// toc.musicbrainz_id().to_string(),
/// "nljDXdC8B_pDwbdY1vZJvdrAZI4-",
/// );
/// assert_eq!(
/// toc.musicbrainz_id().pretty_print(),
/// "nljDXdC8B_pDwbdY1vZJvdrAZI4-",
/// );
/// ```
pub fn musicbrainz_id(&self) -> ShaB64 {
use sha1::Digest;
Expand Down Expand Up @@ -133,6 +137,7 @@ mod tests {
let toc = Toc::from_cdtoc(t).expect("Invalid TOC");
let mb_id = toc.musicbrainz_id();
assert_eq!(mb_id.to_string(), id);
assert_eq!(mb_id.pretty_print(), id);

// Test decoding three ways.
assert_eq!(ShaB64::decode(id), Ok(mb_id));
Expand Down
3 changes: 3 additions & 0 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ macro_rules! serialize_with {
($ty:ty, $fn:ident) => (
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl Serialize for $ty {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: ser::Serializer { self.$fn().serialize(serializer) }
}
Expand All @@ -86,6 +87,7 @@ serialize_with!(Toc, to_string);

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

#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl Serialize for Duration {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: ser::Serializer { self.0.serialize(serializer) }
}
Expand Down
4 changes: 3 additions & 1 deletion src/shab64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ use std::{
pub struct ShaB64([u8; 20]);

impl fmt::Display for ShaB64 {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.pretty_print())
f.pad(&self.pretty_print())
}
}

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

Expand Down
Loading

0 comments on commit f641a25

Please sign in to comment.