Struct tg_flows::MessageEntityRef
source · pub struct MessageEntityRef<'a> { /* private fields */ }Expand description
A “parsed” MessageEntity.
MessageEntity has offsets in UTF-16 code units, but in Rust we
mostly work with UTF-8. In order to use an entity we need to convert
UTF-16 offsets to UTF-8 ones. This type represents a message entity with
converted offsets and a reference to the text.
You can get MessageEntityRefs by calling parse_entities and
parse_caption_entities methods of Message or by calling
MessageEntityRef::parse.
Implementations§
source§impl<'a> MessageEntityRef<'a>
impl<'a> MessageEntityRef<'a>
sourcepub fn kind(&self) -> &'a MessageEntityKind
pub fn kind(&self) -> &'a MessageEntityKind
Returns kind of this entity.
sourcepub fn range(&self) -> Range<usize>
pub fn range(&self) -> Range<usize>
Returns range that this entity is related to.
The range is in bytes for UTF-8 encoding i.e. you can use it with common Rust strings.
sourcepub fn start(&self) -> usize
pub fn start(&self) -> usize
Returns the offset (in bytes, for UTF-8) to the start of this entity in the original message.
sourcepub fn end(&self) -> usize
pub fn end(&self) -> usize
Returns the offset (in bytes, for UTF-8) to the end of this entity in the original message.
sourcepub fn message_text(&self) -> &'a str
pub fn message_text(&self) -> &'a str
Returns the full text of the original message.
sourcepub fn parse(text: &'a str, entities: &'a [MessageEntity]) -> Vec<Self>
pub fn parse(text: &'a str, entities: &'a [MessageEntity]) -> Vec<Self>
Parses telegram MessageEntitys converting offsets to UTF-8.
Trait Implementations§
source§impl<'a> Clone for MessageEntityRef<'a>
impl<'a> Clone for MessageEntityRef<'a>
source§fn clone(&self) -> MessageEntityRef<'a>
fn clone(&self) -> MessageEntityRef<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<'a> Debug for MessageEntityRef<'a>
impl<'a> Debug for MessageEntityRef<'a>
source§impl<'a> Hash for MessageEntityRef<'a>
impl<'a> Hash for MessageEntityRef<'a>
source§impl<'a> PartialEq<MessageEntityRef<'a>> for MessageEntityRef<'a>
impl<'a> PartialEq<MessageEntityRef<'a>> for MessageEntityRef<'a>
source§fn eq(&self, other: &MessageEntityRef<'a>) -> bool
fn eq(&self, other: &MessageEntityRef<'a>) -> bool
self and other values to be equal, and is used
by ==.