extern crate alloc;
use alloc::fmt;
use alloc::string::String;
#[derive(Debug, Clone, thiserror::Error)]
pub enum ColorError {
#[error("failed to parse ICC profile: {0}")]
ProfileParse(String),
#[error("transform requires compatible profile classes, got {src} and {dst}")]
IncompatibleProfiles {
src: String,
dst: String,
},
#[error("color component {component} out of range: {value}")]
ComponentOutOfRange {
component: &'static str,
value: f32,
},
#[error("proofing config is incomplete: {0}")]
IncompleteProofingConfig(String),
#[error("transform not built: call .build() before transforming")]
TransformNotBuilt,
#[error("transform execution failed: {0}")]
TransformExecution(String),
#[error("unsupported color space: {0}")]
UnsupportedColorSpace(String),
#[cfg(feature = "std")]
#[error("I/O error: {0}")]
Io(String),
#[error("missing profile: {0}")]
MissingProfile(String),
}
impl ColorError {
#[cfg(feature = "std")]
pub fn from_io(err: std::io::Error) -> Self {
ColorError::Io(fmt::format(format_args!("{}", err)))
}
}
pub type ColorResult<T> = Result<T, ColorError>;