Enum Attribute

Source
#[repr(u16)]
pub enum Attribute {
Show 13 variants Bold = 1, Dim = 2, Italic = 4, Underline = 8, Blink = 16, Blink2 = 32, Reverse = 64, Conceal = 128, Strike = 256, Underline2 = 512, Frame = 1_024, Encircle = 2_048, Overline = 4_096,
}
Expand description

Individual effects that can be applied to text in a terminal.

Attribute values can be combined with bitwise operators to produce AttributeSets.

Attribute values can be parsed from the following case-insensitive strings:

  • "bold" or "b"Bold
  • "dim" or "d"Dim
  • "italic" or "i"Italic
  • "underline" or "u"Underline
  • "blink"Blink
  • "blink2"Blink2
  • "reverse" or "r"Reverse
  • "conceal" or "c"Conceal
  • "strike" or "s"Strike
  • "underline2" or "uu"Underline2
  • "frame"Frame
  • "encircle"Encircle
  • "overline"Overline

Attribute values are displayed as lowercase strings from the above list; for values with two strings, the longer one is used.

Variants§

§

Bold = 1

§

Dim = 2

§

Italic = 4

§

Underline = 8

§

Blink2 = 32

Fast blinking

§

Reverse = 64

Reverse video

§

Conceal = 128

Concealed/hidden

§

Strike = 256

Strikethrough

§

Underline2 = 512

Double-underline

§

Frame = 1_024

§

Encircle = 2_048

§

Overline = 4_096

Implementations§

Source§

impl Attribute

Source

pub fn iter() -> AttributeIter

Returns an iterator over all Attribute variants

Source

pub fn as_str(self) -> &'static str

Return the long name of the attribute

§Example
use parse_style::Attribute;

assert_eq!(Attribute::Bold.as_str(), "bold");

Trait Implementations§

Source§

impl<A: Into<AttributeSet>> BitAnd<A> for Attribute

Source§

type Output = AttributeSet

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: A) -> AttributeSet

Performs the & operation. Read more
Source§

impl<A: Into<AttributeSet>> BitOr<A> for Attribute

Source§

type Output = AttributeSet

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: A) -> AttributeSet

Performs the | operation. Read more
Source§

impl<A: Into<AttributeSet>> BitXor<A> for Attribute

Source§

type Output = AttributeSet

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: A) -> AttributeSet

Performs the ^ operation. Read more
Source§

impl Clone for Attribute

Source§

fn clone(&self) -> Attribute

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Attribute

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for Attribute

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Extend<Attribute> for AttributeSet

Source§

fn extend<I: IntoIterator<Item = Attribute>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<Attribute> for AttributeSet

Source§

fn from(value: Attribute) -> AttributeSet

Converts to this type from the input type.
Source§

impl From<Attribute> for Style

Source§

fn from(value: Attribute) -> Style

Construct a new Style that enables the given attribute

Source§

impl FromIterator<Attribute> for AttributeSet

Source§

fn from_iter<I: IntoIterator<Item = Attribute>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl FromStr for Attribute

Source§

type Err = ParseAttributeError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Attribute, ParseAttributeError>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Attribute

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoEnumIterator for Attribute

Source§

impl Not for Attribute

Source§

type Output = AttributeSet

The resulting type after applying the ! operator.
Source§

fn not(self) -> AttributeSet

Performs the unary ! operation. Read more
Source§

impl Ord for Attribute

Source§

fn cmp(&self, other: &Attribute) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Attribute

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Attribute

Source§

fn partial_cmp(&self, other: &Attribute) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<A: Into<AttributeSet>> Sub<A> for Attribute

Source§

type Output = AttributeSet

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: A) -> AttributeSet

Performs the - operation. Read more
Source§

impl Copy for Attribute

Source§

impl Eq for Attribute

Source§

impl StructuralPartialEq for Attribute

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToLine for T
where T: Display,

Source§

fn to_line(&self) -> Line<'_>

Converts the value to a Line.
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSpan for T
where T: Display,

Source§

fn to_span(&self) -> Span<'_>

Converts the value to a Span.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToText for T
where T: Display,

Source§

fn to_text(&self) -> Text<'_>

Converts the value to a Text.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.