vast4_rs/
verification.rs

1/// The AdVerification element is used to initiate a controlled container where code can be executed
2/// for collecting data to verify ad playback details.
3///
4/// ```text
5/// <xs:complexType name="AdVerifications" >
6///   <xs:sequence>
7///     <xs:element name="Verification" minOccurs="0" maxOccurs="unbounded" type="vast:Verification_type" />
8///   </xs:sequence>
9/// </xs:complexType>
10/// ```
11#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
12#[xml(tag = "AdVerifications")]
13pub struct AdVerifications<'a> {
14    /// The container for zero or more [`<Verification>`](Verification) elements.
15    #[xml(child = "Verification", default)]
16    pub verifications: Vec<Verification<'a>>,
17}
18
19/// The `<Verification>` element contains the executable and bootstrapping data required to
20/// run the measurement code for a single verification vendor.
21///
22/// ```text
23/// <xs:complexType name="Verification">
24///   <xs:attribute name="vendor" type="xs:string" use="optional">
25///   <xs:sequence>
26///     <xs:element name="ExecutableResource" minOccurs="0" maxOccurs="unbounded">
27///     <xs:element name="JavaScriptResource" minOccurs="0" maxOccurs="unbounded">
28///     <xs:element name="TrackingEvents" minOccurs="0" maxOccurs="1" type="vast:TrackingEvents_Verification_type" />
29///     <xs:element name="VerificationParameters" minOccurs="0" maxOccurs="1" type="xs:string">
30///   </xs:sequence>
31/// </xs:complexType>
32/// ```
33#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
34#[xml(tag = "Verification")]
35pub struct Verification<'a> {
36    // https://github.com/InteractiveAdvertisingBureau/vast/blob/f28dbb4768744062fcb638a1859364cdafb3a449/vast_4.2.xsd#L1136
37    /// An identifier for the verification vendor. The recommended format is `[domain]-[useCase]`,
38    /// to avoid name collisions. For example, "company.com-omid".
39    #[xml(attr = "vendor", default)]
40    pub vendor: Option<std::borrow::Cow<'a, str>>,
41
42    /// The container for zero or more [`<ExecutableResource>`](ExecutableResource) elements.
43    #[xml(child = "ExecutableResource", default)]
44    pub executable_resources: Vec<ExecutableResource<'a>>,
45    /// The container for zero or more [`<JavaScriptResource>`](JavaScriptResource) elements.
46    #[xml(child = "JavaScriptResource", default)]
47    pub javascript_resources: Vec<JavaScriptResource<'a>>,
48    /// The container for zero or one [`<TrackingEvents>`](VerificationTrackingEvents) element.
49    #[xml(child = "TrackingEvents", default)]
50    pub tracking_events: Option<VerificationTrackingEvents<'a>>,
51    /// The container for zero or one `<VerificationParameters>` element.
52    #[xml(flatten_text = "VerificationParameters", cdata, default)]
53    pub verification_parameters: Option<std::borrow::Cow<'a, str>>,
54}
55
56/// A container for the URI to the JavaScript file used to collect verification data.
57///
58/// ```text
59/// <xs:element name="JavaScriptResource">
60///   <xs:complexType>
61///     <xs:simpleContent>
62///       <xs:extension base="xs:anyURI">
63///         <xs:attribute name="apiFramework" type="xs:string" use="optional" />
64///         <xs:attribute name="browserOptional" type="xs:boolean" use="optional" />
65///       </xs:extension>
66///     </xs:simpleContent>
67///   </xs:complexType>
68/// </xs:element>
69/// ```
70#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
71#[xml(tag = "JavaScriptResource")]
72pub struct JavaScriptResource<'a> {
73    // https://github.com/InteractiveAdvertisingBureau/vast/blob/f28dbb4768744062fcb638a1859364cdafb3a449/vast_4.2.xsd#L1123
74    /// The name of the API framework used to execute the AdVerification code.
75    #[xml(attr = "apiFramework", default)]
76    pub api_framework: Option<std::borrow::Cow<'a, str>>,
77    // https://github.com/InteractiveAdvertisingBureau/vast/blob/f28dbb4768744062fcb638a1859364cdafb3a449/vast_4.2.xsd#L1124
78    /// Boolean value. If true, this resource is optimized and able to execute in an
79    /// environment without DOM and other browser built-ins (e.g. iOS' JavaScriptCore)
80    #[xml(attr = "browserOptional", default)]
81    pub browser_optional: Option<bool>,
82
83    /// A CDATA-wrapped URI to the JavaScript used to collect data.
84    #[xml(text, cdata, default)]
85    pub uri: std::borrow::Cow<'a, str>,
86}
87
88/// A reference to a non-JavaScript or custom-integration resource intended for collecting
89/// verification data via the listed apiFramework.
90///
91/// ```text
92/// <xs:element name="ExecutableResource">
93///   <xs:complexType>
94///     <xs:simpleContent>
95///       <xs:extension base="xs:anyURI">
96///         <xs:attribute name="apiFramework" type="xs:string" use="optional" />
97///         <xs:attribute name="type" type="xs:string" use="optional" />
98///       </xs:extension>
99///     </xs:simpleContent>
100///   </xs:complexType>
101/// </xs:element>
102/// ```
103#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
104#[xml(tag = "ExecutableResource")]
105pub struct ExecutableResource<'a> {
106    /// The name of the API framework used to execute the AdVerification code.
107    #[xml(attr = "apiFramework", default)]
108    pub api_framework: std::borrow::Cow<'a, str>,
109    /// The type of executable resource provided. The exact value used should be agreed
110    /// upon by verification integrators and vendors who are implementing verification in
111    /// a custom environment.
112    #[xml(attr = "type", default)]
113    pub resource_type: Option<std::borrow::Cow<'a, str>>,
114
115    /// A CDATA-wrapped reference to the resource. This may be a URI, but
116    /// depending on the execution environment can be any value which enables the
117    /// player to load the required verification code.
118    #[xml(text, cdata, default)]
119    pub uri: std::borrow::Cow<'a, str>,
120}
121
122/// The verification vendor may provide URIs for tracking events relating to the execution of
123/// their code during the ad session.
124///
125/// ```text
126/// <xs:complexType name="TrackingEvents" >
127///   <xs:sequence>
128///     <xs:element name="Tracking" minOccurs="0" maxOccurs="unbounded">
129///   </xs:sequence>
130/// </xs:complexType>
131/// ```
132#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
133#[xml(tag = "TrackingEvents")]
134pub struct VerificationTrackingEvents<'a> {
135    /// The container for zero or more [`<Tracking>`](VerificationTracking) elements.
136    #[xml(child = "Tracking", default)]
137    pub trackings: Vec<VerificationTracking<'a>>,
138}
139
140/// Each `<Tracking>` element is used to define a single event to be tracked by the verification
141/// vendor.
142///
143/// ```text
144/// <xs:element name="Tracking">
145///   <xs:complexType>
146///     <xs:simpleContent>
147///       <xs:extension base="xs:anyURI">
148///         <xs:attribute name="event" type="xs:string" use="required">
149///       </xs:extension>
150///     </xs:simpleContent>
151///   </xs:complexType>
152/// </xs:element>
153/// ```
154#[derive(hard_xml::XmlWrite, hard_xml::XmlRead, Default, PartialEq, Clone, Debug)]
155#[xml(tag = "Tracking")]
156pub struct VerificationTracking<'a> {
157    /// A string that defines the event being tracked. Accepted values are listed in section
158    /// 3.17.3.
159    #[xml(attr = "event", default)]
160    pub event: std::borrow::Cow<'a, str>,
161
162    /// A URI to the tracking resource for the event specified using the event attribute.
163    #[xml(text, cdata, default)]
164    pub uri: std::borrow::Cow<'a, str>,
165}