mirror of
https://github.com/teloxide/teloxide.git
synced 2024-10-24 09:57:18 +02:00
Add setters to Contact
This commit is contained in:
parent
bf8617da31
commit
2733cb561a
1 changed files with 52 additions and 0 deletions
|
@ -24,3 +24,55 @@ pub struct Contact {
|
|||
/// [vCard]: https://en.wikipedia.org/wiki/VCard
|
||||
pub vcard: Option<String>,
|
||||
}
|
||||
|
||||
impl Contact {
|
||||
pub fn new<S1, S2>(phone_number: S1, first_name: S2) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
phone_number: phone_number.into(),
|
||||
first_name: first_name.into(),
|
||||
last_name: None,
|
||||
user_id: None,
|
||||
vcard: None,
|
||||
}
|
||||
}
|
||||
pub fn phone_number<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.phone_number = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn first_name<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.first_name = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn last_name<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.last_name = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn user_id(mut self, val: i32) -> Self {
|
||||
self.user_id = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn vcard<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.vcard = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue