Struct Style
pub struct Style { /* private fields */ }
A stored style that can be applied.
Implementations
impl Style
const fn new() -> SelfReturns an empty default style.
fn from_dotted_str(s: &str) -> SelfCreates 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_bluewill create a string that is red on blue background.9.on_12is 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) -> SelfForces styling on or off.
This overrides the automatic detection.
const fn for_stderr(self) -> SelfSpecifies that style is applying to something being written on stderr.
const fn for_stdout(self) -> SelfSpecifies that style is applying to something being written on stdout.
This is the default behaviour.
const fn fg(self, color: Color) -> SelfSets a foreground color.
const fn bg(self, color: Color) -> SelfSets a background color.
const fn attr(self, attr: Attribute) -> SelfAdds a attr.
const fn black(self) -> Selfconst fn red(self) -> Selfconst fn green(self) -> Selfconst fn yellow(self) -> Selfconst fn blue(self) -> Selfconst fn magenta(self) -> Selfconst fn cyan(self) -> Selfconst fn white(self) -> Selfconst fn color256(self, color: u8) -> Selfconst fn true_color(self, r: u8, g: u8, b: u8) -> Selfconst fn bright(self) -> Selfconst fn on_black(self) -> Selfconst fn on_red(self) -> Selfconst fn on_green(self) -> Selfconst fn on_yellow(self) -> Selfconst fn on_blue(self) -> Selfconst fn on_magenta(self) -> Selfconst fn on_cyan(self) -> Selfconst fn on_white(self) -> Selfconst fn on_color256(self, color: u8) -> Selfconst fn on_true_color(self, r: u8, g: u8, b: u8) -> Selfconst fn on_bright(self) -> Selfconst fn bold(self) -> Selfconst fn dim(self) -> Selfconst fn italic(self) -> Selfconst fn underlined(self) -> Selfconst fn blink(self) -> Selfconst fn blink_fast(self) -> Selfconst fn reverse(self) -> Selfconst 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) -> 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, 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>