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.
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.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<DecodingError> for Error
Available on crate feature png only.
impl From<DecodingError> for Error
png only.Source§fn from(err: DecodingError) -> Self
fn from(err: DecodingError) -> Self
Source§impl From<DecodingError> for Error
Available on crate feature gif only.
impl From<DecodingError> for Error
gif only.Source§fn from(err: DecodingError) -> Self
fn from(err: DecodingError) -> Self
Source§impl From<EncodingError> for Error
Available on crate feature png only.
impl From<EncodingError> for Error
png only.Source§fn from(err: EncodingError) -> Self
fn from(err: EncodingError) -> Self
Source§impl From<EncodingError> for Error
Available on crate feature jpeg only.
impl From<EncodingError> for Error
jpeg only.Source§fn from(err: EncodingError) -> Self
fn from(err: EncodingError) -> Self
Source§impl From<EncodingError> for Error
Available on crate feature gif only.
impl From<EncodingError> for Error
gif only.Source§fn from(err: EncodingError) -> Self
fn from(err: EncodingError) -> Self
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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