kolorz 1.1.0

A silly little library for printing kolored text to the terminal
Documentation
use std::fmt;

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UnknownKolorSchemeError {
    name: String,
}

impl UnknownKolorSchemeError {
    pub fn new(name: impl Into<String>) -> Self {
        Self { name: name.into() }
    }

    pub fn name(&self) -> &str {
        &self.name
    }
}

impl fmt::Display for UnknownKolorSchemeError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "unknown kolor scheme: '{}'", self.name)
    }
}

impl std::error::Error for UnknownKolorSchemeError {}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct InvalidColorNumberError {
    number: usize,
}

impl InvalidColorNumberError {
    pub const MAX_COLOR_NUMBER: usize = 6;

    pub fn new(number: usize) -> Self {
        Self { number }
    }

    pub fn number(&self) -> usize {
        self.number
    }
}

impl fmt::Display for InvalidColorNumberError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(
            f,
            "invalid color number: {} (must be 0-{})",
            self.number,
            Self::MAX_COLOR_NUMBER
        )
    }
}

impl std::error::Error for InvalidColorNumberError {}