iqa 1.2.1

A single, ergonomic API over the patchwork of visual quality assessment metrics in the Rust ecosystem.
Documentation
//! Error type shared across all metrics.

/// Errors produced when constructing images or computing metrics.
#[derive(Debug, thiserror::Error)]
pub enum Error {
    /// The two images passed to a metric have different dimensions.
    #[error("dimension mismatch: {a:?} vs {b:?}")]
    DimensionMismatch {
        /// Dimensions of the first (reference) image, as `(width, height)`.
        a: (u32, u32),
        /// Dimensions of the second (distorted) image, as `(width, height)`.
        b: (u32, u32),
    },

    /// An image is smaller than the minimum a metric can process.
    #[error("image too small: {0}x{1}, minimum is {2}x{2}")]
    ImageTooSmall(u32, u32, u32),

    /// A sample buffer's length does not match the declared dimensions.
    #[error("buffer size mismatch: expected {expected} samples, got {actual}")]
    BufferSize {
        /// Number of samples the dimensions and format require.
        expected: usize,
        /// Number of samples actually provided.
        actual: usize,
    },

    /// The native SSIMULACRA2 implementation reported a failure.
    #[error("ssimulacra2 computation failed")]
    Ssimulacra2Failed,

    /// The native Butteraugli implementation reported a failure.
    #[error("butteraugli computation failed")]
    ButteraugliFailed,
}

/// Convenience alias for results returned by this crate.
pub type Result<T> = std::result::Result<T, Error>;