Struct Style

pub struct Style { /* private fields */ }

A stored style that can be applied.

Implementations

impl Style

const fn new() -> Self

Returns an empty default style.

fn from_dotted_str(s: &str) -> Self

Creates a style from a dotted string.

Effectively the string is split at each dot and then the terms in between are applied. For instance red.on_blue will create a string that is red on blue background. 9.on_12 is the same, but using 256 color numbers. Unknown terms are ignored.

fn apply_to<D>(&self, val: D) -> StyledObject<D>

Apply the style to something that can be displayed.

const fn force_styling(self, value: bool) -> Self

Forces styling on or off.

This overrides the automatic detection.

const fn for_stderr(self) -> Self

Specifies that style is applying to something being written on stderr.

const fn for_stdout(self) -> Self

Specifies that style is applying to something being written on stdout.

This is the default behaviour.

const fn fg(self, color: Color) -> Self

Sets a foreground color.

const fn bg(self, color: Color) -> Self

Sets a background color.

const fn attr(self, attr: Attribute) -> Self

Adds a attr.

const fn black(self) -> Self
const fn red(self) -> Self
const fn green(self) -> Self
const fn yellow(self) -> Self
const fn blue(self) -> Self
const fn magenta(self) -> Self
const fn cyan(self) -> Self
const fn white(self) -> Self
const fn color256(self, color: u8) -> Self
const fn true_color(self, r: u8, g: u8, b: u8) -> Self
const fn bright(self) -> Self
const fn on_black(self) -> Self
const fn on_red(self) -> Self
const fn on_green(self) -> Self
const fn on_yellow(self) -> Self
const fn on_blue(self) -> Self
const fn on_magenta(self) -> Self
const fn on_cyan(self) -> Self
const fn on_white(self) -> Self
const fn on_color256(self, color: u8) -> Self
const fn on_true_color(self, r: u8, g: u8, b: u8) -> Self
const fn on_bright(self) -> Self
const fn bold(self) -> Self
const fn dim(self) -> Self
const fn italic(self) -> Self
const fn underlined(self) -> Self
const fn reverse(self) -> Self
const fn hidden(self) -> Self
const fn strikethrough(self) -> Self

Trait Implementations

impl Clone for Style

fn clone(&self) -> Self

impl Debug for Style

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl Default for Style

fn default() -> Self

impl Eq for Style

impl PartialEq for Style

fn eq(&self, other: &Self) -> bool

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

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) -> T

Returns the argument unchanged.

impl<T> ToOwned for Style where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Style where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses 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>