Skip to main content

JpegError

Enum JpegError 

Source
#[non_exhaustive]
pub enum JpegError {
Show 39 variants Truncated { offset: usize, expected: usize, }, InvalidMarker { offset: usize, marker: u8, }, UnexpectedMarker { offset: usize, expected: MarkerKind, found: u8, }, MissingMarker { marker: MarkerKind, }, DuplicateMarker { offset: usize, marker: MarkerKind, }, InvalidSegmentLength { offset: usize, marker: u8, length: u16, }, ConflictingDuplicateTable { offset: usize, table: TableKind, id: u8, }, ExpectedDimensionsRequired { offset: usize, }, ConflictingExpectedDimensions { offset: usize, expected: (u16, u16), actual: (u16, u16), }, InvalidJpegAssembly { offset: usize, reason: &'static str, }, ConflictingDri { offset: usize, existing: u16, new: u16, }, UnsupportedSof { marker: u8, reason: UnsupportedReason, }, UnsupportedComponentCount { count: u8, }, UnsupportedColorSpace { color_space: ColorSpace, }, UnsupportedBitDepth { depth: u8, }, UnsupportedPredictor { predictor: u8, }, ZeroDimension { width: u16, height: u16, }, DimensionOverflow { width: u32, height: u32, }, InvalidSampling { component: u8, h: u8, v: u8, }, MissingQuantTable { component: u8, table_id: u8, }, MissingHuffmanTable { component: u8, class: u8, id: u8, }, InvalidScanParameters { offset: usize, ss: u8, se: u8, ah: u8, al: u8, }, UnknownScanComponent { offset: usize, component: u8, }, DuplicateScanComponent { offset: usize, component: u8, }, InvalidSequentialComponentSet { offset: usize, expected: u8, found: u8, }, InvalidSequentialScanCount { sof: SofKind, count: u16, }, HuffmanDecode { mcu: u32, reason: HuffmanFailure, }, RestartMismatch { offset: usize, expected: u8, found: u8, }, UnexpectedEoi { mcu_at: u32, mcu_total: u32, }, CoefficientOverflow { mcu: u32, component: u8, }, MemoryCapExceeded { requested: usize, cap: usize, }, OutputBufferTooSmall { required: usize, provided: usize, }, InvalidStride { stride: usize, row: usize, }, RectOutOfBounds { rect: Rect, width: u32, height: u32, }, DownscaleUnsupported { sof: SofKind, }, ScanFragmentsOverlap { mcu: u32, }, BuilderConflict { reason: BuilderConflictReason, }, NotImplemented { sof: SofKind, }, RowSinkAborted,
}
Expand description

Fatal JPEG decode or API error.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Truncated

Input ended before the requested bytes could be read.

Fields

§offset: usize

Byte offset where decoding stopped.

§expected: usize

Additional byte count required.

§

InvalidMarker

Marker byte is not legal in the current JPEG position.

Fields

§offset: usize

Byte offset of the marker.

§marker: u8

Raw marker byte following 0xff.

§

UnexpectedMarker

A different marker kind was required at this position.

Fields

§offset: usize

Byte offset of the unexpected marker.

§expected: MarkerKind

Marker kind expected by the parser.

§found: u8

Raw marker byte that was found.

§

MissingMarker

Required marker was absent from the stream.

Fields

§marker: MarkerKind

Missing marker kind.

§

DuplicateMarker

A marker appeared more than once where only one is legal.

Fields

§offset: usize

Byte offset of the duplicate marker.

§marker: MarkerKind

Duplicated marker kind.

§

InvalidSegmentLength

Marker segment length is invalid for the marker kind.

Fields

§offset: usize

Byte offset of the segment.

§marker: u8

Raw marker byte following 0xff.

§length: u16

Declared segment length.

§

ConflictingDuplicateTable

Duplicate DQT/DHT table has different bytes from an earlier definition.

Fields

§offset: usize

Byte offset of the conflicting table segment.

§table: TableKind

Table class.

§id: u8

Table id.

§

ExpectedDimensionsRequired

TIFF/NDPI metadata did not provide dimensions needed to repair a zero SOF.

Fields

§offset: usize

Byte offset of the SOF marker.

§

ConflictingExpectedDimensions

Container-provided dimensions conflict with non-zero SOF dimensions.

Fields

§offset: usize

Byte offset of the SOF marker.

§expected: (u16, u16)

Expected dimensions supplied by the caller.

§actual: (u16, u16)

Dimensions declared by the SOF marker.

§

InvalidJpegAssembly

TIFF/JPEGTables assembly cannot produce a valid JPEG interchange stream.

Fields

§offset: usize

Byte offset of the assembly problem.

§reason: &'static str

Static diagnostic reason.

§

ConflictingDri

Duplicate DRI marker conflicts with an earlier DRI value.

Fields

§offset: usize

Byte offset of the conflicting DRI segment.

§existing: u16

Existing non-zero restart interval.

§new: u16

New non-zero restart interval.

§

UnsupportedSof

Unsupported SOF variant. Carries the raw marker byte (e.g. 0xC9 for arithmetic extended-sequential) so callers routing to a fallback decoder can distinguish FFC5 from FFC9 without relying on reason. SOF marker class is outside the decoder’s supported JPEG subset.

Fields

§marker: u8

Raw SOF marker byte.

§reason: UnsupportedReason

Unsupported feature category.

§

UnsupportedComponentCount

Component count is outside the supported range.

Fields

§count: u8

Declared component count.

§

UnsupportedColorSpace

Color space cannot be produced by the requested decode path.

Fields

§color_space: ColorSpace

Header-derived color space.

§

UnsupportedBitDepth

Sample precision is not supported by this decoder path.

Fields

§depth: u8

Declared sample precision in bits.

§

UnsupportedPredictor

Lossless predictor selection is unsupported.

Fields

§predictor: u8

Predictor value from the scan header.

§

ZeroDimension

SOF declares a zero width or height.

Fields

§width: u16

Declared width.

§height: u16

Declared height.

§

DimensionOverflow

Dimensions exceed this crate’s safe decode bounds.

Fields

§width: u32

Declared width.

§height: u32

Declared height.

§

InvalidSampling

Component sampling factors are outside the JPEG legal range.

Fields

§component: u8

Component id.

§h: u8

Horizontal sampling factor.

§v: u8

Vertical sampling factor.

§

MissingQuantTable

Component references a quantization table that was not defined.

Fields

§component: u8

Component id.

§table_id: u8

Referenced quantization table id.

§

MissingHuffmanTable

Scan references a Huffman table that was not defined.

Fields

§component: u8

Component id.

§class: u8

Huffman table class.

§id: u8

Huffman table id.

§

InvalidScanParameters

Scan spectral selection or approximation parameters are invalid.

Fields

§offset: usize

Byte offset of the scan header.

§ss: u8

Start of spectral selection.

§se: u8

End of spectral selection.

§ah: u8

Successive approximation high bit.

§al: u8

Successive approximation low bit.

§

UnknownScanComponent

Scan references a component id not declared in the SOF.

Fields

§offset: usize

Byte offset of the scan header.

§component: u8

Unknown component id.

§

DuplicateScanComponent

Scan lists the same component more than once.

Fields

§offset: usize

Byte offset of the scan header.

§component: u8

Duplicated component id.

§

InvalidSequentialComponentSet

Sequential scan does not contain the expected component set.

Fields

§offset: usize

Byte offset of the scan header.

§expected: u8

Expected component count.

§found: u8

Found component count.

§

InvalidSequentialScanCount

Sequential SOF contained an invalid number of scans.

Fields

§sof: SofKind

SOF kind being decoded.

§count: u16

Observed scan count.

§

HuffmanDecode

Huffman entropy decoding failed. mcu is the current MCU when the caller has MCU progress, or 0 for table/bitstream contexts that do not track image position.

Fields

§mcu: u32

Current MCU index, or 0 when the decoder context has no MCU index.

§reason: HuffmanFailure

Failure category.

§

RestartMismatch

Restart marker sequence did not match the expected RST index.

Fields

§offset: usize

Byte offset of the marker.

§expected: u8

Expected RST index.

§found: u8

Found raw marker byte.

§

UnexpectedEoi

EOI was reached before all MCUs were decoded.

Fields

§mcu_at: u32

MCU index where EOI was found.

§mcu_total: u32

Total MCU count expected for the image.

§

CoefficientOverflow

Decoded coefficient exceeded the representable range.

Fields

§mcu: u32

MCU index.

§component: u8

Component index.

§

MemoryCapExceeded

Requested decode allocation exceeds the configured memory cap.

Fields

§requested: usize

Requested byte count.

§cap: usize

Configured byte cap.

§

OutputBufferTooSmall

Caller-provided output buffer is too small.

Fields

§required: usize

Required byte count.

§provided: usize

Provided byte count.

§

InvalidStride

Output stride is smaller than the decoded row size.

Fields

§stride: usize

Caller-provided stride.

§row: usize

Minimum row byte count.

§

RectOutOfBounds

Requested decode rectangle is outside image bounds.

Fields

§rect: Rect

Requested rectangle.

§width: u32

Image width in pixels.

§height: u32

Image height in pixels.

§

DownscaleUnsupported

Requested downscale is not supported for the SOF kind.

Fields

§sof: SofKind

SOF kind being decoded.

§

ScanFragmentsOverlap

Builder-provided scan fragments overlap in MCU space.

Fields

§mcu: u32

First overlapping MCU index.

§

BuilderConflict

Decoder builder inputs conflict.

Fields

§reason: BuilderConflictReason

Conflict category.

§

NotImplemented

Transient pre-1.0 gap: the SOF is parseable and may eventually be supported by the decoder, but the current release does not implement the requested shape yet. Distinct from UnsupportedSof because callers routing to a fallback decoder on is_unsupported() should NOT reroute streams that a newer version of j2k will decode natively.

Fields

§sof: SofKind

SOF kind awaiting implementation.

§

RowSinkAborted

Row sink returned an error and aborted row-based decoding.

Implementations§

Source§

impl JpegError

Source

pub fn is_unsupported(&self) -> bool

True if the error is recoverable by routing to a different decoder — any Unsupported* variant.

Source

pub fn is_truncated(&self) -> bool

True if the input was truncated — caller may retry with more bytes.

Source

pub fn is_api_misuse(&self) -> bool

True if the error indicates caller misuse, not a decode failure.

Source

pub fn is_not_implemented(&self) -> bool

True if the error is a transient “not yet implemented” gap — the stream is valid and will decode on a future j2k release, so callers should not reroute to a different decoder permanently. See Self::is_unsupported for errors that are permanent routing decisions.

Source

pub fn offset(&self) -> Option<usize>

Byte offset where the error was detected in the input stream, if any.

Trait Implementations§

Source§

impl Clone for JpegError

Source§

fn clone(&self) -> JpegError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CodecError for JpegError

Source§

fn is_truncated(&self) -> bool

True when the error indicates truncated input.
Source§

fn is_not_implemented(&self) -> bool

True when the error indicates an unimplemented supported surface.
Source§

fn is_unsupported(&self) -> bool

True when the error indicates unsupported input or options.
Source§

fn is_buffer_error(&self) -> bool

True when the error indicates caller buffer sizing or layout problems.
Source§

impl Debug for JpegError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for JpegError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for JpegError

Source§

impl Error for JpegError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<JpegError> for FastPacketError

Source§

fn from(value: JpegError) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for JpegError

Source§

fn eq(&self, other: &JpegError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for JpegError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.