use super::MediaType;
#[derive(Debug, Clone)]
pub struct CT_MultiMedia {
pub id: u32,
pub media_type: MediaType,
pub format: Option<String>,
pub file: Option<String>,
}
impl CT_MultiMedia {
#[must_use]
pub fn new(id: u32, media_type: MediaType) -> Self {
Self {
id,
media_type,
format: None,
file: None,
}
}
#[must_use]
pub fn format(mut self, format: impl Into<String>) -> Self {
self.format = Some(format.into());
self
}
#[must_use]
pub fn file(mut self, file: impl Into<String>) -> Self {
self.file = Some(file.into());
self
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn ct_multi_media_new() {
let mm = CT_MultiMedia::new(1, MediaType::Image);
assert_eq!(mm.id, 1);
assert_eq!(mm.media_type, MediaType::Image);
assert!(mm.format.is_none());
}
#[test]
fn ct_multi_media_builder() {
let mm = CT_MultiMedia::new(2, MediaType::Image)
.format("PNG")
.file("image.png");
assert_eq!(mm.format.unwrap(), "PNG");
assert_eq!(mm.file.unwrap(), "image.png");
}
}