Skip to content

Commit

Permalink
release: 0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Sep 12, 2023
2 parents 1635de3 + 90da7fc commit 1cbe8cf
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 22 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 6 additions & 6 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -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:[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.5.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.5.1 | [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.8.0 | [zhangsoledad](mailto:[email protected]) | MIT |
| [faster-hex](https://github.com/NervosFoundation/faster-hex) | 0.8.1 | [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.6 | [David Tolnay](mailto:[email protected]) | 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:[email protected]) | 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:[email protected]) | WTFPL |
| [typenum](https://github.com/paholg/typenum) | 1.16.0 | [Paho Lurie-Gregg](mailto:[email protected]) and [Andre Bogus](mailto:[email protected]) | Apache-2.0 or MIT |
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cdtoc"
version = "0.2.1"
version = "0.2.2"
authors = ["Blobfolio, LLC. <[email protected]>"]
edition = "2021"
rust-version = "1.70"
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ bench BENCH="":


# Get/Set version.
version: credits
version:
#!/usr/bin/env bash
# Current version.
Expand All @@ -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:
Expand Down
56 changes: 48 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down Expand Up @@ -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
```
*/
Expand Down Expand Up @@ -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<Track> {
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.
///
Expand Down
6 changes: 6 additions & 0 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,11 @@ mod tests {
let toc = Toc::from_cdtoc(TOC).expect("Invalid TOC.");
let tracks: Vec<Track> = toc.audio_tracks().collect();
inout!(tracks, Vec<Track>, "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");
}
}
25 changes: 25 additions & 0 deletions src/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down

0 comments on commit 1cbe8cf

Please sign in to comment.