Struct ControlFunction

Source
pub struct ControlFunction<'a> { /* private fields */ }
Expand description

An ansi control function defined in ECMA-48.

This struct implements the PartialEq trait for String-like types (all types that implement AsRef<str>). It can be used to compare ControlFunctions with string-like values using == or != functions.

Example:

use ansi_control_codes::c0;

let some_string = String::from("\u{001B}");
if (c0::ESC == some_string) {
    println!("ESC!")
}

Implementations§

Source§

impl<'a> ControlFunction<'a>

Source

pub fn private_use( value: &'a str, parameters: Vec<String>, ) -> Result<Self, InvalidControlFunction>

Creates a new control function representing a control sequence that is declared as private use.

These functions are not standardized and their function is unknown. Yet, the standard allows these functions to exist for experimental use.

If the specified value lies outside of the valid private use area, this function will return Err.

Trait Implementations§

Source§

impl<'a> Debug for ControlFunction<'a>

Source§

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

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

impl<'a> Display for ControlFunction<'a>

Source§

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

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

impl Explain for ControlFunction<'_>

Source§

fn short_name(&self) -> Option<&'static str>

Returns the short name (abbreviation) of this control function, e.g. CR, LF. Read more
Source§

fn long_name(&self) -> &'static str

Returns the name of this control function, e.g. Carriage Return, Line Feed.
Source§

fn short_description(&self) -> String

Returns the short description of what this function does.
Source§

fn long_description(&self) -> String

Returns a long description of what this function does. Read more
Source§

impl<'a> From<ControlFunction<'a>> for String

Source§

fn from(control_function: ControlFunction<'_>) -> Self

Converts to this type from the input type.
Source§

impl<'a> PartialEq<ControlFunction<'a>> for &str

Source§

fn eq(&self, other: &ControlFunction<'_>) -> bool

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

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<'a> PartialEq<ControlFunction<'a>> for String

Source§

fn eq(&self, other: &ControlFunction<'_>) -> bool

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

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<'a, T> PartialEq<T> for ControlFunction<'a>
where T: AsRef<str>,

Source§

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

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

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<'a> PartialEq for ControlFunction<'a>

Source§

fn eq(&self, other: &ControlFunction<'a>) -> bool

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

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<'a> Eq for ControlFunction<'a>

Source§

impl<'a> StructuralPartialEq for ControlFunction<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for ControlFunction<'a>

§

impl<'a> RefUnwindSafe for ControlFunction<'a>

§

impl<'a> Send for ControlFunction<'a>

§

impl<'a> Sync for ControlFunction<'a>

§

impl<'a> Unpin for ControlFunction<'a>

§

impl<'a> UnwindSafe for ControlFunction<'a>

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> 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> 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, 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.