Skip to main content

webp_rust/encoder/
error.rs

1use std::fmt::{Display, Formatter, Result as FmtResult};
2
3/// Error type used by encoding entry points.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum EncoderError {
6    /// A caller-provided dimension or buffer length is invalid.
7    InvalidParam(&'static str),
8    /// Internal encoder state would produce an invalid VP8L bitstream.
9    Bitstream(&'static str),
10}
11
12impl Display for EncoderError {
13    fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
14        match self {
15            Self::InvalidParam(msg) => write!(f, "invalid parameter: {msg}"),
16            Self::Bitstream(msg) => write!(f, "bitstream error: {msg}"),
17        }
18    }
19}
20
21impl std::error::Error for EncoderError {}