cue

Crates.iocue
lib.rscue
version3.0.0
sourcesrc
created_at2016-07-01 20:24:43.271816
updated_at2024-11-24 10:40:26.32378
descriptionHigh-level bindings for the libcue library
homepagehttps://github.com/mistydemeo/libcue.rs
repositoryhttps://github.com/mistydemeo/libcue.rs
max_upload_size
id5562
size37,885
Misty De Méo (mistydemeo)

documentation

README

cue

This crate provides Rust bindings for the libcue library, which supports parsing and interpreting CUE sheets. The CUE sheet format is commonly used for authoring CDs and to store copies of ripped CDs.

This repository contains two crates: cue-sys, which contains raw bindings for the original C API, and cue, which provides a higher-level, more Rustic interface.

Example

Here's a simple example of how to use this crate using a sample CUE sheet:

use cue::cd::{CD, DiscMode};

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().unwrap_or(-1));
    println!("Pregap: {}", track.get_zero_pre().unwrap_or(0));
    println!("Postgap: {}", track.get_zero_post().unwrap_or(0));
    println!("");
}

Contributing

If you have trouble using this crate, feel free to file an issue asking for help. I'll do my best to help you out!

Pull requests are very welcome. If you're new to open source, or to Rust, just let me know and I'll be glad to help you through the process of contributing!

License

Both crates are licensed under the GPL 2.0, which is the same license used by libcue.

Commit count: 46

cargo fmt