pub enum Color {
}
Variants§
Reset
Black
Red
Green
Yellow
Blue
Magenta
Cyan
Gray
DarkGray
LightRed
LightGreen
LightYellow
LightBlue
LightMagenta
LightCyan
White
Rgb(u8, u8, u8)
Indexed(u8)
Trait Implementations§
source§impl<'de> Deserialize<'de> for Color
impl<'de> Deserialize<'de> for Color
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<Color> for ColorAttribute
impl From<Color> for ColorAttribute
source§fn from(color: Color) -> ColorAttribute
fn from(color: Color) -> ColorAttribute
Converts to this type from the input type.
source§impl FromStr for Color
impl FromStr for Color
Converts a string representation to a Color
instance.
The from_str
function attempts to parse the given string and convert it
to the corresponding Color
variant. It supports named colors, RGB values,
and indexed colors. If the string cannot be parsed, a ParseColorError
is returned.
Examples
let color: Color = Color::from_str("blue").unwrap();
assert_eq!(color, Color::Blue);
let color: Color = Color::from_str("#FF0000").unwrap();
assert_eq!(color, Color::Rgb(255, 0, 0));
let color: Color = Color::from_str("10").unwrap();
assert_eq!(color, Color::Indexed(10));
let color: Result<Color, _> = Color::from_str("invalid_color");
assert!(color.is_err());
source§impl PartialEq<Color> for Color
impl PartialEq<Color> for Color
impl Copy for Color
impl Eq for Color
impl StructuralEq for Color
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more