mirror of
https://github.com/storytold/photocraft.git
synced 2026-10-28 10:11:58 +01:00
CI's `cargo fmt --all -- --check` has failed on every run because the repo had no rustfmt config and was never formatted. Use the same settings as EffectCraft/FilmCraft (max_width 160, use_small_heuristics Max), which also keeps the churn small. Formatting only; no code changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.1 KiB
Rust
32 lines
1.1 KiB
Rust
use crate::format::Format;
|
|
|
|
/// Errors produced by this crate. Decoders never panic on malformed input;
|
|
/// they return [`CodecError::Malformed`] instead.
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum CodecError {
|
|
#[error("unrecognized image format")]
|
|
UnknownFormat,
|
|
#[error("{format:?}: {reason}")]
|
|
Unsupported { format: Format, reason: String },
|
|
#[error("{format:?}: malformed data: {message}")]
|
|
Malformed { format: Format, message: String },
|
|
#[error("limit exceeded: {0}")]
|
|
LimitExceeded(String),
|
|
#[error("{format:?}: encode failed: {message}")]
|
|
Encode { format: Format, message: String },
|
|
#[error("invalid image: {0}")]
|
|
InvalidImage(String),
|
|
}
|
|
|
|
impl CodecError {
|
|
pub(crate) fn malformed(format: Format, e: impl std::fmt::Display) -> Self {
|
|
CodecError::Malformed { format, message: e.to_string() }
|
|
}
|
|
pub(crate) fn encode(format: Format, e: impl std::fmt::Display) -> Self {
|
|
CodecError::Encode { format, message: e.to_string() }
|
|
}
|
|
pub(crate) fn unsupported(format: Format, reason: impl Into<String>) -> Self {
|
|
CodecError::Unsupported { format, reason: reason.into() }
|
|
}
|
|
}
|