#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
#[xml(tag = "Icons", strict(unknown_attribute, unknown_element))]
pub struct Icons<'a> {
#[xml(child = "Icon")]
pub icons: Vec<Icon<'a>>,
}
#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
#[xml(tag = "Icon", strict(unknown_attribute, unknown_element))]
pub struct Icon<'a> {
#[xml(attr = "program", default)]
pub program: Option<std::borrow::Cow<'a, str>>,
#[xml(attr = "width", default)]
pub width: Option<i32>,
#[xml(attr = "height", default)]
pub height: Option<i32>,
#[xml(attr = "xPosition", default)]
pub x_position: Option<XPosition>,
#[xml(attr = "yPosition", default)]
pub y_position: Option<YPosition>,
#[xml(attr = "duration", default)]
pub duration: Option<crate::Duration>,
#[xml(attr = "offset", default)]
pub offset: Option<crate::Duration>,
#[xml(attr = "apiFramework", default)]
pub api_framework: Option<std::borrow::Cow<'a, str>>,
#[xml(attr = "pxratio", default)]
pub pxratio: Option<f32>,
#[xml(flatten_text = "HTMLResource", cdata, default)]
pub html_resources: Vec<std::borrow::Cow<'a, str>>,
#[xml(flatten_text = "IFrameResource", cdata, default)]
pub iframe_resources: Vec<std::borrow::Cow<'a, str>>,
#[xml(child = "StaticResource", default)]
pub static_resources: Vec<crate::StaticResource<'a>>,
#[xml(child = "IconClicks", default)]
pub icon_clicks: Option<IconClicks<'a>>,
#[xml(flatten_text = "IconViewTracking", cdata, default)]
pub icon_view_trackings: Vec<std::borrow::Cow<'a, str>>,
}
#[derive(PartialEq, Clone, Copy, Debug)]
pub enum XPosition {
Coordinate(i32),
Left,
Right,
}
impl std::str::FromStr for XPosition {
type Err = crate::VastParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"left" => Self::Left,
"right" => Self::Right,
_ => match s.parse::<i32>() {
Ok(x) => Self::Coordinate(x),
Err(_) => {
return Err(crate::VastParseError::new(format!(
"x position parsing error: '{s}'",
)));
}
},
})
}
}
impl std::fmt::Display for XPosition {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
XPosition::Coordinate(x) => write!(f, "{x}"),
XPosition::Left => write!(f, "left"),
XPosition::Right => write!(f, "right"),
}
}
}
#[derive(PartialEq, Clone, Copy, Debug)]
pub enum YPosition {
Coordinate(i32),
Top,
Bottom,
}
impl std::str::FromStr for YPosition {
type Err = crate::VastParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"top" => Self::Top,
"buttom" => Self::Bottom,
_ => match s.parse::<i32>() {
Ok(y) => Self::Coordinate(y),
Err(_) => {
return Err(crate::VastParseError::new(format!(
"y position parsing error: '{s}'",
)));
}
},
})
}
}
impl std::fmt::Display for YPosition {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
YPosition::Coordinate(y) => write!(f, "{y}"),
YPosition::Top => write!(f, "top"),
YPosition::Bottom => write!(f, "bottom"),
}
}
}
#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
#[xml(tag = "IconClicks", strict(unknown_attribute, unknown_element))]
pub struct IconClicks<'a> {
#[xml(child = "IconClickFallbackImages", default)]
pub icon_click_fallback_images: Option<IconClickFallbackImages<'a>>,
#[xml(flatten_text = "IconClickThrough", cdata, default)]
pub icon_click_through: Option<std::borrow::Cow<'a, str>>,
#[xml(child = "IconClickTracking", default)]
pub icon_click_trackings: Vec<IconClickTracking<'a>>,
}
#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
#[xml(tag = "IconClickTracking", strict(unknown_attribute, unknown_element))]
pub struct IconClickTracking<'a> {
#[xml(attr = "id", default)]
pub id: 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 = "IconClickFallbackImages", strict(unknown_attribute, unknown_element))]
pub struct IconClickFallbackImages<'a> {
#[xml(child = "IconClickFallbackImage")]
pub icon_click_fallback_images: Vec<IconClickFallbackImage<'a>>,
}
#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
#[xml(tag = "IconClickFallbackImage", strict(unknown_attribute, unknown_element))]
pub struct IconClickFallbackImage<'a> {
#[xml(attr = "height", default)]
pub height: Option<i32>,
#[xml(attr = "width", default)]
pub width: Option<i32>,
#[xml(flatten_text = "AltText", default)]
pub alt_text: Option<std::borrow::Cow<'a, str>>,
#[xml(flatten_text = "StaticResource", cdata, default)]
pub static_resource: Option<std::borrow::Cow<'a, str>>,
}