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 for MessageEntityRef<'a>
impl<'a> PartialEq for MessageEntityRef<'a>
impl<'a> Eq for MessageEntityRef<'a>
impl<'a> StructuralPartialEq for MessageEntityRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for MessageEntityRef<'a>
impl<'a> RefUnwindSafe for MessageEntityRef<'a>
impl<'a> Send for MessageEntityRef<'a>
impl<'a> Sync for MessageEntityRef<'a>
impl<'a> Unpin for MessageEntityRef<'a>
impl<'a> UnwindSafe for MessageEntityRef<'a>
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