1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
/// 4.4 Image Request Object /// /// The Image object to be used for all image elements of the Native ad such as Icons, Main Image, /// etc. Recommended sizes and aspect ratios are included in the Image Asset Types section. #[derive(serde::Serialize, serde::Deserialize, Default, Debug, PartialEq, Clone)] pub struct Image<'a> { /// optional; integer; - /// Type ID of the image element supported by the publisher. The publisher can display this /// information in an appropriate format. See Table Image Asset Types. #[serde(default, skip_serializing_if = "Option::is_none")] pub r#type: Option<crate::ImageAssetType>, /// optional; integer; - /// Width of the image in pixels. #[serde(default, skip_serializing_if = "Option::is_none")] pub w: Option<i32>, /// recommended; integer; - /// The minimum requested width of the image in pixels. This option should be used for any /// rescaling of images by the client. Either w or wmin should be transmitted. If only w is /// included, it should be considered an exact requirement. #[serde(default, skip_serializing_if = "Option::is_none")] pub wmin: Option<i32>, /// optional; integer; - /// Width of the image in pixels. #[serde(default, skip_serializing_if = "Option::is_none")] pub h: Option<i32>, /// recommended; integer; - /// The minimum requested height of the image in pixels. This option should be used for any /// rescaling of images by the client. Either h or hmin should be transmitted. If only h is /// included, it should be considered an exact requirement. #[serde(default, skip_serializing_if = "Option::is_none")] pub hmin: Option<i32>, /// optional; array of string; All types allowed /// Whitelist of content MIME types supported. Popular MIME types include, but are not limited /// to “image/jpg” “image/gif”. Each implementing Exchange should have their own list of /// supported types in the integration docs. See Wikipedia's MIME page for more information and /// links to all IETF RFCs. If blank, assume all types are allowed. #[serde(borrow, default, skip_serializing_if = "Option::is_none")] pub mimes: Option<Vec<std::borrow::Cow<'a, str>>>, /// optional; object; - /// This object is a placeholder that may contain custom JSON agreed to by the parties to /// support flexibility beyond the standard defined in this specification. #[serde(borrow, default, skip_serializing_if = "Option::is_none")] pub ext: Option<json_ext::Object<'a>>, } #[cfg(test)] mod test { use super::*; #[test] fn json() -> serde_json::Result<()> { let json = r#"{}"#; let o1 = Image::default(); assert_eq!(serde_json::to_string(&o1)?, json); assert_eq!(o1, serde_json::from_str::<Image>(json)?); Ok(()) } }