Add setters to UserProfilePhotos

This commit is contained in:
Temirkhan Myrzamadi 2020-07-28 20:32:09 +06:00
parent 8cd9d582aa
commit abaff16949

View file

@ -14,3 +14,27 @@ pub struct UserProfilePhotos {
/// Requested profile pictures (in up to 4 sizes each).
pub photos: Vec<Vec<PhotoSize>>,
}
impl UserProfilePhotos {
pub fn new<P1, P2>(total_count: u32, photos: P1) -> Self
where
P1: Into<Vec<P2>>,
P2: Into<Vec<PhotoSize>>,
{
Self { total_count, photos: photos.into().into_iter().map(Into::into).collect() }
}
pub fn total_count(mut self, val: u32) -> Self {
self.total_count = val;
self
}
pub fn photos<P1, P2>(mut self, val: P1) -> Self
where
P1: Into<Vec<P2>>,
P2: Into<Vec<PhotoSize>>,
{
self.photos = val.into().into_iter().map(Into::into).collect();
self
}
}