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