Skip to main content

dnoise_core/
error.rs

1//! The error type of the pure stages and the per-frame API.
2
3use thiserror::Error;
4
5/// Convenience alias for results produced by this crate.
6pub type Result<T, E = Error> = std::result::Result<T, E>;
7
8/// Anything that can go wrong while building the run state or denoising a frame.
9/// The messages match the `dnoise` crate's `DnoiseError` variants of the same
10/// name, which this converts into one to one.
11#[derive(Debug, Error)]
12#[non_exhaustive]
13pub enum Error {
14    /// Invalid input, configuration or metadata.
15    #[error("{0}")]
16    InvalidInput(String),
17
18    /// Reading or decoding a supporting frame failed (reported by the caller's
19    /// frame source).
20    #[error("reading frame {index}: {message}")]
21    FrameRead {
22        /// Zero-based frame index that failed.
23        index: usize,
24        /// Upstream reader message.
25        message: String,
26    },
27
28    /// A cancellation token was set before the work finished.
29    #[error("cancelled")]
30    Cancelled,
31}