openrtb_native1/response/data.rs
1/// 5.5 Data Response Object
2///
3/// Corresponds to the Data Object in the request, with the value filled in. The Data Object is to
4/// be used for all miscellaneous elements of the native unit such as Brand Name, Ratings, Review
5/// Count, Stars, Downloads, Price count etc. It is also generic for future native elements not
6/// contemplated at the time of the writing of this document.
7#[derive(serde::Serialize, serde::Deserialize, Default, Debug, PartialEq, Clone)]
8pub struct Data {
9 /// optional; integer; -
10 /// Required for assetsurl/dcourl responses, not required for embedded asset responses. The
11 /// type of data element being submitted from the Data Asset Types table.
12 #[serde(default, skip_serializing_if = "Option::is_none")]
13 pub r#type: Option<crate::DataAssetType>,
14
15 /// optional; integer; -
16 /// Required for assetsurl/dcourl responses, not required for embedded asset responses. The
17 /// length of the data element being submitted. Where applicable, must comply with the
18 /// recommended maximum lengths in the Data Asset Types table.
19 #[serde(default, skip_serializing_if = "Option::is_none")]
20 pub len: Option<i32>,
21
22 /// required; string; -
23 /// The formatted string of data to be displayed. Can contain a formatted value such as “5
24 /// stars” or “$10” or “3.4 stars out of 5”.
25 pub value: String,
26
27 /// optional; object; -
28 /// This object is a placeholder that may contain custom JSON agreed to by the parties to
29 /// support flexibility beyond the standard defined in this specification.
30 #[serde(default, skip_serializing_if = "Option::is_none")]
31 pub ext: Option<serde_json::Map<String, serde_json::Value>>,
32}
33
34#[cfg(test)]
35mod test {
36 use super::*;
37
38 #[test]
39 fn json() -> serde_json::Result<()> {
40 let json = r#"{"value":""}"#;
41 let o1 = Data::default();
42 assert_eq!(serde_json::to_string(&o1)?, json);
43 assert_eq!(o1, serde_json::from_str::<Data>(json)?);
44
45 Ok(())
46 }
47}