use std::{error::Error, fmt};
#[derive(Debug, Clone, PartialEq)]
pub struct BadBasicColor {
pub code: u8,
}
impl fmt::Display for BadBasicColor {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "Bad basic color code {}", self.code)
}
}
impl Error for BadBasicColor {}
#[derive(Debug, Clone, PartialEq)]
pub struct BadGrayColor {
pub brightness: u8,
}
impl fmt::Display for BadGrayColor {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "Bad gray color brightness {}", self.brightness)
}
}
impl Error for BadGrayColor {}
#[derive(Debug, Clone, PartialEq)]
pub struct BadCmyColor {
pub cyan: u8,
pub magenta: u8,
pub yellow: u8,
}
impl fmt::Display for BadCmyColor {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(
fmt,
"Bad CMY color, cyan={}, magenta={}, yellow={}",
self.cyan, self.magenta, self.yellow
)
}
}
impl Error for BadCmyColor {}