1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
use serde::{Deserialize, Serialize};
/// This object represents a phone contact.
/// # Documentation
/// <https://core.telegram.org/bots/api#contact>
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Contact {
/// Contact's phone number
pub phone_number: Box<str>,
/// Contact's first name
pub first_name: Box<str>,
/// Contact's last name
#[serde(skip_serializing_if = "Option::is_none")]
pub last_name: Option<Box<str>>,
/// Contact's user identifier in Telegram. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<i64>,
/// Additional data about the contact in the form of a vCard
#[serde(skip_serializing_if = "Option::is_none")]
pub vcard: Option<Box<str>>,
}
impl Contact {
/// Creates a new `Contact`.
///
/// # Arguments
/// * `phone_number` - Contact's phone number
/// * `first_name` - Contact's first name
///
/// # Notes
/// Use builder methods to set optional fields.
#[must_use]
pub fn new<T0: Into<Box<str>>, T1: Into<Box<str>>>(phone_number: T0, first_name: T1) -> Self {
Self {
phone_number: phone_number.into(),
first_name: first_name.into(),
last_name: None,
user_id: None,
vcard: None,
}
}
/// Contact's phone number
#[must_use]
pub fn phone_number<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.phone_number = val.into();
this
}
/// Contact's first name
#[must_use]
pub fn first_name<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.first_name = val.into();
this
}
/// Contact's last name
#[must_use]
pub fn last_name<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.last_name = Some(val.into());
this
}
/// Contact's last name
#[must_use]
pub fn last_name_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.last_name = val.map(Into::into);
this
}
/// Contact's user identifier in Telegram. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
#[must_use]
pub fn user_id<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.user_id = Some(val.into());
this
}
/// Contact's user identifier in Telegram. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
#[must_use]
pub fn user_id_option<T: Into<i64>>(self, val: Option<T>) -> Self {
let mut this = self;
this.user_id = val.map(Into::into);
this
}
/// Additional data about the contact in the form of a vCard
#[must_use]
pub fn vcard<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.vcard = Some(val.into());
this
}
/// Additional data about the contact in the form of a vCard
#[must_use]
pub fn vcard_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.vcard = val.map(Into::into);
this
}
}