pub enum AnsiColor {
None,
Default,
Dark(AnsiColor3),
Bright(AnsiColor3),
Palette(AnsiColor8),
Rgb([u8; 3]),
}Available on crate feature
term only.Expand description
๐ฎ ๐จ Complete ANSI color selection
๐ sys/os/term
๐ฆ size_of::<AnsiColor>() == 4 bytes / 32 bits
โ๏ธOption<T>
Covers all terminal color modes:
- no color / default
- 3-bit (dark / bright)
- 8-bit palette (256 colors)
- 24-bit truecolor (RGB)
Variantsยง
None
No color (explicitly unset).
Default
Terminal default color.
Dark(AnsiColor3)
Standard 3-bit colors (ANSI dark set).
Bright(AnsiColor3)
Bright 3-bit colors (ANSI bright set).
Palette(AnsiColor8)
8-bit indexed color (ANSI 256 colors).
Rgb([u8; 3])
24-bit true color RGB.
Implementationsยง
Sourceยงimpl AnsiColor
ยงConversions
impl AnsiColor
ยงConversions
Sourcepub const fn is_none(self) -> bool
pub const fn is_none(self) -> bool
Returns true if this is AnsiColor::None.
Sourcepub const fn is_default(self) -> bool
pub const fn is_default(self) -> bool
Returns true if this is AnsiColor::Default.
Sourcepub const fn is_palette(self) -> bool
pub const fn is_palette(self) -> bool
Returns true if this is an 8-bit ANSI palette color.
Alias of Self::is_8.
Sourcepub const fn into_3(self) -> Option<AnsiColor3> โ
pub const fn into_3(self) -> Option<AnsiColor3> โ
Extracts the 3-bit color if present.
Returns None for non-3-bit variants.
Sourcepub const fn into_8(self) -> Option<AnsiColor8> โ
pub const fn into_8(self) -> Option<AnsiColor8> โ
Extracts the 8-bit palette color if present.
Returns None for non-palette variants.
Sourceยงimpl AnsiColor
ยงColor constants
impl AnsiColor
ยงColor constants
pub const Black: Self
pub const Red: Self
pub const Green: Self
pub const Yellow: Self
pub const Blue: Self
pub const Magenta: Self
pub const Cyan: Self
pub const White: Self
pub const BlackBright: Self
pub const RedBright: Self
pub const GreenBright: Self
pub const YellowBright: Self
pub const BlueBright: Self
pub const MagentaBright: Self
pub const CyanBright: Self
pub const WhiteBright: Self
pub const K: Self = Self::Black
pub const R: Self = Self::Red
pub const G: Self = Self::Green
pub const Y: Self = Self::Yellow
pub const B: Self = Self::Blue
pub const M: Self = Self::Magenta
pub const C: Self = Self::Cyan
pub const W: Self = Self::White
pub const KB: Self = Self::BlackBright
pub const RB: Self = Self::RedBright
pub const GB: Self = Self::GreenBright
pub const YB: Self = Self::YellowBright
pub const BB: Self = Self::BlueBright
pub const MB: Self = Self::MagentaBright
pub const CB: Self = Self::CyanBright
pub const WB: Self = Self::WhiteBright
Trait Implementationsยง
Sourceยงimpl BitSized<24> for AnsiColor
impl BitSized<24> for AnsiColor
Sourceยงconst BIT_SIZE: usize = _
const BIT_SIZE: usize = _
The bit size of this type (only the relevant data part, without padding). Read more
Sourceยงconst MIN_BYTE_SIZE: usize = _
const MIN_BYTE_SIZE: usize = _
The rounded up byte size for this type. Read more
Sourceยงfn bit_size(&self) -> usize
fn bit_size(&self) -> usize
Returns the bit size of this type (only the relevant data part, without padding). Read more
Sourceยงfn min_byte_size(&self) -> usize
fn min_byte_size(&self) -> usize
Returns the rounded up byte size for this type. Read more
impl Copy for AnsiColor
impl Eq for AnsiColor
Sourceยงimpl PartialEq for AnsiColor
impl PartialEq for AnsiColor
impl StructuralPartialEq for AnsiColor
Auto Trait Implementationsยง
impl Freeze for AnsiColor
impl RefUnwindSafe for AnsiColor
impl Send for AnsiColor
impl Sync for AnsiColor
impl Unpin for AnsiColor
impl UnsafeUnpin for AnsiColor
impl UnwindSafe for AnsiColor
Blanket Implementationsยง
Sourceยงimpl<T> AnyExt for T
impl<T> AnyExt for T
Sourceยงfn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
Returns a deterministic hash of the
TypeId of Self using a custom hasher.Sourceยงfn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Sourceยงfn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
Available on crate feature
alloc only.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> ByteSized for T
impl<T> ByteSized for T
Sourceยงconst BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
The alignment of this type in bytes.
Sourceยงfn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Returns the alignment of this type in bytes.
Sourceยงfn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
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<T> MemExt for Twhere
T: ?Sized,
impl<T> MemExt for Twhere
T: ?Sized,
Sourceยงconst NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Know whether dropping values of this type matters, in compile-time.
Sourceยงfn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Returns the minimum alignment of the type in bytes. Read more
Sourceยงfn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Returns the alignment of the pointed-to value in bytes. Read more
Sourceยงfn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Returns the size of a type in bytes. Read more
Sourceยงfn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Returns the size of the pointed-to value in bytes. Read more
Sourceยงfn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
Returns
true if dropping values of this type matters. Read moreSourceยงfn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
Forgets about
self without running its destructor. Read moreSourceยงfn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Sourceยงunsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
Available on crate feature
unsafe_layout only.Returns the value of type
T represented by the all-zero byte-pattern. Read moreSourceยงunsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
Available on crate feature
unsafe_layout only.Returns the value of type
T represented by the all-zero byte-pattern. Read moreSourceยงfn mem_as_bytes(&self) -> &[u8] โ
fn mem_as_bytes(&self) -> &[u8] โ
Available on crate feature
unsafe_slice only.