Skip to content
Clone
e8e8f2c
30 lines 1.1 KB Rust
//! Why a preview was not produced. Every reason is non-fatal: the caller keeps
//! the original and serves it instead.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PreviewSkip {
/// The declared content type is not one of the supported raster formats.
UnsupportedFormat,
/// The payload had no bytes.
Empty,
/// The source exceeds the byte or pixel ceiling for previews.
SourceTooLarge,
/// The source could not be decoded (corrupt, truncated, or a decoder limit).
Decode(String),
/// The decoded image could not be encoded back into a preview.
Encode(String),
}
impl std::fmt::Display for PreviewSkip {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::UnsupportedFormat => write!(f, "unsupported format"),
Self::Empty => write!(f, "empty payload"),
Self::SourceTooLarge => write!(f, "source too large"),
Self::Decode(reason) => write!(f, "decode failed: {reason}"),
Self::Encode(reason) => write!(f, "encode failed: {reason}"),
}
}
}
impl std::error::Error for PreviewSkip {}