Add setters to Audio

This commit is contained in:
Temirkhan Myrzamadi 2020-07-27 14:10:56 +06:00
parent ecae850fda
commit c5b0bb93ca

View file

@ -37,6 +37,77 @@ pub struct Audio {
pub thumb: Option<PhotoSize>, pub thumb: Option<PhotoSize>,
} }
impl Audio {
pub fn new<S1, S2>(file_id: S1, file_unique_id: S2, duration: u32) -> Self
where
S1: Into<String>,
S2: Into<String>,
{
Self {
file_id: file_id.into(),
file_unique_id: file_unique_id.into(),
duration,
performer: None,
title: None,
mime_type: None,
file_size: None,
thumb: 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 duration(mut self, val: u32) -> Self {
self.duration = val;
self
}
pub fn performer<S>(mut self, val: S) -> Self
where
S: Into<String>,
{
self.performer = Some(val.into());
self
}
pub fn title<S>(mut self, val: S) -> Self
where
S: Into<String>,
{
self.title = Some(val.into());
self
}
pub fn mime_type(mut self, val: MimeWrapper) -> Self {
self.mime_type = Some(val);
self
}
pub fn file_size(mut self, val: u32) -> Self {
self.file_size = Some(val);
self
}
pub fn thumb(mut self, val: PhotoSize) -> Self {
self.thumb = Some(val);
self
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;