pub struct Color { /* private fields */ }Expand description
Full set of named ANSI colors. Use Color::name_to_index() to look up.
A terminal color.
Can be one of: default (inherit), a standard ANSI name, an 8-bit palette index, or a 24-bit true-color RGB triple.
Implementations§
Source§impl Color
impl Color
Sourcepub fn from_ansi_name(name: &str) -> Option<Self>
pub fn from_ansi_name(name: &str) -> Option<Self>
Create from an ANSI standard name (e.g. “red”, “bright_blue”).
Sourcepub fn from_hex(hex: &str) -> Result<Self, ColorParseError>
pub fn from_hex(hex: &str) -> Result<Self, ColorParseError>
Create from a hex string like “#ff0000” or “ff0000”.
Sourcepub fn parse(s: &str) -> Result<Self, ColorParseError>
pub fn parse(s: &str) -> Result<Self, ColorParseError>
Parse a color from a string (name, hex, or “default”).
Sourcepub fn is_default(&self) -> bool
pub fn is_default(&self) -> bool
Is this the default/inherit color?
Sourcepub fn get_truecolor(&self, theme: &TerminalTheme) -> (u8, u8, u8)
pub fn get_truecolor(&self, theme: &TerminalTheme) -> (u8, u8, u8)
Get the RGB triplet if available (computes it for named/8-bit colors by looking up the palette).
Sourcepub fn downgrade(&self, system: ColorSystem) -> Self
pub fn downgrade(&self, system: ColorSystem) -> Self
Downgrade this color to the given color system.
Trait Implementations§
impl Copy for Color
impl Eq for Color
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.