pub struct Track { /* private fields */ }Expand description
§Audio Track.
This struct holds the details for an audio track, allowing you to fetch things like duration, sector positioning, etc.
It is the return value of Toc::audio_track.
Implementations§
Source§impl Track
impl Track
Sourcepub const fn is_htoa(&self) -> bool
pub const fn is_htoa(&self) -> bool
§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()));Sourcepub const fn msf_normalized(&self) -> (u32, u8, u8)
pub const fn msf_normalized(&self) -> (u32, u8, u8)
§MSF (Normalized).
Return the (beginning) MSF — minutes, seconds, and frames — of the track, without the mandatory 150-sector CD lead-in.
In other words, this value will always be two seconds less than
Track::msf.
Most applications expect a normalized MSF, so this is probably the version you’ll want to use.
§Examples
use cdtoc::Toc;
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
let track = toc.audio_track(2).unwrap();
assert_eq!(track.msf(), (2, 34, 13));
assert_eq!(track.msf_normalized(), (2, 32, 13));Sourcepub const fn position(&self) -> TrackPosition
pub const fn position(&self) -> TrackPosition
§Disc Position.
Return whether or not this track appears first, last, or somewhere in between on the disc.
§Examples
use cdtoc::{Toc, TrackPosition};
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
assert_eq!(toc.audio_track(1).unwrap().position(), TrackPosition::First);
assert_eq!(toc.audio_track(2).unwrap().position(), TrackPosition::Middle);
assert_eq!(toc.audio_track(3).unwrap().position(), TrackPosition::Middle);
assert_eq!(toc.audio_track(4).unwrap().position(), TrackPosition::Last);Sourcepub const fn sector_range(&self) -> Range<u32>
pub const fn sector_range(&self) -> Range<u32>
§Sector Range.
Return the range of sectors — start..end — occupied by this track.
§Examples
use cdtoc::Toc;
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
let track = toc.audio_track(1).unwrap();
assert_eq!(track.sector_range(), 150..11_563);
// If you just want the length, sectors() can get that more
// directly, but it works out the same either way:
assert_eq!(track.sector_range().len(), track.sectors() as usize);Sourcepub const fn sector_range_normalized(&self) -> Range<u32>
pub const fn sector_range_normalized(&self) -> Range<u32>
§Normalized Sector Range.
Return the range of sectors — start..end — occupied by this track,
without the mandatory 150-sector CD lead-in.
In other words, the start and end will be 150 less than the range
reported by Track::sector_range.
§Examples
use cdtoc::Toc;
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
let track = toc.audio_track(1).unwrap();
assert_eq!(track.sector_range(), 150..11_563);
assert_eq!(track.sector_range_normalized(), 0..11_413);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Track
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Track
serde only.