pub struct User {
pub first_name: String,
pub id: UserPeerId,
pub is_bot: bool,
pub added_to_attachment_menu: Option<bool>,
pub is_premium: Option<bool>,
pub language_code: Option<String>,
pub last_name: Option<String>,
pub username: Option<UserUsername>,
}
Expand description
Represents a user.
Fields§
§first_name: String
First name of the user.
id: UserPeerId
Unique identifier of the user.
is_bot: bool
Indicates whether the user is a bot.
Indicates whether the user added the bot to the attachment menu.
Indicates whether the user is a Telegram Premium user.
language_code: Option<String>
IETF language tag of the user’s language.
last_name: Option<String>
Last name of the user.
username: Option<UserUsername>
Username of the user.
Implementations§
source§impl User
impl User
sourcepub fn new<A, B>(id: A, first_name: B, is_bot: bool) -> User
pub fn new<A, B>(id: A, first_name: B, is_bot: bool) -> User
Creates a new User
.
§Arguments
id
- Unique identifier of the user.first_name
- First name of the user.is_bot
- Indicates whether the user is a bot.
sourcepub fn get_full_name(&self) -> String
pub fn get_full_name(&self) -> String
Returns the full name of the user (first name + last name).
sourcepub fn get_link(&self) -> String
pub fn get_link(&self) -> String
Returns the link to the user (tg://user?id=xxx
).
These links will work only if they are used inside an inline link. For example, they will not work, when used in an inline keyboard button or in a message text.
sourcepub fn get_link_mention(
&self,
parse_mode: ParseMode
) -> Result<String, MentionError>
pub fn get_link_mention( &self, parse_mode: ParseMode ) -> Result<String, MentionError>
Returns the mention for the user.
§Arguments
parse_mode
- A parse mode for formatting the mention.
These mentions are only guaranteed to work if the user has contacted the bot in the past, has sent a callback query to the bot via inline button or is a member in the group where he was mentioned.
Sets a new value for an added_to_attachment_menu
flag.
§Arguments
value
- Indicates whether the user added the bot to the attachment menu.
Sets a new value for an is_premium
flag.
§Arguments
value
- Indicates whether the user is a Telegram Premium user.
sourcepub fn with_language_code<T>(self, value: T) -> User
pub fn with_language_code<T>(self, value: T) -> User
sourcepub fn with_last_name<T>(self, value: T) -> User
pub fn with_last_name<T>(self, value: T) -> User
sourcepub fn with_username<T>(self, value: T) -> Userwhere
T: Into<UserUsername>,
pub fn with_username<T>(self, value: T) -> Userwhere
T: Into<UserUsername>,
Trait Implementations§
source§impl<'de> Deserialize<'de> for User
impl<'de> Deserialize<'de> for User
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<User, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<User, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl From<User> for MessageSender
impl From<User> for MessageSender
source§fn from(value: User) -> MessageSender
fn from(value: User) -> MessageSender
source§impl From<User> for PollAnswerVoter
impl From<User> for PollAnswerVoter
source§fn from(original: User) -> PollAnswerVoter
fn from(original: User) -> PollAnswerVoter
source§impl PartialEq for User
impl PartialEq for User
source§impl PartialOrd for User
impl PartialOrd for User
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for User
impl Serialize for User
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
source§impl TryFromInput for User
impl TryFromInput for User
§type Error = Infallible
type Error = Infallible
source§async fn try_from_input(
input: HandlerInput
) -> Result<Option<Self>, Self::Error>
async fn try_from_input( input: HandlerInput ) -> Result<Option<Self>, Self::Error>
impl StructuralPartialEq for User
Auto Trait Implementations§
impl Freeze for User
impl RefUnwindSafe for User
impl Send for User
impl Sync for User
impl Unpin for User
impl UnwindSafe for User
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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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