lib.rsannotatedlib.rssource64 lines · 2.1 KB · raw
1pub mod cdtime;
2pub mod cue;
3pub mod reader;
4
5use std::io;
6use thiserror::Error;

Data: 16 header bytes + 2048 data bytes + 288 error detection/correction bytes Audio: 1176 signed 16-bit PCM samples, half for the left channel and half for the right channel

10pub const BYTES_PER_SECTOR: u64 = 2352;
12#[derive(Debug, Error)]
13pub enum CdRomError {
14    #[error("Unable to determine parent directory of CUE file '{0}'")]
15    CueParentDir(String),
16    #[error("Error parsing CUE file: {0}")]
17    CueParse(String),
18    #[error("Invalid/unsupported FILE line in CUE file: {0}")]
19    CueInvalidFileLine(String),
20    #[error("Invalid/unsupported TRACK line in CUE file: {0}")]
21    CueInvalidTrackLine(String),
22    #[error("Invalid/unsupported INDEX line in CUE file: {0}")]
23    CueInvalidIndexLine(String),
24    #[error("Invalid/unsupported PREGAP line in CUE file: {0}")]
25    CueInvalidPregapLine(String),
26    #[error("Invalid/unsupported POSTGAP line in CUE file: {0}")]
27    CueInvalidPostgapLine(String),
28    #[error("Unable to get file metadata for file '{path}': {source}")]
29    FsMetadata {
30        path: String,
31        #[source]
32        source: io::Error,
33    },
34    #[error("Error opening CUE file '{path}': {source}")]
35    CueOpen {
36        path: String,
37        #[source]
38        source: io::Error,
39    },
40    #[error("Error opening BIN file '{path}': {source}")]
41    BinOpen {
42        path: String,
43        #[source]
44        source: io::Error,
45    },
46    #[error("CHD-related error: {0}")]
47    ChdError(#[from] chd::Error),
48    #[error("Error opening CHD file '{path}': {source}")]
49    ChdOpen {
50        path: String,
51        #[source]
52        source: io::Error,
53    },
54    #[error("Unable to parse CD-ROM metadata in CHD header: '{metadata_value}'")]
55    ChdHeaderParseError { metadata_value: String },
56    #[error("CHD header contains an invalid CD-ROM track list: {track_numbers:?}")]
57    ChdInvalidTrackList { track_numbers: Vec<u8> },
58    #[error("I/O error reading from disc: {0}")]
59    DiscReadIo(#[source] io::Error),
60    #[error("WAV file in unsupported format; must contain 44100 Hz 16-bit stereo samples")]
61    WaveUnsupported,
62}
63
64pub type CdRomResult<T> = Result<T, CdRomError>;