Struct Style
pub struct Style { /* private fields */ }
ANSI Text styling
You can print a Style to render the corresponding ANSI code.
Using the alternate flag # will render the ANSI reset code, if needed.
Together, this makes it convenient to render styles using inline format arguments.
Examples
let style = new.bold;
let value = 42;
println!;
Implementations
impl Style
const fn get_fg_color(self) -> Option<Color>Get the foreground color
const fn get_bg_color(self) -> Option<Color>Get the background color
const fn get_underline_color(self) -> Option<Color>const fn get_effects(self) -> Effectsconst fn is_plain(self) -> boolCheck if no styling is enabled
impl Style
const fn bold(self) -> SelfApply
boldeffectExamples
let style = new.bold;const fn dimmed(self) -> SelfApply
dimmedeffectExamples
let style = new.dimmed;const fn italic(self) -> SelfApply
italiceffectExamples
let style = new.italic;const fn underline(self) -> SelfApply
underlineeffectExamples
let style = new.underline;const fn blink(self) -> SelfApply
blinkeffectExamples
let style = new.blink;const fn invert(self) -> SelfApply
inverteffectExamples
let style = new.invert;Apply
hiddeneffectExamples
let style = new.hidden;const fn strikethrough(self) -> SelfApply
strikethrougheffectExamples
let style = new.strikethrough;
impl Style
const fn new() -> SelfNo effects enabled
Examples
let style = new;const fn fg_color(self, fg: Option<Color>) -> SelfSet foreground color
Examples
let style = new.fg_color;const fn bg_color(self, bg: Option<Color>) -> SelfSet background color
Examples
let style = new.bg_color;const fn underline_color(self, underline: Option<Color>) -> SelfSet underline color
Examples
let style = new.underline_color;const fn effects(self, effects: Effects) -> SelfSet text effects
Examples
let style = new.effects;fn render(self) -> impl Display + CopyRender the ANSI code
Stylealso implementsDisplaydirectly, so calling this method is optional.fn write_to(self, write: &mut dyn Write) -> Result<()>Write the ANSI code
fn render_reset(self) -> impl Display + CopyRenders the relevant [
Reset][crate::Reset] codeUnlike [
Reset::render][crate::Reset::render], this will elide the code if there is nothing to reset.fn write_reset_to(self, write: &mut dyn Write) -> Result<()>Write the relevant [
Reset][crate::Reset] codeUnlike [
Reset::render][crate::Reset::render], this will elide the code if there is nothing to reset.
Trait Implementations
impl BitOr<Effects> for Style
type Output = Style;fn bitor(self, rhs: Effects) -> Self
impl BitOrAssign<Effects> for Style
fn bitor_assign(&mut self, other: Effects)
impl Clone for Style
fn clone(&self) -> Self
impl Copy for Style
impl Debug for Style
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for Style
fn default() -> Self
impl Display for Style
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for Style
impl From<Effects> for Style
fn from(effects: Effects) -> Self
impl Hash for Style
fn hash<__H: Hasher>(&self, state: &mut __H)
impl Ord for Style
fn cmp(&self, other: &Self) -> Ordering
impl PartialEq for Style
fn eq(&self, other: &Self) -> bool
impl PartialEq<Effects> for Style
fn eq(&self, other: &Effects) -> bool
impl PartialOrd for Style
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
impl StructuralPartialEq for Style
impl Sub<Effects> for Style
type Output = Style;fn sub(self, other: Effects) -> Self
impl SubAssign<Effects> for Style
fn sub_assign(&mut self, other: Effects)
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
impl<T> Any for Style
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Style
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Style
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Style
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Style
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Style
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> ToString for Style
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for Style
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Style
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Style
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>