Track

Struct Track 

Source
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

Source

pub const fn bytes(self) -> u64

§Byte Size.

Return the equivalent RAW PCM byte size for this track.

§Examples
use cdtoc::Toc;

let toc = Toc::from_cdtoc("9+96+5766+A284+E600+11FE5+15913+19A98+1E905+240CB+26280").unwrap();
let track = toc.audio_track(9).unwrap();
assert_eq!(
    track.bytes(),
    20_295_408,
);
Source

pub const fn duration(&self) -> Duration

§Duration.

Return the track duration (seconds + frames).

§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.duration().to_string(), "00:02:32+13");
Source

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()));
Source

pub const fn msf(&self) -> (u32, u8, u8)

§MSF.

Return the (beginning) MSF — minutes, seconds, and frames — of the track.

§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));
Source

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));
Source

pub const fn number(&self) -> u8

§Number.

Return the track number.

§Examples
use cdtoc::Toc;

let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
assert_eq!(toc.audio_track(2).unwrap().number(), 2_u8);
Source

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);
Source

pub const fn samples(self) -> u64

§Total Samples.

Return the total number of samples.

§Examples
use cdtoc::Toc;

let toc = Toc::from_cdtoc("9+96+5766+A284+E600+11FE5+15913+19A98+1E905+240CB+26280").unwrap();
let track = toc.audio_track(9).unwrap();
assert_eq!(
    track.samples(),
    5_073_852,
);
Source

pub const fn sectors(&self) -> u32

§Sector Size.

Return the number of sectors 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.sectors(), 11_413_u32);
Source

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);
Source

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 Clone for Track

Source§

fn clone(&self) -> Track

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Track

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Track

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for Track

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Track

Source§

fn eq(&self, other: &Track) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Track

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for Track

Source§

impl Eq for Track

Source§

impl StructuralPartialEq for Track

Auto Trait Implementations§

§

impl Freeze for Track

§

impl RefUnwindSafe for Track

§

impl Send for Track

§

impl Sync for Track

§

impl Unpin for Track

§

impl UnwindSafe for Track

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,