Add setters to Contact

This commit is contained in:
Temirkhan Myrzamadi 2020-07-27 15:42:12 +06:00
parent bf8617da31
commit 2733cb561a

View file

@ -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
}
}