Skip to main content

lofty/picture/
error.rs

1//! [`Picture`] error types
2//!
3//! [`Picture`]: crate::picture::Picture
4
5use std::borrow::Cow;
6
7use lofty_attr::LoftyError;
8
9/// Unable to parse a [`Picture`]
10///
11/// [`Picture`]: crate::picture::Picture
12#[derive(LoftyError)]
13#[error(message = "failed to parse picture")]
14pub struct PictureParseError {
15	#[error(from(
16		std::io::Error,
17		crate::error::NotEnoughDataError,
18		crate::error::SizeMismatchError,
19		crate::error::AllocationError,
20		crate::util::text::TextDecodingError,
21		UnknownImageFormatError,
22		data_encoding::DecodeError,
23	))]
24	source: Box<dyn core::error::Error + Send + Sync + 'static>,
25}
26
27impl PictureParseError {
28	pub(super) fn message(message: impl Into<Cow<'static, str>>) -> Self {
29		let message = message.into();
30		Self {
31			source: message.into(),
32		}
33	}
34}
35
36/// Unable to determine the image format
37#[derive(LoftyError)]
38#[error(message = "unable to determine image format")]
39pub struct UnknownImageFormatError;