Struct cue::cd::CD

source ·
pub struct CD { /* private fields */ }
Expand description

The CD struct represents the entirety of a CD, which is the core unit of a CUE sheet. This struct contains the parsing methods used as the primary entry point to libcue’s functionality.

A CD can be a pure CD audio disc, a pure data disc, or a mixed-mode disc containing both data and audio tracks in arbitrary order. A CD will always have at least one track.

Here’s an example of a simple function which parses a CUE sheet and prints information about its contents:

use cue::cd::{CD, DiscMode};
use cue::track::{TrackMode, TrackSubMode};

let cue_sheet = "FILE \"example.img\" BINARY
  TRACK 01 MODE1/2352
    INDEX 01 00:00:00
  TRACK 02 AUDIO
    PREGAP 00:02:00
    INDEX 01 58:41:36
  TRACK 03 AUDIO
    INDEX 00 61:06:08
    INDEX 01 61:08:08
";

let cd = CD::parse(cue_sheet.to_string()).unwrap();

println!("Number of tracks: {}", cd.get_track_count());
let mode = match cd.get_mode() {
    DiscMode::CD_DA => "CD-DA",
    DiscMode::CD_ROM => "CD-ROM",
    DiscMode::CD_ROM_XA => "CD-ROM XA",
};
println!("Mode: {}", mode);
println!("");

for (index, track) in cd.tracks().iter().enumerate() {
    println!("Track {}", index + 1);
    println!("Filename: {}", track.get_filename());
    println!("Start: {}", track.get_start());
    println!("Length: {}", track.get_length());
    println!("Pregap: {}", track.get_zero_pre());
    println!("Postgap: {}", track.get_zero_post());
    println!("");
}

Implementations§

source§

impl CD

source

pub fn parse(string: String) -> Result<CD, NulError>

Parses a string containing a CUE sheet and returns a CD struct.

Errors

Returns a NulError if the provided string contains any null bytes.

source

pub fn parse_file(path: PathBuf) -> Result<CD, Error>

Reads the file contained at path and parses it like the parse function above.

source

pub fn get_mode(&self) -> DiscMode

Returns a DiscMode value indicating the type of disc represented by this CUE sheet. Individual tracks also have types; see Track.get_mode and Track.get_sub_mode.

source

pub fn get_cdtextfile(&self) -> Option<String>

Returns the path on disc to the sidecar metadata file containing CD-TEXT metadata, if any.

Safety

This may segfault if there is no CD-TEXT sidecar.

source

pub fn get_track_count(&self) -> isize

Returns the total number of tracks in this CD.

source

pub fn get_track(&self, index: isize) -> Result<Track, String>

Returns a Track struct for the track at the requested index. Note that track numbering starts from 1; there is no track 0.

Errors

If the requested track doesn’t exist in the CD, returns Err with a string containing an error message.

source

pub fn tracks(&self) -> Vec<Track>

Returns a Vec containing every track in the CD.

source

pub fn get_cdtext(&self) -> CDText

Returns a CDText representing the CD-TEXT data stored within this CUE sheet.

source

pub fn get_rem(&self) -> REM

Returns a REM representing the comments stored within this CUE sheet.

Trait Implementations§

source§

impl Drop for CD

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for CD

§

impl !Send for CD

§

impl !Sync for CD

§

impl Unpin for CD

§

impl UnwindSafe for CD

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.