Error

Enum Error 

Source
pub enum Error {
    InvalidHexCode(String),
    InvalidPaletteIndex,
    InvalidExtension(OsString),
    EncodingError(String),
    DecodingError(String),
    FontError(&'static str),
    UnknownEncodingFormat,
    IncompatibleImageData {
        width: u32,
        height: u32,
        received: usize,
    },
    UnsupportedColorType,
    IoError(Error),
    EmptyImageError,
    QuantizationOverflow {
        unique_colors: usize,
        palette_size: usize,
    },
}
Expand description

Represents an error that occurs within the crate.

Variants§

§

InvalidHexCode(String)

An invalid hex code was provided when trying to parse a hex value.

§

InvalidPaletteIndex

Received an invalid palette index.

§

InvalidExtension(OsString)

An invalid extension was provided when trying to resolve an image’s encoding format from a file extension.

§Note

This is not an error that occurs when the file extension is not recognized, or is an unknown image extension. This occurs if the OsStr fails conversion to a native &str. In the case of this, [ImageFormat::Unknown] is used instead.

§

EncodingError(String)

Failed to encode an image.

§

DecodingError(String)

Invalid data was encountered when an image, usually because it is corrupted.

Errors can differ across encodings, so the inner &'static str here is nothing more than an error message.

§

FontError(&'static str)

An error occured while trying to render or rasterize a font.

§

UnknownEncodingFormat

No encoding format could be inferred for the given image.

§

IncompatibleImageData

An image received data incompatible with the image’s dimensions.

Fields

§width: u32
§height: u32
§received: usize
§

UnsupportedColorType

Received an unsupported color type when trying to create a pixel from raw data.

This occurs when the color type is not supported by the pixel type. This is almost always fixed by switching the pixel type to [Dynamic] then using [Image::convert] to convert the image into your desired type.

§

IoError(Error)

An error occured when trying to read a file or when trying to write to a file.

§

EmptyImageError

Tried to encode an empty image, or an image without data. This is also raised when trying to encode an image sequence with no frames.

§

QuantizationOverflow

Attempted lossless quantization, but there are more unique colors than the desired palette size.

Fields

§unique_colors: usize

The amount of unique colors in the image.

§palette_size: usize

The desired palette size.

Trait Implementations§

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

1.30.0§

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

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

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0§

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

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
§

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<DecodingError> for Error

Available on crate feature png only.
Source§

fn from(err: DecodingError) -> Self

Converts to this type from the input type.
Source§

impl From<DecodingError> for Error

Available on crate feature gif only.
Source§

fn from(err: DecodingError) -> Self

Converts to this type from the input type.
Source§

impl From<EncodingError> for Error

Available on crate feature png only.
Source§

fn from(err: EncodingError) -> Self

Converts to this type from the input type.
Source§

impl From<EncodingError> for Error

Available on crate feature jpeg only.
Source§

fn from(err: EncodingError) -> Self

Converts to this type from the input type.
Source§

impl From<EncodingError> for Error

Available on crate feature gif only.
Source§

fn from(err: EncodingError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Available on crate feature jpeg only.
Source§

fn from(err: Error) -> Self

Converts to this type from the input type.

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§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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
§

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

§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.