#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
#[xml(tag = "MediaFiles", strict(unknown_attribute, unknown_element))]
pub struct MediaFiles<'a> {
#[xml(child = "ClosedCaptionFiles", default)]
pub closed_caption_files: Option<ClosedCaptionFiles<'a>>,
#[xml(child = "MediaFile")]
pub media_files: Vec<MediaFile<'a>>,
#[xml(child = "Mezzanine", default)]
pub mezzanines: Vec<Mezzanine<'a>>,
#[xml(child = "InteractiveCreativeFile", default)]
pub interactive_creative_files: Vec<InteractiveCreativeFile<'a>>,
}
#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
#[xml(tag = "MediaFile", strict(unknown_attribute, unknown_element))]
pub struct MediaFile<'a> {
#[xml(attr = "id", default)]
pub id: Option<std::borrow::Cow<'a, str>>,
#[xml(attr = "delivery")]
pub delivery: DeliveryProtocol,
#[xml(attr = "type")]
pub mime_type: std::borrow::Cow<'a, str>,
#[xml(attr = "width")]
pub width: i32,
#[xml(attr = "height")]
pub height: i32,
#[xml(attr = "codec", default)]
pub codec: Option<std::borrow::Cow<'a, str>>,
#[xml(attr = "bitrate", default)]
pub bitrate: Option<i32>,
#[xml(attr = "minBitrate", default)]
pub min_bitrate: Option<i32>,
#[xml(attr = "maxBitrate", default)]
pub max_bitrate: Option<i32>,
#[xml(attr = "scalable", default)]
pub scalable: Option<bool>,
#[xml(attr = "maintainAspectRatio", default)]
pub maintain_aspect_ratio: Option<bool>,
#[xml(attr = "fileSize", default)]
pub file_size: Option<i32>,
#[xml(attr = "mediaType", default)]
pub media_type: Option<std::borrow::Cow<'a, str>>,
#[deprecated(since = "VAST 4.1")]
#[xml(attr = "apiFramework", default)]
pub api_framework: Option<std::borrow::Cow<'a, str>>,
#[xml(text, cdata)]
pub uri: std::borrow::Cow<'a, str>,
}
#[derive(Default, PartialEq, Clone, Copy, Debug)]
pub enum DeliveryProtocol {
#[default]
Progressive,
Streaming,
}
impl std::str::FromStr for DeliveryProtocol {
type Err = crate::VastParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"progressive" => Self::Progressive,
"streaming" => Self::Streaming,
_ => {
return Err(crate::VastParseError::new(format!(
"delivery protocol parsing error: '{s}'"
)));
}
})
}
}
impl std::fmt::Display for DeliveryProtocol {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Progressive => write!(f, "progressive"),
Self::Streaming => write!(f, "streaming"),
}
}
}
#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
#[xml(tag = "Mezzanine", strict(unknown_attribute, unknown_element))]
pub struct Mezzanine<'a> {
#[xml(attr = "id", default)]
pub id: Option<std::borrow::Cow<'a, str>>,
#[xml(attr = "delivery")]
pub delivery: DeliveryProtocol,
#[xml(attr = "type")]
pub mime_type: std::borrow::Cow<'a, str>,
#[xml(attr = "width")]
pub width: i32,
#[xml(attr = "height")]
pub height: i32,
#[xml(attr = "codec", default)]
pub codec: Option<std::borrow::Cow<'a, str>>,
#[xml(attr = "fileSize", default)]
pub file_size: Option<i32>,
#[xml(attr = "mediaType", default)]
pub media_type: Option<std::borrow::Cow<'a, str>>,
#[xml(text, cdata)]
pub uri: std::borrow::Cow<'a, str>,
}
#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
#[xml(tag = "InteractiveCreativeFile", strict(unknown_attribute, unknown_element))]
pub struct InteractiveCreativeFile<'a> {
#[xml(attr = "type", default)]
pub mime_type: Option<std::borrow::Cow<'a, str>>,
#[xml(attr = "apiFramework", default)]
pub api_framework: Option<std::borrow::Cow<'a, str>>,
#[xml(attr = "variableDuration", default)]
pub variable_duration: Option<bool>,
#[xml(text, cdata)]
pub uri: std::borrow::Cow<'a, str>,
}
#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
#[xml(tag = "ClosedCaptionFiles", strict(unknown_attribute, unknown_element))]
pub struct ClosedCaptionFiles<'a> {
#[xml(child = "ClosedCaptionFile")]
pub closed_caption_files: Vec<ClosedCaptionFile<'a>>,
}
#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
#[xml(tag = "ClosedCaptionFile", strict(unknown_attribute, unknown_element))]
pub struct ClosedCaptionFile<'a> {
#[xml(attr = "type", default)]
pub mime_type: Option<std::borrow::Cow<'a, str>>,
#[xml(attr = "language", default)]
pub language: Option<std::borrow::Cow<'a, str>>,
#[xml(text, cdata)]
pub uri: std::borrow::Cow<'a, str>,
}