pub enum IrcFmtByte {
    Bold,
    Italics,
    Underline,
    Strikethrough,
    Monospace,
    Colour,
    HexColour,
    ReverseColour,
    Reset,
}
Expand description

A byte that indicates formatting to apply to text.

Variants§

§

Bold

Toggle bold formatting. u8 value of 2 (byte \x02).

§

Italics

Toggle italic formatting. u8 value of 29 (byte \x1d).

§

Underline

Toggle underline formatting. u8 value of 31 (byte \x1f).

§

Strikethrough

Toggle strikethrough formatting. u8 value of 30 (byte \x1e).

§

Monospace

Toggle monospace formatting. u8 value of 17 (byte \x11).

§

Colour

Reset or apply foreground/background colours using irc colour codes. u8 value of 3 (byte \x03).

Valid colour codes are 0-99. 0-15 are usually author defined. 16-98 are specified. 99 indicates a resetting to the default colour. No colour codes after the colour byte indicates a colour reset. Background colour cannot be specified without first specifying a foreground colour followed by a comma.

§

HexColour

Reset or apply foreground/background colours using hex values. u8 value of 4 (byte \x04).

6 hexadecimal digits, 2 each representing the red, green and blue values. No colour codes after the colour byte indicates a colour reset. Background colour cannot be specified without first specifying a foreground colour followed by a comma.

§

ReverseColour

Toggle reversing the colour. u8 value of 22 (byte \x16).

§

Reset

Reset all formatting to default. u8 value of 15 (byte \x0f).

Implementations§

source§

impl IrcFmtByte

source

pub const fn contains_irc_formatting(input: &[u8]) -> bool

Checks whether the input contains an IrcFmtByte.

source

pub const fn find_nth_fmt_byte_and_position( input: &[u8], nth: usize ) -> Option<(Self, usize)>

Returns both the IrcFmtByte and the index it occurs at if present.

The nth parameter is a 0 based index.

source

pub const fn count_fmt_bytes(input: &[u8]) -> usize

Counts each IrcFmtByte in input.

The count does not contain the bytes that represent irc colour codes or hex values.

source

pub const fn split_at_first_fmt_byte( input: &[u8] ) -> Option<(OptMsgPart<'_>, Option<Self>, OptIrcColours<'_>, OptMsgPart<'_>)>

Returns message parts split both sides of the IrcFmtByte along with the byte and colours if present.

If input is empty it returns None.

Output is split into 4 parts:

1 - All bytes before the first IrcFmtByte. None if the first byte is the IrcFmtByte.

2 - The IrcFmtByte if present.

3 - The colours specified for IrcFmtByte::Colour or IrcFmtByte::HexColour if present.

4 - All bytes after the colours if present including further formatting bytes. None if the last byte is part of a colour or the IrcFmtByte.

Trait Implementations§

source§

impl Clone for IrcFmtByte

source§

fn clone(&self) -> IrcFmtByte

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for IrcFmtByte

source§

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

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

impl PartialEq for IrcFmtByte

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for IrcFmtByte

source§

impl Eq for IrcFmtByte

source§

impl StructuralPartialEq for IrcFmtByte

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.