Skip to main content

RichText

Enum RichText 

Source
pub enum RichText {
Show 27 variants Plain(String), Array(Vec<RichText>), Bold(Box<RichTextBold>), Italic(Box<RichTextItalic>), Underline(Box<RichTextUnderline>), Strikethrough(Box<RichTextStrikethrough>), Spoiler(Box<RichTextSpoiler>), DateTime(Box<RichTextDateTime>), TextMention(Box<RichTextTextMention>), Subscript(Box<RichTextSubscript>), Superscript(Box<RichTextSuperscript>), Marked(Box<RichTextMarked>), Code(Box<RichTextCode>), CustomEmoji(Box<RichTextCustomEmoji>), MathematicalExpression(Box<RichTextMathematicalExpression>), Url(Box<RichTextUrl>), EmailAddress(Box<RichTextEmailAddress>), PhoneNumber(Box<RichTextPhoneNumber>), BankCardNumber(Box<RichTextBankCardNumber>), Mention(Box<RichTextMention>), Hashtag(Box<RichTextHashtag>), Cashtag(Box<RichTextCashtag>), BotCommand(Box<RichTextBotCommand>), Anchor(Box<RichTextAnchor>), AnchorLink(Box<RichTextAnchorLink>), Footnote(Box<RichTextFootnote>), Reference(Box<RichTextReference>),
}
Expand description

Rich formatted text — a recursive sum type that mirrors the Telegram RichText union from Bot API 10.1.

A RichText value is either:

  • a plain String (leaf node),
  • an Array of nested RichText values, or
  • one of the typed inline-formatting variants listed below.

Variants§

§

Plain(String)

Plain text without any formatting.

§

Array(Vec<RichText>)

A sequence of rich-text nodes rendered consecutively.

§

Bold(Box<RichTextBold>)

Bold formatting.

§

Italic(Box<RichTextItalic>)

Italic formatting.

§

Underline(Box<RichTextUnderline>)

Underline formatting.

§

Strikethrough(Box<RichTextStrikethrough>)

Strikethrough formatting.

§

Spoiler(Box<RichTextSpoiler>)

Spoiler — text hidden until tapped.

§

DateTime(Box<RichTextDateTime>)

A date/time entity.

§

TextMention(Box<RichTextTextMention>)

A mention by user object.

§

Subscript(Box<RichTextSubscript>)

Subscript text.

§

Superscript(Box<RichTextSuperscript>)

Superscript text.

§

Marked(Box<RichTextMarked>)

Highlighted/marked text.

§

Code(Box<RichTextCode>)

Inline monospace code.

§

CustomEmoji(Box<RichTextCustomEmoji>)

A custom emoji.

§

MathematicalExpression(Box<RichTextMathematicalExpression>)

An inline LaTeX mathematical expression.

§

Url(Box<RichTextUrl>)

A hyperlink.

§

EmailAddress(Box<RichTextEmailAddress>)

An e-mail address link.

§

PhoneNumber(Box<RichTextPhoneNumber>)

A telephone number link.

§

BankCardNumber(Box<RichTextBankCardNumber>)

A bank card number.

§

Mention(Box<RichTextMention>)

A @username mention.

§

Hashtag(Box<RichTextHashtag>)

A #hashtag.

§

Cashtag(Box<RichTextCashtag>)

A $cashtag.

§

BotCommand(Box<RichTextBotCommand>)

A /bot_command.

§

Anchor(Box<RichTextAnchor>)

An in-document anchor definition.

A link targeting an in-document anchor.

§

Footnote(Box<RichTextFootnote>)

A footnote body.

§

Reference(Box<RichTextReference>)

A reference to a footnote.

Trait Implementations§

Source§

impl Clone for RichText

Source§

fn clone(&self) -> RichText

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RichText

Source§

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

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

impl<'de> Deserialize<'de> for RichText

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for RichText

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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