pub struct MessageEntity {
pub kind: MessageEntityKind,
pub offset: usize,
pub length: usize,
}
Expand description
This object represents one special entity in a text message.
For example, hashtags, usernames, URLs, etc.
Fields§
§kind: MessageEntityKind
§offset: usize
Offset in UTF-16 code units to the start of the entity.
length: usize
Length of the entity in UTF-16 code units.
Implementations§
Source§impl MessageEntity
impl MessageEntity
pub const fn new(kind: MessageEntityKind, offset: usize, length: usize) -> Self
Sourcepub const fn bold(offset: usize, length: usize) -> Self
pub const fn bold(offset: usize, length: usize) -> Self
Create a message entity representing a bold text.
Sourcepub const fn italic(offset: usize, length: usize) -> Self
pub const fn italic(offset: usize, length: usize) -> Self
Create a message entity representing an italic text.
Sourcepub const fn underline(offset: usize, length: usize) -> Self
pub const fn underline(offset: usize, length: usize) -> Self
Create a message entity representing an underline text.
Sourcepub const fn strikethrough(offset: usize, length: usize) -> Self
pub const fn strikethrough(offset: usize, length: usize) -> Self
Create a message entity representing a strikethrough text.
Sourcepub const fn spoiler(offset: usize, length: usize) -> Self
pub const fn spoiler(offset: usize, length: usize) -> Self
Create a message entity representing a spoiler text.
Sourcepub const fn code(offset: usize, length: usize) -> Self
pub const fn code(offset: usize, length: usize) -> Self
Create a message entity representing a monowidth text.
Sourcepub const fn pre(language: Option<String>, offset: usize, length: usize) -> Self
pub const fn pre(language: Option<String>, offset: usize, length: usize) -> Self
Create a message entity representing a monowidth block.
Sourcepub const fn text_link(url: Url, offset: usize, length: usize) -> Self
pub const fn text_link(url: Url, offset: usize, length: usize) -> Self
Create a message entity representing a clickable text URL.
Sourcepub const fn text_mention(user: User, offset: usize, length: usize) -> Self
pub const fn text_mention(user: User, offset: usize, length: usize) -> Self
Create a message entity representing a text mention.
§Note
If you don’t have a complete User
value, please use
MessageEntity::text_mention_id
instead.
Sourcepub fn text_mention_id(user_id: UserId, offset: usize, length: usize) -> Self
pub fn text_mention_id(user_id: UserId, offset: usize, length: usize) -> Self
Create a message entity representing a text link in the form of
tg://user/?id=...
that mentions user with user_id
.
Sourcepub const fn custom_emoji(
custom_emoji_id: String,
offset: usize,
length: usize,
) -> Self
pub const fn custom_emoji( custom_emoji_id: String, offset: usize, length: usize, ) -> Self
Create a message entity representing a custom emoji.
pub fn kind(self, val: MessageEntityKind) -> Self
pub const fn offset(self, val: usize) -> Self
pub const fn length(self, val: usize) -> Self
Trait Implementations§
Source§impl Clone for MessageEntity
impl Clone for MessageEntity
Source§fn clone(&self) -> MessageEntity
fn clone(&self) -> MessageEntity
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for MessageEntity
impl Debug for MessageEntity
Source§impl<'de> Deserialize<'de> for MessageEntity
impl<'de> Deserialize<'de> for MessageEntity
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for MessageEntity
impl Hash for MessageEntity
Source§impl PartialEq for MessageEntity
impl PartialEq for MessageEntity
Source§impl Serialize for MessageEntity
impl Serialize for MessageEntity
impl Eq for MessageEntity
impl StructuralPartialEq for MessageEntity
Auto Trait Implementations§
impl Freeze for MessageEntity
impl RefUnwindSafe for MessageEntity
impl Send for MessageEntity
impl Sync for MessageEntity
impl Unpin for MessageEntity
impl UnwindSafe for MessageEntity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Erasable for T
impl<T> Erasable for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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