material_colors/
error.rs

1use core::fmt;
2
3#[cfg(feature = "std")]
4use std::error::Error as Err;
5
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum Error {
8    /// Error returned when RGB color parsing with the [`Argb::from_str`] fails
9    ///
10    /// [`Argb::from_str`]: std::str::FromStr
11    ParseRGB,
12}
13
14impl fmt::Display for Error {
15    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16        match self {
17            Self::ParseRGB => "provided string was not RGB-like".fmt(f),
18        }
19    }
20}
21
22#[cfg(feature = "std")]
23impl Err for Error {
24    fn description(&self) -> &str {
25        match self {
26            Self::ParseRGB => "failed to parse RGB",
27        }
28    }
29}