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
impl CD
sourcepub fn parse(string: String) -> Result<CD, NulError>
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.
sourcepub fn parse_file(path: PathBuf) -> Result<CD, Error>
pub fn parse_file(path: PathBuf) -> Result<CD, Error>
Reads the file contained at path
and parses it like the parse
function
above.
sourcepub fn get_mode(&self) -> DiscMode
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
.
sourcepub fn get_cdtextfile(&self) -> Option<String>
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.
sourcepub fn get_track_count(&self) -> isize
pub fn get_track_count(&self) -> isize
Returns the total number of tracks in this CD.
sourcepub fn get_cdtext(&self) -> CDText
pub fn get_cdtext(&self) -> CDText
Returns a CDText
representing the CD-TEXT data stored within
this CUE sheet.