#[non_exhaustive]pub enum ImageCodecError {
Filter(FilterError),
Unsupported {
codec: Codec,
},
FeatureUnsupported {
feature: &'static str,
},
Corrupt {
codec: Codec,
detail: String,
},
TooLarge,
DeclaredGeometryExceedsData {
codec: Codec,
declared: DeclaredGeometry,
min_bytes: u64,
have_bytes: u64,
},
AllocationFailed {
bytes: u64,
},
NotAllowedInline {
codec: Codec,
},
BrotliNotAllowedInline,
CodecNotTerminal,
Cancelled,
}Expand description
Why an image stream could not be turned into samples.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Filter(FilterError)
A byte-stream filter in the chain’s prefix failed.
Unsupported
The codec itself is recognized but not implemented in this build. Should be zero once Pass 2.3 lands; the variant is kept afterwards so a regression stays visible.
FeatureUnsupported
A specific codec sub-feature is unimplemented (rule R27).
feature is a stable diagnostic key such as "DCT/arithmetic"
or "DCT/12-bit", suitable for counting by name.
Corrupt
The codestream is malformed or truncated.
Fields
TooLarge
The codestream’s declared geometry crosses a pdfcer ceiling
(MAX_IMAGE_PIXELS, MAX_IMAGE_DIMENSION,
MAX_IMAGE_SAMPLE_BYTES).
DeclaredGeometryExceedsData
The codestream declares more geometry than its own bytes could
encode (decision 227): any conforming encoding of declared takes
at least min_bytes, and the codec was handed have_bytes. Refused
before anything is sized from the declared geometry.
ImageCodecError::refusal_key names the codec’s bound.
Fields
declared: DeclaredGeometryThe geometry the codestream or its parameters declared.
AllocationFailed
The allocator refused a buffer the image needed. The image is within pdfcer’s ceilings; the machine lacks the memory (decision 226). Never an abort, because on wasm32 an abort traps the module.
NotAllowedInline
The codec is forbidden inside an inline image (§7.4.7, §8.9.7).
BrotliNotAllowedInline
/BrotliDecode appeared in an inline image’s filter chain, which
EXTN-BROTLI-1 §5.2 forbids outright.
Distinct from ImageCodecError::NotAllowedInline deliberately: that
one names a terminal codec the inline form does not admit, while
this is a byte-stream filter that is legal everywhere else a
stream is legal. Collapsing the two would report “codec not allowed
inline” about something that is not a codec, and an operator chasing
that message would look in the wrong half of the file.
CodecNotTerminal
Two or more terminal codecs in one /Filter chain, or a codec
followed by further filters. Neither is meaningful: a codec
consumes a codestream and produces samples, so nothing can be
chained after it.
Cancelled
The caller’s cancel poll answered true mid-decode
(decode_image_view_cancellable). A cancel inside the filter
prefix arrives as ImageCodecError::Filter carrying
FilterError::Cancelled instead; callers treat both alike.
Implementations§
Source§impl ImageCodecError
impl ImageCodecError
Sourcepub fn refusal_key(&self) -> Option<&'static str>
pub fn refusal_key(&self) -> Option<&'static str>
A stable, greppable key naming why the image was refused, for
counting refusals by cause: image/evidence/dct, image/evidence/jpx
or image/evidence/ccitt for
ImageCodecError::DeclaredGeometryExceedsData. None for errors
that carry no refusal key.
§Examples
use pdfcer_image_codec::{Codec, DeclaredGeometry, ImageCodecError};
let e = ImageCodecError::DeclaredGeometryExceedsData {
codec: Codec::Ccitt,
declared: DeclaredGeometry::Rows { rows: 9000 },
min_bytes: 1125,
have_bytes: 40,
};
assert_eq!(e.refusal_key(), Some("image/evidence/ccitt"));
assert_eq!(ImageCodecError::Cancelled.refusal_key(), None);Trait Implementations§
Source§impl Clone for ImageCodecError
impl Clone for ImageCodecError
Source§impl Debug for ImageCodecError
impl Debug for ImageCodecError
Source§impl Display for ImageCodecError
impl Display for ImageCodecError
impl Eq for ImageCodecError
Source§impl Error for ImageCodecError
impl Error for ImageCodecError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()