openrtb_native1/image_asset_type.rs
1#![allow(deprecated)]
2/// 7.5 Image Asset Types
3///
4/// Below is a list of common image asset element types of native advertising at the time of writing
5/// this spec. This list is non-exhaustive and intended to be extended by the buyers and sellers as
6/// the format evolves.
7///
8/// An implementing exchange may not support all asset variants or may introduce new ones unique to
9/// that system.
10///
11/// In order to facilitate adoption, recommendations are made for both minimum sizes and aspect
12/// ratios. We speak here of 'minimum maximum height' or ‘max height of at least’, which means the
13/// SSP should support a max height of at least this value. They are free to support larger, but the
14/// DSP knows that if they have an image of this size it will be accepted. Note that SSPs will be
15/// responsible for sizing image to exact size if min-max- height framework is used; exact size may
16/// not be available at bid request time. Width is calculated from the 3 supported aspect ratios.
17/// Note we merged the prior overlapping type 1 and type 2 as just type 1 - to be used for app icon,
18/// brand logo, or similar.
19#[derive(Debug, PartialEq, Eq, Clone, Copy)]
20pub enum ImageAssetType {
21 /// Icon image.
22 /// optional; -; -; max height: at least 50, aspect ratio: 1:1
23 Icon,
24 /// Logo image for the brand/app.
25 #[deprecated = "Please use the Icon variant instead"]
26 Logo,
27 /// Large image preview for the ad.
28 /// At least one of 2 size variants required:
29 /// Small Variant: max height: 200+, max width: 200+, 267, or 382,
30 /// aspect ratio: 1:1, 4:3, or 1.91:1.
31 /// Large Variant: max height: 627+, max width: 627+, 836, or 1198,
32 /// aspect ratio: 1:1, 4:3, or 1.91:1.
33 Main,
34 /// Reserved for Exchange specific usage numbered above 500
35 ExchangeSpecific(i32),
36}
37
38crate::impl_enum_serde!(
39 #[exchange(ident = ExchangeSpecific, greater = 500)]
40 ImageAssetType {
41 Icon = 1,
42 Logo = 2,
43 Main = 3,
44 }
45);
46
47#[cfg(test)]
48mod test {
49 use super::*;
50
51 #[test]
52 fn json() -> serde_json::Result<()> {
53 assert!(serde_json::from_str::<ImageAssetType>("0").is_err());
54 assert!(serde_json::from_str::<ImageAssetType>("500").is_err());
55
56 let json = "[1,2,501]";
57 let e1: Vec<ImageAssetType> = serde_json::from_str(json)?;
58 assert_eq!(serde_json::to_string(&e1)?, json);
59 assert_eq!(
60 e1,
61 vec![
62 ImageAssetType::Icon,
63 ImageAssetType::Logo,
64 ImageAssetType::ExchangeSpecific(501),
65 ]
66 );
67
68 Ok(())
69 }
70}