atrac3p_decoder/
error.rs

1// Atrac3+ Decoder
2//
3// Copyright (c) 2020 Cory Forsstrom <cforsstrom18@gmail.com>
4// Copyright (c) 2010-2013 Maxim Poliakovski
5//
6// The following code is a derivative work of the code from the FFmpeg project,
7// which is licensed LGPL v2.1. This code therefore is also licensed under the terms
8// of the GNU Lesser General Public License, verison 2.1.
9
10use std::io;
11use thiserror::Error;
12
13#[derive(Debug, Error)]
14pub enum Error {
15    #[error("IO error reading file: {0}")]
16    IOError(io::Error),
17    #[error("Error reading riff file: {0}")]
18    RiffError(riff_wave_reader::Error),
19    #[error("No extended info in riff file, can't determine spec")]
20    RiffErrorNoExtendedInfo,
21    #[error("File supplied is not Atrac3Plus")]
22    NotAtrac3PlusFile,
23    #[error("Block align is not set")]
24    BlockAlignNotSet,
25    #[error("Invalid Start Bit")]
26    InvalidStartBit,
27    #[error("Unsupported channel unit extension")]
28    UnsupportedChannelUnitExtension,
29    #[error("Channel Unit Type can only be 2 bits")]
30    InvalidChannelUnitTypeBits,
31    #[error("Invalid Data")]
32    InvalidData,
33    #[error("Unsupported channel count: {0}")]
34    UnsupportedChannelCount(u16),
35    #[error("{0}")]
36    Other(&'static str),
37    #[error("{0}")]
38    OtherFormat(String),
39}
40
41impl From<riff_wave_reader::Error> for Error {
42    fn from(error: riff_wave_reader::Error) -> Self {
43        Error::RiffError(error)
44    }
45}
46
47impl From<std::io::Error> for Error {
48    fn from(error: std::io::Error) -> Self {
49        Error::IOError(error)
50    }
51}