Error

Struct Error 

Source
pub struct Error { /* private fields */ }
Expand description

Errors that can occur during JPEG encoding/decoding.

Use Error::kind() to match on the specific error variant.

Implementations§

Source§

impl Error

Source

pub fn new(kind: ErrorKind) -> Self

Create a new error with the given kind, capturing the current location.

Source

pub const fn new_untraced(kind: ErrorKind) -> Self

Create a new error without capturing a trace (for hot paths).

Source

pub fn kind(&self) -> &ErrorKind

Get the kind of error.

Source

pub fn into_kind(self) -> ErrorKind

Convert into the error kind, discarding the trace.

Source

pub fn invalid_dimensions(width: u32, height: u32, reason: &'static str) -> Self

Create an invalid dimensions error.

Source

pub fn invalid_color_format(reason: &'static str) -> Self

Create an invalid color format error.

Source

pub fn invalid_buffer_size(expected: usize, actual: usize) -> Self

Create an invalid buffer size error.

Source

pub fn unsupported_feature(feature: &'static str) -> Self

Create an unsupported feature error.

Source

pub fn unsupported_pixel_format(format: PixelFormat) -> Self

Create an unsupported pixel format error.

Source

pub fn allocation_failed(bytes: usize, context: &'static str) -> Self

Create an allocation failed error.

Source

pub fn size_overflow(context: &'static str) -> Self

Create a size overflow error.

Source

pub fn image_too_large(pixels: u64, limit: u64) -> Self

Create an image too large error.

Source

pub fn io_error(reason: String) -> Self

Create an I/O error.

Source

pub fn icc_error(reason: String) -> Self

Create an ICC error.

Source

pub fn internal(reason: &'static str) -> Self

Create an internal error.

Source

pub fn cancelled() -> Self

Create a cancelled error.

Source

pub fn invalid_jpeg_data(reason: &'static str) -> Self

Create an invalid JPEG data error.

Source

pub fn truncated_data(context: &'static str) -> Self

Create a truncated data error.

Source

pub fn invalid_marker(marker: u8, context: &'static str) -> Self

Create an invalid marker error.

Source

pub fn invalid_huffman_table(table_idx: u8, reason: &'static str) -> Self

Create an invalid Huffman table error.

Source

pub fn invalid_quant_table(table_idx: u8, reason: &'static str) -> Self

Create an invalid quantization table error.

Source

pub fn too_many_scans(count: usize, limit: usize) -> Self

Create a too many scans error.

Source

pub fn decode_error(reason: String) -> Self

Create a decode error.

Source

pub fn invalid_quality(value: f32, valid_range: &'static str) -> Self

Create an invalid quality error.

Source

pub fn invalid_scan_script(reason: String) -> Self

Create an invalid scan script error.

Source

pub fn invalid_config(reason: String) -> Self

Create an invalid config error.

Source

pub fn stride_too_small(width: u32, stride: usize) -> Self

Create a stride too small error.

Source

pub fn too_many_rows(height: u32, pushed: u32) -> Self

Create a too many rows error.

Source

pub fn incomplete_image(height: u32, pushed: u32) -> Self

Create an incomplete image error.

Trait Implementations§

Source§

impl AtTraceable for Error

Source§

fn trace_mut(&mut self) -> &mut AtTrace

Get a mutable reference to the embedded trace.
Source§

fn trace(&self) -> Option<&AtTrace>

Get an immutable reference to the trace, if allocated. Read more
Source§

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

Format just the error message (without trace). Read more
Source§

fn at(self) -> Self

Add the caller’s location to the trace.
Source§

fn at_str(self, msg: &'static str) -> Self

Add a static string context to the last location (or create one if empty).
Source§

fn at_string(self, f: impl FnOnce() -> String) -> Self

Add a lazily-computed string context to the last location (or create one if empty).
Source§

fn at_data<T>(self, f: impl FnOnce() -> T) -> Self
where T: Display + Send + Sync + 'static,

Add lazily-computed typed context (Display) to the last location (or create one if empty).
Source§

fn at_debug<T>(self, f: impl FnOnce() -> T) -> Self
where T: Debug + Send + Sync + 'static,

Add lazily-computed typed context (Debug) to the last location (or create one if empty).
Source§

fn at_error<E>(self, err: E) -> Self
where E: Error + Send + Sync + 'static,

Add an error as context to the last location (or create one if empty). Read more
Source§

fn at_crate(self, info: &'static AtCrateInfo) -> Self

Add a crate boundary marker to the last location (or create one if empty). Read more
Source§

fn at_fn<F>(self, _marker: F) -> Self
where F: Fn(),

Add a location frame with the caller’s function name as context. Read more
Source§

fn at_named(self, name: &'static str) -> Self

Add a location frame with an explicit name as context. Read more
Source§

fn at_pop(&mut self) -> Option<AtFrameOwned>

Pop the most recent location and its contexts from the trace.
Source§

fn at_push(&mut self, segment: AtFrameOwned)

Push a segment (location + contexts) to the end of the trace.
Source§

fn at_first_pop(&mut self) -> Option<AtFrameOwned>

Pop the oldest location and its contexts from the trace.
Source§

fn at_first_insert(&mut self, segment: AtFrameOwned)

Insert a segment (location + contexts) at the beginning of the trace.
Source§

fn map_traceable<E2, F>(self, f: F) -> E2
where F: FnOnce(Self) -> E2, E2: AtTraceable,

Convert to another AtTraceable type, transferring the trace. Read more
Source§

fn into_at<E2, F>(self, f: F) -> At<E2>
where F: FnOnce(Self) -> E2,

Convert to At<E2>, transferring the trace.
Source§

fn full_trace(&self) -> impl Display

Format with full trace (message + all frames with contexts). Read more
Source§

fn last_error_trace(&self) -> impl Display

Format with trace locations only (message + locations, no context strings). Read more
Source§

fn last_error(&self) -> impl Display

Format just the error message (no trace). Read more
Source§

impl Clone for Error

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

Available on crate feature std only.
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<Error> for Error

Available on crate feature std only.
Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<StopReason> for Error

Source§

fn from(_: StopReason) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Error

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe for Error

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<E> ErrorAtExt for E
where E: Error,

Source§

fn start_at(self) -> At<E>

Wrap this value in At<E> and add the caller’s location. If allocation fails, the error is still wrapped but trace may be empty. 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> 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.