pub struct Style { /* private fields */ }Expand description
A terminal style defining text effects and foreground/background colors.
When the color feature is enabled, this is backed by anstyle::Style
which renders zero-allocation ANSI escape codes. When disabled, this is a
zero-cost no-op type that emits nothing.
Implementations§
Source§impl Style
impl Style
Sourcepub const fn fg_rgb(self, r: u8, g: u8, b: u8) -> Self
pub const fn fg_rgb(self, r: u8, g: u8, b: u8) -> Self
Set 24-bit Truecolor (RGB) foreground color.
Sourcepub const fn fg_ansi256(self, code: u8) -> Self
pub const fn fg_ansi256(self, code: u8) -> Self
Set 8-bit ANSI 256-color palette foreground color.
Sourcepub const fn fg_ansi(self, color: AnsiColor) -> Self
pub const fn fg_ansi(self, color: AnsiColor) -> Self
Set 4-bit standard ANSI 16-color foreground color.
Sourcepub fn render_reset(&self) -> impl Display
pub fn render_reset(&self) -> impl Display
Render the ANSI sequence to reset styles.
Sourcepub fn to_ansi256(self) -> Self
pub fn to_ansi256(self) -> Self
Convert this style’s colors to ANSI 256 colors.
Sourcepub fn to_monochrome(self) -> Self
pub fn to_monochrome(self) -> Self
Strip all foreground/background colors, preserving effects like Bold and Dimmed.
Trait Implementations§
impl Copy for Style
impl Eq for Style
impl StructuralPartialEq for Style
Auto Trait Implementations§
impl Freeze for Style
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnsafeUnpin for Style
impl UnwindSafe for Style
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