openrtb_native1/response/title.rs
1/// 5.3 Title Response Object
2///
3/// Corresponds to the Title Object in the request, with the value filled in.
4/// If using assetsurl or dcourl response rather than embedded asset response, it is recommended
5/// that three title objects be provided, the length of each of which is less than or equal to the
6/// three recommended maximum title lengths (25,90,140).
7#[derive(serde::Serialize, serde::Deserialize, Default, Debug, PartialEq, Clone)]
8pub struct Title {
9 /// required; string; -
10 /// The text associated with the text element.
11 pub text: String,
12
13 /// optional; integer; -
14 /// The length of the title being provided. Required if using assetsurl/dcourl representation,
15 /// optional if using embedded asset representation.
16 #[serde(default, skip_serializing_if = "Option::is_none")]
17 pub len: Option<i32>,
18
19 /// optional; object; -
20 /// This object is a placeholder that may contain custom JSON agreed to by the parties to
21 /// support flexibility beyond the standard defined in this specification.
22 #[serde(default, skip_serializing_if = "Option::is_none")]
23 pub ext: Option<serde_json::Map<String, serde_json::Value>>,
24}
25
26#[cfg(test)]
27mod test {
28 use super::*;
29
30 #[test]
31 fn json() -> serde_json::Result<()> {
32 let json = r#"{"text":""}"#;
33 let o1 = Title::default();
34 assert_eq!(serde_json::to_string(&o1)?, json);
35 assert_eq!(o1, serde_json::from_str::<Title>(json)?);
36
37 Ok(())
38 }
39}