diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dd940c..247bb72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ # Changelog +## [0.2.2](https://github.com/Blobfolio/cdtoc/releases/tag/v0.2.2) - 2023-09-12 + +### New + +* `Toc::htoa` +* `Track::is_htoa` + + + ## [0.2.1](https://github.com/Blobfolio/cdtoc/releases/tag/v0.2.1) - 2023-06-25 ### New diff --git a/CREDITS.md b/CREDITS.md index dc54f0b..ec7bf40 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -1,19 +1,19 @@ # Project Dependencies Package: cdtoc - Version: 0.2.0 - Generated: 2023-06-26 04:44:05 UTC + Version: 0.2.2 + Generated: 2023-09-12 16:13:26 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:alex@alexcrichton.com) | 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.5.0 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL | +| [dactyl](https://github.com/Blobfolio/dactyl) | 0.5.1 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | 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.8.0 | [zhangsoledad](mailto:787953403@qq.com) | MIT | +| [faster-hex](https://github.com/NervosFoundation/faster-hex) | 0.8.1 | [zhangsoledad](mailto:787953403@qq.com) | MIT | | [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 | -| [itoa](https://github.com/dtolnay/itoa) | 1.0.6 | [David Tolnay](mailto:dtolnay@gmail.com) | Apache-2.0 or MIT | -| [num-traits](https://github.com/rust-num/num-traits) | 0.2.15 | The Rust Project Developers | Apache-2.0 or MIT | +| [itoa](https://github.com/dtolnay/itoa) | 1.0.9 | [David Tolnay](mailto:dtolnay@gmail.com) | Apache-2.0 or MIT | +| [num-traits](https://github.com/rust-num/num-traits) | 0.2.16 | The Rust Project Developers | Apache-2.0 or MIT | | [sha1](https://github.com/RustCrypto/hashes) | 0.10.5 | RustCrypto Developers | Apache-2.0 or MIT | | [trimothy](https://github.com/Blobfolio/trimothy) | 0.1.8 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL | | [typenum](https://github.com/paholg/typenum) | 1.16.0 | [Paho Lurie-Gregg](mailto:paho@paholg.com) and [Andre Bogus](mailto:bogusandre@gmail.com) | Apache-2.0 or MIT | diff --git a/Cargo.toml b/Cargo.toml index 65b3b64..63a16bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cdtoc" -version = "0.2.1" +version = "0.2.2" authors = ["Blobfolio, LLC. "] edition = "2021" rust-version = "1.70" diff --git a/README.md b/README.md index 323de64..2d50dad 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,6 @@ By default it can also generate disc IDs for services like [AccurateRip](http:// -## Work In Progress - -This library is a work-in-progress. If you notice any bugs, please open an [issue](https://github.com/Blobfolio/cdtoc/issues)! - - - ## Examples ```rust diff --git a/justfile b/justfile index 65faeea..170213c 100644 --- a/justfile +++ b/justfile @@ -156,7 +156,7 @@ bench BENCH="": # Get/Set version. -version: credits +version: #!/usr/bin/env bash # Current version. @@ -176,6 +176,9 @@ version: credits # Set the release version! just _version "{{ justfile_directory() }}" "$_ver2" + # Update the credits. + just credits + # Set version for real. @_version DIR VER: diff --git a/src/lib.rs b/src/lib.rs index 9fbebc1..d0ea369 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,12 +17,6 @@ By default it can also generate disc IDs for services like [AccurateRip](http:// -## Work In Progress - -This library is a work-in-progress. If you notice any bugs, please open an [issue](https://github.com/Blobfolio/cdtoc/issues)! - - - ## Examples ``` @@ -69,14 +63,14 @@ Add `cdtoc` to your `dependencies` in `Cargo.toml`, like: ```ignore,toml [dependencies] -cdtoc = "0.1.*" +cdtoc = "0.2.*" ``` The disc ID helpers require additional dependencies, so if you aren't using them, be sure to disable the default features (adding back any you _do_ want) to skip the overhead. ```ignore,toml [dependencies.cdtoc] -version = "0.1.*" +version = "0.2.*" default-features = false ``` */ @@ -710,6 +704,52 @@ impl Toc { /// ``` pub const fn has_data(&self) -> bool { self.kind.has_data() } + #[must_use] + /// # HTOA Pre-gap "Track". + /// + /// Return a `Track` object representing the space between the mandatory + /// disc leadin (`150`) and the start of the first audio track, if any. + /// + /// Such regions usually only contain a small amount of silence — extra + /// padding, basically — but every once in a while might be a secret bonus + /// song. + /// + /// ## Examples + /// + /// ``` + /// use cdtoc::Toc; + /// + /// // This disc has no HTOA. + /// let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap(); + /// assert!(toc.htoa().is_none()); + /// + /// // But this one does! + /// let toc = Toc::from_cdtoc("15+247E+2BEC+4AF4+7368+9704+B794+E271+110D0+12B7A+145C1+16CAF+195CF+1B40F+1F04A+21380+2362D+2589D+2793D+2A760+2DA32+300E1+32B46").unwrap(); + /// let htoa = toc.htoa().unwrap(); + /// assert!(htoa.is_htoa()); // Should always be true. + /// + /// // HTOAs have no track number. + /// assert_eq!(htoa.number(), 0); + /// + /// // Their position is also technically invalid. + /// assert!(! htoa.position().is_valid()); + /// + /// // Their ranges are normal, though. + /// assert_eq!(htoa.sector_range(), 150..9342); + /// ``` + pub fn htoa(&self) -> Option { + let leadin = self.audio_leadin(); + if leadin == 150 || matches!(self.kind, TocKind::DataFirst) { None } + else { + Some(Track { + num: 0, + pos: TrackPosition::Invalid, + from: 150, + to: leadin, + }) + } + } + #[must_use] /// # CD Format. /// diff --git a/src/serde.rs b/src/serde.rs index 5cb4a33..50f042e 100644 --- a/src/serde.rs +++ b/src/serde.rs @@ -279,5 +279,11 @@ mod tests { let toc = Toc::from_cdtoc(TOC).expect("Invalid TOC."); let tracks: Vec = toc.audio_tracks().collect(); inout!(tracks, Vec, "Track"); + + // Make sure HTOA tracks work out okay. + let toc = Toc::from_cdtoc("15+247E+2BEC+4AF4+7368+9704+B794+E271+110D0+12B7A+145C1+16CAF+195CF+1B40F+1F04A+21380+2362D+2589D+2793D+2A760+2DA32+300E1+32B46") + .expect("Mummies TOC failed."); + let htoa = toc.htoa().expect("Mummies HTOA failed."); + inout!(htoa, Track, "HTOA"); } } diff --git a/src/track.rs b/src/track.rs index d543b10..da92ee1 100644 --- a/src/track.rs +++ b/src/track.rs @@ -57,6 +57,31 @@ impl Track { /// ``` pub const fn duration(&self) -> Duration { Duration(self.sectors() as u64) } + #[must_use] + /// # Is HTOA? + /// + /// Return `true` if this is a pre-gap hidden track. + /// + /// ## Examples + /// + /// ``` + /// use cdtoc::Toc; + /// + /// let toc = Toc::from_cdtoc("15+247E+2BEC+4AF4+7368+9704+B794+E271+110D0+12B7A+145C1+16CAF+195CF+1B40F+1F04A+21380+2362D+2589D+2793D+2A760+2DA32+300E1+32B46").unwrap(); + /// + /// // This will return true for the HTOA. + /// let htoa = toc.htoa().unwrap(); + /// assert!(htoa.is_htoa()); + /// + /// // And false for everything else. + /// assert!(toc.audio_tracks().all(|v| ! v.is_htoa())); + /// ``` + pub const fn is_htoa(&self) -> bool { + self.num == 0 && + self.from == 150 && + matches!(self.pos, TrackPosition::Invalid) + } + #[must_use] /// # MSF. ///