3 stable releases

2.0.0 Nov 24, 2024
1.1.0 Jun 3, 2023
1.0.0 May 21, 2018

#2083 in Parser implementations

Download history 19/week @ 2024-08-19 12/week @ 2024-09-09 7/week @ 2024-09-23 2/week @ 2024-09-30 7/week @ 2024-10-14 8/week @ 2024-11-04 142/week @ 2024-11-18 62/week @ 2024-11-25

212 downloads per month
Used in 2 crates (via cue)

GPL-2.0-or-later

60KB
2K SLoC

C 1K SLoC // 0.1% comments CUE 334 SLoC Happy 304 SLoC Lex 109 SLoC // 0.0% comments Rust 95 SLoC

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.

Dependencies

~0.4–390KB