Add setters to PhotoSize

This commit is contained in:
Temirkhan Myrzamadi 2020-07-28 15:57:32 +06:00
parent 8e9b0b2715
commit e593d4c1c7

View file

@ -26,6 +26,53 @@ pub struct PhotoSize {
pub file_size: Option<u32>,
}
impl PhotoSize {
pub fn new<S1, S2>(file_id: S1, file_unique_id: S2, width: i32, height: i32) -> Self
where
S1: Into<String>,
S2: Into<String>,
{
Self {
file_id: file_id.into(),
file_unique_id: file_unique_id.into(),
width,
height,
file_size: None,
}
}
pub fn file_id<S>(mut self, val: S) -> Self
where
S: Into<String>,
{
self.file_id = val.into();
self
}
pub fn file_unique_id<S>(mut self, val: S) -> Self
where
S: Into<String>,
{
self.file_unique_id = val.into();
self
}
pub fn width(mut self, val: i32) -> Self {
self.width = val;
self
}
pub fn height(mut self, val: i32) -> Self {
self.height = val;
self
}
pub fn file_size(mut self, val: u32) -> Self {
self.file_size = Some(val);
self
}
}
#[cfg(test)]
mod tests {
use super::*;