av_codec/
error.rs

1use std::fmt;
2
3/// General coding errors.
4#[derive(Debug)]
5pub enum Error {
6    /// Invalid input data.
7    InvalidData,
8    /// A coding operation needs more data to be completed.
9    MoreDataNeeded,
10    /// Incomplete input configuration.
11    ConfigurationIncomplete,
12    /// Invalid input configuration.
13    ConfigurationInvalid,
14    /// Unsupported requested feature.
15    Unsupported(String),
16    // TODO add support for dependency-specific errors here
17    // Inner(failure::Context)
18}
19
20impl std::error::Error for Error {}
21
22impl fmt::Display for Error {
23    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
24        match self {
25            Error::InvalidData => write!(f, "Invalid Data"),
26            Error::MoreDataNeeded => write!(f, "Additional data needed"),
27            Error::ConfigurationIncomplete => write!(f, "Configuration Incomplete"),
28            Error::ConfigurationInvalid => write!(f, "Configuration Invalid"),
29            Error::Unsupported(feat) => write!(f, "Unsupported feature {feat}"),
30        }
31    }
32}
33
34/// A specialized `Result` type for coding operations.
35pub type Result<T> = ::std::result::Result<T, Error>;