openrtb_native1/
placement_type.rs

1/// 7.3 Placement Type IDs
2///
3/// The FORMAT of the ad you are purchasing, separate from the surrounding context
4#[derive(Debug, PartialEq, Eq, Clone, Copy)]
5pub enum PlacementType {
6    /// In the feed of content - for example as an item inside the organic
7    /// feed/grid/listing/carousel.
8    InFeed,
9    /// In the atomic unit of the content - IE in the article page or single image page.
10    AtomicUnit,
11    /// Outside the core content - for example in the ads section on the right rail, as a
12    /// banner-style placement near the content, etc.
13    Outside,
14    /// Recommendation widget, most commonly presented below the article content.
15    Recommendation,
16    /// To be defined by the exchange
17    ExchangeSpecific(i32),
18}
19
20crate::impl_enum_serde!(
21    #[exchange(ident = ExchangeSpecific, greater = 500)]
22    PlacementType {
23        InFeed = 1,
24        AtomicUnit = 2,
25        Outside = 3,
26        Recommendation = 4,
27    }
28);
29
30#[cfg(test)]
31mod test {
32    use super::*;
33
34    #[test]
35    fn json() -> serde_json::Result<()> {
36        assert!(serde_json::from_str::<PlacementType>("0").is_err());
37        assert!(serde_json::from_str::<PlacementType>("500").is_err());
38
39        let json = "[1,2,501]";
40        let e1: Vec<PlacementType> = serde_json::from_str(json)?;
41        assert_eq!(serde_json::to_string(&e1)?, json);
42        assert_eq!(
43            e1,
44            vec![
45                PlacementType::InFeed,
46                PlacementType::AtomicUnit,
47                PlacementType::ExchangeSpecific(501),
48            ]
49        );
50
51        Ok(())
52    }
53}