Skip to main content

browser_protocol/network/
mod.rs

1//! Network domain allows tracking network activities of the page. It exposes information about http,
2//! file, data and other requests and responses, their headers, bodies, timing, etc.
3
4
5use serde::{Serialize, Deserialize};
6use serde_json::Value as JsonValue;
7use std::borrow::Cow;
8
9/// Resource type as it was perceived by the rendering engine.
10
11#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
12pub enum ResourceType {
13    #[default]
14    #[serde(rename = "Document")]
15    Document,
16    #[serde(rename = "Stylesheet")]
17    Stylesheet,
18    #[serde(rename = "Image")]
19    Image,
20    #[serde(rename = "Media")]
21    Media,
22    #[serde(rename = "Font")]
23    Font,
24    #[serde(rename = "Script")]
25    Script,
26    #[serde(rename = "TextTrack")]
27    TextTrack,
28    #[serde(rename = "XHR")]
29    XHR,
30    #[serde(rename = "Fetch")]
31    Fetch,
32    #[serde(rename = "Prefetch")]
33    Prefetch,
34    #[serde(rename = "EventSource")]
35    EventSource,
36    #[serde(rename = "WebSocket")]
37    WebSocket,
38    #[serde(rename = "Manifest")]
39    Manifest,
40    #[serde(rename = "SignedExchange")]
41    SignedExchange,
42    #[serde(rename = "Ping")]
43    Ping,
44    #[serde(rename = "CSPViolationReport")]
45    CSPViolationReport,
46    #[serde(rename = "Preflight")]
47    Preflight,
48    #[serde(rename = "FedCM")]
49    FedCM,
50    #[serde(rename = "Other")]
51    Other,
52}
53
54/// Unique loader identifier.
55
56pub type LoaderId<'a> = Cow<'a, str>;
57
58/// Unique network request identifier.
59/// Note that this does not identify individual HTTP requests that are part of
60/// a network request.
61
62pub type RequestId<'a> = Cow<'a, str>;
63
64/// Unique intercepted request identifier.
65
66pub type InterceptionId<'a> = Cow<'a, str>;
67
68/// Network level fetch failure reason.
69
70#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
71pub enum ErrorReason {
72    #[default]
73    #[serde(rename = "Failed")]
74    Failed,
75    #[serde(rename = "Aborted")]
76    Aborted,
77    #[serde(rename = "TimedOut")]
78    TimedOut,
79    #[serde(rename = "AccessDenied")]
80    AccessDenied,
81    #[serde(rename = "ConnectionClosed")]
82    ConnectionClosed,
83    #[serde(rename = "ConnectionReset")]
84    ConnectionReset,
85    #[serde(rename = "ConnectionRefused")]
86    ConnectionRefused,
87    #[serde(rename = "ConnectionAborted")]
88    ConnectionAborted,
89    #[serde(rename = "ConnectionFailed")]
90    ConnectionFailed,
91    #[serde(rename = "NameNotResolved")]
92    NameNotResolved,
93    #[serde(rename = "InternetDisconnected")]
94    InternetDisconnected,
95    #[serde(rename = "AddressUnreachable")]
96    AddressUnreachable,
97    #[serde(rename = "BlockedByClient")]
98    BlockedByClient,
99    #[serde(rename = "BlockedByResponse")]
100    BlockedByResponse,
101}
102
103/// UTC time in seconds, counted from January 1, 1970.
104
105pub type TimeSinceEpoch = f64;
106
107/// Monotonically increasing time in seconds since an arbitrary point in the past.
108
109pub type MonotonicTime = f64;
110
111/// Request / response headers as keys / values of JSON object.
112
113pub type Headers = serde_json::Map<String, JsonValue>;
114
115/// The underlying connection technology that the browser is supposedly using.
116
117#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
118pub enum ConnectionType {
119    #[default]
120    #[serde(rename = "none")]
121    None,
122    #[serde(rename = "cellular2g")]
123    Cellular2g,
124    #[serde(rename = "cellular3g")]
125    Cellular3g,
126    #[serde(rename = "cellular4g")]
127    Cellular4g,
128    #[serde(rename = "bluetooth")]
129    Bluetooth,
130    #[serde(rename = "ethernet")]
131    Ethernet,
132    #[serde(rename = "wifi")]
133    Wifi,
134    #[serde(rename = "wimax")]
135    Wimax,
136    #[serde(rename = "other")]
137    Other,
138}
139
140/// Represents the cookie's 'SameSite' status:
141/// https://tools.ietf.org/html/draft-west-first-party-cookies
142
143#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
144pub enum CookieSameSite {
145    #[default]
146    #[serde(rename = "Strict")]
147    Strict,
148    #[serde(rename = "Lax")]
149    Lax,
150    #[serde(rename = "None")]
151    None,
152}
153
154/// Represents the cookie's 'Priority' status:
155/// https://tools.ietf.org/html/draft-west-cookie-priority-00
156
157#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
158pub enum CookiePriority {
159    #[default]
160    #[serde(rename = "Low")]
161    Low,
162    #[serde(rename = "Medium")]
163    Medium,
164    #[serde(rename = "High")]
165    High,
166}
167
168/// Represents the source scheme of the origin that originally set the cookie.
169/// A value of "Unset" allows protocol clients to emulate legacy cookie scope for the scheme.
170/// This is a temporary ability and it will be removed in the future.
171
172#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
173pub enum CookieSourceScheme {
174    #[default]
175    #[serde(rename = "Unset")]
176    Unset,
177    #[serde(rename = "NonSecure")]
178    NonSecure,
179    #[serde(rename = "Secure")]
180    Secure,
181}
182
183/// Timing information for the request.
184
185#[derive(Debug, Clone, Serialize, Deserialize, Default)]
186#[serde(rename_all = "camelCase")]
187pub struct ResourceTiming {
188    /// Timing's requestTime is a baseline in seconds, while the other numbers are ticks in
189    /// milliseconds relatively to this requestTime.
190    requestTime: f64,
191    /// Started resolving proxy.
192    proxyStart: f64,
193    /// Finished resolving proxy.
194    proxyEnd: f64,
195    /// Started DNS address resolve.
196    dnsStart: f64,
197    /// Finished DNS address resolve.
198    dnsEnd: f64,
199    /// Started connecting to the remote host.
200    connectStart: f64,
201    /// Connected to the remote host.
202    connectEnd: f64,
203    /// Started SSL handshake.
204    sslStart: f64,
205    /// Finished SSL handshake.
206    sslEnd: f64,
207    /// Started running ServiceWorker.
208    workerStart: f64,
209    /// Finished Starting ServiceWorker.
210    workerReady: f64,
211    /// Started fetch event.
212    workerFetchStart: f64,
213    /// Settled fetch event respondWith promise.
214    workerRespondWithSettled: f64,
215    /// Started ServiceWorker static routing source evaluation.
216    #[serde(skip_serializing_if = "Option::is_none")]
217    workerRouterEvaluationStart: Option<f64>,
218    /// Started cache lookup when the source was evaluated to 'cache'.
219    #[serde(skip_serializing_if = "Option::is_none")]
220    workerCacheLookupStart: Option<f64>,
221    /// Started sending request.
222    sendStart: f64,
223    /// Finished sending request.
224    sendEnd: f64,
225    /// Time the server started pushing request.
226    pushStart: f64,
227    /// Time the server finished pushing request.
228    pushEnd: f64,
229    /// Started receiving response headers.
230    receiveHeadersStart: f64,
231    /// Finished receiving response headers.
232    receiveHeadersEnd: f64,
233}
234
235impl ResourceTiming {
236    pub fn builder(requestTime: f64, proxyStart: f64, proxyEnd: f64, dnsStart: f64, dnsEnd: f64, connectStart: f64, connectEnd: f64, sslStart: f64, sslEnd: f64, workerStart: f64, workerReady: f64, workerFetchStart: f64, workerRespondWithSettled: f64, sendStart: f64, sendEnd: f64, pushStart: f64, pushEnd: f64, receiveHeadersStart: f64, receiveHeadersEnd: f64) -> ResourceTimingBuilder {
237        ResourceTimingBuilder {
238            requestTime: requestTime,
239            proxyStart: proxyStart,
240            proxyEnd: proxyEnd,
241            dnsStart: dnsStart,
242            dnsEnd: dnsEnd,
243            connectStart: connectStart,
244            connectEnd: connectEnd,
245            sslStart: sslStart,
246            sslEnd: sslEnd,
247            workerStart: workerStart,
248            workerReady: workerReady,
249            workerFetchStart: workerFetchStart,
250            workerRespondWithSettled: workerRespondWithSettled,
251            workerRouterEvaluationStart: None,
252            workerCacheLookupStart: None,
253            sendStart: sendStart,
254            sendEnd: sendEnd,
255            pushStart: pushStart,
256            pushEnd: pushEnd,
257            receiveHeadersStart: receiveHeadersStart,
258            receiveHeadersEnd: receiveHeadersEnd,
259        }
260    }
261    pub fn requestTime(&self) -> f64 { self.requestTime }
262    pub fn proxyStart(&self) -> f64 { self.proxyStart }
263    pub fn proxyEnd(&self) -> f64 { self.proxyEnd }
264    pub fn dnsStart(&self) -> f64 { self.dnsStart }
265    pub fn dnsEnd(&self) -> f64 { self.dnsEnd }
266    pub fn connectStart(&self) -> f64 { self.connectStart }
267    pub fn connectEnd(&self) -> f64 { self.connectEnd }
268    pub fn sslStart(&self) -> f64 { self.sslStart }
269    pub fn sslEnd(&self) -> f64 { self.sslEnd }
270    pub fn workerStart(&self) -> f64 { self.workerStart }
271    pub fn workerReady(&self) -> f64 { self.workerReady }
272    pub fn workerFetchStart(&self) -> f64 { self.workerFetchStart }
273    pub fn workerRespondWithSettled(&self) -> f64 { self.workerRespondWithSettled }
274    pub fn workerRouterEvaluationStart(&self) -> Option<f64> { self.workerRouterEvaluationStart }
275    pub fn workerCacheLookupStart(&self) -> Option<f64> { self.workerCacheLookupStart }
276    pub fn sendStart(&self) -> f64 { self.sendStart }
277    pub fn sendEnd(&self) -> f64 { self.sendEnd }
278    pub fn pushStart(&self) -> f64 { self.pushStart }
279    pub fn pushEnd(&self) -> f64 { self.pushEnd }
280    pub fn receiveHeadersStart(&self) -> f64 { self.receiveHeadersStart }
281    pub fn receiveHeadersEnd(&self) -> f64 { self.receiveHeadersEnd }
282}
283
284
285pub struct ResourceTimingBuilder {
286    requestTime: f64,
287    proxyStart: f64,
288    proxyEnd: f64,
289    dnsStart: f64,
290    dnsEnd: f64,
291    connectStart: f64,
292    connectEnd: f64,
293    sslStart: f64,
294    sslEnd: f64,
295    workerStart: f64,
296    workerReady: f64,
297    workerFetchStart: f64,
298    workerRespondWithSettled: f64,
299    workerRouterEvaluationStart: Option<f64>,
300    workerCacheLookupStart: Option<f64>,
301    sendStart: f64,
302    sendEnd: f64,
303    pushStart: f64,
304    pushEnd: f64,
305    receiveHeadersStart: f64,
306    receiveHeadersEnd: f64,
307}
308
309impl ResourceTimingBuilder {
310    /// Started ServiceWorker static routing source evaluation.
311    pub fn workerRouterEvaluationStart(mut self, workerRouterEvaluationStart: f64) -> Self { self.workerRouterEvaluationStart = Some(workerRouterEvaluationStart); self }
312    /// Started cache lookup when the source was evaluated to 'cache'.
313    pub fn workerCacheLookupStart(mut self, workerCacheLookupStart: f64) -> Self { self.workerCacheLookupStart = Some(workerCacheLookupStart); self }
314    pub fn build(self) -> ResourceTiming {
315        ResourceTiming {
316            requestTime: self.requestTime,
317            proxyStart: self.proxyStart,
318            proxyEnd: self.proxyEnd,
319            dnsStart: self.dnsStart,
320            dnsEnd: self.dnsEnd,
321            connectStart: self.connectStart,
322            connectEnd: self.connectEnd,
323            sslStart: self.sslStart,
324            sslEnd: self.sslEnd,
325            workerStart: self.workerStart,
326            workerReady: self.workerReady,
327            workerFetchStart: self.workerFetchStart,
328            workerRespondWithSettled: self.workerRespondWithSettled,
329            workerRouterEvaluationStart: self.workerRouterEvaluationStart,
330            workerCacheLookupStart: self.workerCacheLookupStart,
331            sendStart: self.sendStart,
332            sendEnd: self.sendEnd,
333            pushStart: self.pushStart,
334            pushEnd: self.pushEnd,
335            receiveHeadersStart: self.receiveHeadersStart,
336            receiveHeadersEnd: self.receiveHeadersEnd,
337        }
338    }
339}
340
341/// Loading priority of a resource request.
342
343#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
344pub enum ResourcePriority {
345    #[default]
346    #[serde(rename = "VeryLow")]
347    VeryLow,
348    #[serde(rename = "Low")]
349    Low,
350    #[serde(rename = "Medium")]
351    Medium,
352    #[serde(rename = "High")]
353    High,
354    #[serde(rename = "VeryHigh")]
355    VeryHigh,
356}
357
358/// The render-blocking behavior of a resource request.
359
360#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
361pub enum RenderBlockingBehavior {
362    #[default]
363    #[serde(rename = "Blocking")]
364    Blocking,
365    #[serde(rename = "InBodyParserBlocking")]
366    InBodyParserBlocking,
367    #[serde(rename = "NonBlocking")]
368    NonBlocking,
369    #[serde(rename = "NonBlockingDynamic")]
370    NonBlockingDynamic,
371    #[serde(rename = "PotentiallyBlocking")]
372    PotentiallyBlocking,
373}
374
375/// Post data entry for HTTP request
376
377#[derive(Debug, Clone, Serialize, Deserialize, Default)]
378#[serde(rename_all = "camelCase")]
379pub struct PostDataEntry<'a> {
380    #[serde(skip_serializing_if = "Option::is_none")]
381    bytes: Option<Cow<'a, str>>,
382}
383
384impl<'a> PostDataEntry<'a> {
385    pub fn builder() -> PostDataEntryBuilder<'a> {
386        PostDataEntryBuilder {
387            bytes: None,
388        }
389    }
390    pub fn bytes(&self) -> Option<&str> { self.bytes.as_deref() }
391}
392
393#[derive(Default)]
394pub struct PostDataEntryBuilder<'a> {
395    bytes: Option<Cow<'a, str>>,
396}
397
398impl<'a> PostDataEntryBuilder<'a> {
399    pub fn bytes(mut self, bytes: impl Into<Cow<'a, str>>) -> Self { self.bytes = Some(bytes.into()); self }
400    pub fn build(self) -> PostDataEntry<'a> {
401        PostDataEntry {
402            bytes: self.bytes,
403        }
404    }
405}
406
407/// HTTP request data.
408
409#[derive(Debug, Clone, Serialize, Deserialize, Default)]
410#[serde(rename_all = "camelCase")]
411pub struct Request<'a> {
412    /// Request URL (without fragment).
413    url: Cow<'a, str>,
414    /// Fragment of the requested URL starting with hash, if present.
415    #[serde(skip_serializing_if = "Option::is_none")]
416    urlFragment: Option<Cow<'a, str>>,
417    /// HTTP request method.
418    method: Cow<'a, str>,
419    /// HTTP request headers.
420    headers: Headers,
421    /// HTTP POST request data.
422    /// Use postDataEntries instead.
423    #[serde(skip_serializing_if = "Option::is_none")]
424    postData: Option<Cow<'a, str>>,
425    /// True when the request has POST data. Note that postData might still be omitted when this flag is true when the data is too long.
426    #[serde(skip_serializing_if = "Option::is_none")]
427    hasPostData: Option<bool>,
428    /// Request body elements (post data broken into individual entries).
429    #[serde(skip_serializing_if = "Option::is_none")]
430    postDataEntries: Option<Vec<PostDataEntry<'a>>>,
431    /// The mixed content type of the request.
432    #[serde(skip_serializing_if = "Option::is_none")]
433    mixedContentType: Option<crate::security::MixedContentType>,
434    /// Priority of the resource request at the time request is sent.
435    initialPriority: ResourcePriority,
436    /// The referrer policy of the request, as defined in https://www.w3.org/TR/referrer-policy/
437    referrerPolicy: Cow<'a, str>,
438    /// Whether is loaded via link preload.
439    #[serde(skip_serializing_if = "Option::is_none")]
440    isLinkPreload: Option<bool>,
441    /// Set for requests when the TrustToken API is used. Contains the parameters
442    /// passed by the developer (e.g. via "fetch") as understood by the backend.
443    #[serde(skip_serializing_if = "Option::is_none")]
444    trustTokenParams: Option<TrustTokenParams<'a>>,
445    /// True if this resource request is considered to be the 'same site' as the
446    /// request corresponding to the main frame.
447    #[serde(skip_serializing_if = "Option::is_none")]
448    isSameSite: Option<bool>,
449    /// True when the resource request is ad-related.
450    #[serde(skip_serializing_if = "Option::is_none")]
451    isAdRelated: Option<bool>,
452}
453
454impl<'a> Request<'a> {
455    pub fn builder(url: impl Into<Cow<'a, str>>, method: impl Into<Cow<'a, str>>, headers: Headers, initialPriority: ResourcePriority, referrerPolicy: impl Into<Cow<'a, str>>) -> RequestBuilder<'a> {
456        RequestBuilder {
457            url: url.into(),
458            urlFragment: None,
459            method: method.into(),
460            headers: headers,
461            postData: None,
462            hasPostData: None,
463            postDataEntries: None,
464            mixedContentType: None,
465            initialPriority: initialPriority,
466            referrerPolicy: referrerPolicy.into(),
467            isLinkPreload: None,
468            trustTokenParams: None,
469            isSameSite: None,
470            isAdRelated: None,
471        }
472    }
473    pub fn url(&self) -> &str { self.url.as_ref() }
474    pub fn urlFragment(&self) -> Option<&str> { self.urlFragment.as_deref() }
475    pub fn method(&self) -> &str { self.method.as_ref() }
476    pub fn headers(&self) -> &Headers { &self.headers }
477    pub fn postData(&self) -> Option<&str> { self.postData.as_deref() }
478    pub fn hasPostData(&self) -> Option<bool> { self.hasPostData }
479    pub fn postDataEntries(&self) -> Option<&[PostDataEntry<'a>]> { self.postDataEntries.as_deref() }
480    pub fn mixedContentType(&self) -> Option<&crate::security::MixedContentType> { self.mixedContentType.as_ref() }
481    pub fn initialPriority(&self) -> &ResourcePriority { &self.initialPriority }
482    pub fn referrerPolicy(&self) -> &str { self.referrerPolicy.as_ref() }
483    pub fn isLinkPreload(&self) -> Option<bool> { self.isLinkPreload }
484    pub fn trustTokenParams(&self) -> Option<&TrustTokenParams<'a>> { self.trustTokenParams.as_ref() }
485    pub fn isSameSite(&self) -> Option<bool> { self.isSameSite }
486    pub fn isAdRelated(&self) -> Option<bool> { self.isAdRelated }
487}
488
489
490pub struct RequestBuilder<'a> {
491    url: Cow<'a, str>,
492    urlFragment: Option<Cow<'a, str>>,
493    method: Cow<'a, str>,
494    headers: Headers,
495    postData: Option<Cow<'a, str>>,
496    hasPostData: Option<bool>,
497    postDataEntries: Option<Vec<PostDataEntry<'a>>>,
498    mixedContentType: Option<crate::security::MixedContentType>,
499    initialPriority: ResourcePriority,
500    referrerPolicy: Cow<'a, str>,
501    isLinkPreload: Option<bool>,
502    trustTokenParams: Option<TrustTokenParams<'a>>,
503    isSameSite: Option<bool>,
504    isAdRelated: Option<bool>,
505}
506
507impl<'a> RequestBuilder<'a> {
508    /// Fragment of the requested URL starting with hash, if present.
509    pub fn urlFragment(mut self, urlFragment: impl Into<Cow<'a, str>>) -> Self { self.urlFragment = Some(urlFragment.into()); self }
510    /// HTTP POST request data.
511    /// Use postDataEntries instead.
512    pub fn postData(mut self, postData: impl Into<Cow<'a, str>>) -> Self { self.postData = Some(postData.into()); self }
513    /// True when the request has POST data. Note that postData might still be omitted when this flag is true when the data is too long.
514    pub fn hasPostData(mut self, hasPostData: bool) -> Self { self.hasPostData = Some(hasPostData); self }
515    /// Request body elements (post data broken into individual entries).
516    pub fn postDataEntries(mut self, postDataEntries: Vec<PostDataEntry<'a>>) -> Self { self.postDataEntries = Some(postDataEntries); self }
517    /// The mixed content type of the request.
518    pub fn mixedContentType(mut self, mixedContentType: crate::security::MixedContentType) -> Self { self.mixedContentType = Some(mixedContentType); self }
519    /// Whether is loaded via link preload.
520    pub fn isLinkPreload(mut self, isLinkPreload: bool) -> Self { self.isLinkPreload = Some(isLinkPreload); self }
521    /// Set for requests when the TrustToken API is used. Contains the parameters
522    /// passed by the developer (e.g. via "fetch") as understood by the backend.
523    pub fn trustTokenParams(mut self, trustTokenParams: TrustTokenParams<'a>) -> Self { self.trustTokenParams = Some(trustTokenParams); self }
524    /// True if this resource request is considered to be the 'same site' as the
525    /// request corresponding to the main frame.
526    pub fn isSameSite(mut self, isSameSite: bool) -> Self { self.isSameSite = Some(isSameSite); self }
527    /// True when the resource request is ad-related.
528    pub fn isAdRelated(mut self, isAdRelated: bool) -> Self { self.isAdRelated = Some(isAdRelated); self }
529    pub fn build(self) -> Request<'a> {
530        Request {
531            url: self.url,
532            urlFragment: self.urlFragment,
533            method: self.method,
534            headers: self.headers,
535            postData: self.postData,
536            hasPostData: self.hasPostData,
537            postDataEntries: self.postDataEntries,
538            mixedContentType: self.mixedContentType,
539            initialPriority: self.initialPriority,
540            referrerPolicy: self.referrerPolicy,
541            isLinkPreload: self.isLinkPreload,
542            trustTokenParams: self.trustTokenParams,
543            isSameSite: self.isSameSite,
544            isAdRelated: self.isAdRelated,
545        }
546    }
547}
548
549/// Details of a signed certificate timestamp (SCT).
550
551#[derive(Debug, Clone, Serialize, Deserialize, Default)]
552#[serde(rename_all = "camelCase")]
553pub struct SignedCertificateTimestamp<'a> {
554    /// Validation status.
555    status: Cow<'a, str>,
556    /// Origin.
557    origin: Cow<'a, str>,
558    /// Log name / description.
559    logDescription: Cow<'a, str>,
560    /// Log ID.
561    logId: Cow<'a, str>,
562    /// Issuance date. Unlike TimeSinceEpoch, this contains the number of
563    /// milliseconds since January 1, 1970, UTC, not the number of seconds.
564    timestamp: f64,
565    /// Hash algorithm.
566    hashAlgorithm: Cow<'a, str>,
567    /// Signature algorithm.
568    signatureAlgorithm: Cow<'a, str>,
569    /// Signature data.
570    signatureData: Cow<'a, str>,
571}
572
573impl<'a> SignedCertificateTimestamp<'a> {
574    pub fn builder(status: impl Into<Cow<'a, str>>, origin: impl Into<Cow<'a, str>>, logDescription: impl Into<Cow<'a, str>>, logId: impl Into<Cow<'a, str>>, timestamp: f64, hashAlgorithm: impl Into<Cow<'a, str>>, signatureAlgorithm: impl Into<Cow<'a, str>>, signatureData: impl Into<Cow<'a, str>>) -> SignedCertificateTimestampBuilder<'a> {
575        SignedCertificateTimestampBuilder {
576            status: status.into(),
577            origin: origin.into(),
578            logDescription: logDescription.into(),
579            logId: logId.into(),
580            timestamp: timestamp,
581            hashAlgorithm: hashAlgorithm.into(),
582            signatureAlgorithm: signatureAlgorithm.into(),
583            signatureData: signatureData.into(),
584        }
585    }
586    pub fn status(&self) -> &str { self.status.as_ref() }
587    pub fn origin(&self) -> &str { self.origin.as_ref() }
588    pub fn logDescription(&self) -> &str { self.logDescription.as_ref() }
589    pub fn logId(&self) -> &str { self.logId.as_ref() }
590    pub fn timestamp(&self) -> f64 { self.timestamp }
591    pub fn hashAlgorithm(&self) -> &str { self.hashAlgorithm.as_ref() }
592    pub fn signatureAlgorithm(&self) -> &str { self.signatureAlgorithm.as_ref() }
593    pub fn signatureData(&self) -> &str { self.signatureData.as_ref() }
594}
595
596
597pub struct SignedCertificateTimestampBuilder<'a> {
598    status: Cow<'a, str>,
599    origin: Cow<'a, str>,
600    logDescription: Cow<'a, str>,
601    logId: Cow<'a, str>,
602    timestamp: f64,
603    hashAlgorithm: Cow<'a, str>,
604    signatureAlgorithm: Cow<'a, str>,
605    signatureData: Cow<'a, str>,
606}
607
608impl<'a> SignedCertificateTimestampBuilder<'a> {
609    pub fn build(self) -> SignedCertificateTimestamp<'a> {
610        SignedCertificateTimestamp {
611            status: self.status,
612            origin: self.origin,
613            logDescription: self.logDescription,
614            logId: self.logId,
615            timestamp: self.timestamp,
616            hashAlgorithm: self.hashAlgorithm,
617            signatureAlgorithm: self.signatureAlgorithm,
618            signatureData: self.signatureData,
619        }
620    }
621}
622
623/// Security details about a request.
624
625#[derive(Debug, Clone, Serialize, Deserialize, Default)]
626#[serde(rename_all = "camelCase")]
627pub struct SecurityDetails<'a> {
628    /// Protocol name (e.g. "TLS 1.2" or "QUIC").
629    protocol: Cow<'a, str>,
630    /// Key Exchange used by the connection, or the empty string if not applicable.
631    keyExchange: Cow<'a, str>,
632    /// (EC)DH group used by the connection, if applicable.
633    #[serde(skip_serializing_if = "Option::is_none")]
634    keyExchangeGroup: Option<Cow<'a, str>>,
635    /// Cipher name.
636    cipher: Cow<'a, str>,
637    /// TLS MAC. Note that AEAD ciphers do not have separate MACs.
638    #[serde(skip_serializing_if = "Option::is_none")]
639    mac: Option<Cow<'a, str>>,
640    /// Certificate ID value.
641    certificateId: crate::security::CertificateId,
642    /// Certificate subject name.
643    subjectName: Cow<'a, str>,
644    /// Subject Alternative Name (SAN) DNS names and IP addresses.
645    sanList: Vec<Cow<'a, str>>,
646    /// Name of the issuing CA.
647    issuer: Cow<'a, str>,
648    /// Certificate valid from date.
649    validFrom: TimeSinceEpoch,
650    /// Certificate valid to (expiration) date
651    validTo: TimeSinceEpoch,
652    /// List of signed certificate timestamps (SCTs).
653    signedCertificateTimestampList: Vec<SignedCertificateTimestamp<'a>>,
654    /// Whether the request complied with Certificate Transparency policy
655    certificateTransparencyCompliance: CertificateTransparencyCompliance,
656    /// The signature algorithm used by the server in the TLS server signature,
657    /// represented as a TLS SignatureScheme code point. Omitted if not
658    /// applicable or not known.
659    #[serde(skip_serializing_if = "Option::is_none")]
660    serverSignatureAlgorithm: Option<i64>,
661    /// Whether the connection used Encrypted ClientHello
662    encryptedClientHello: bool,
663}
664
665impl<'a> SecurityDetails<'a> {
666    pub fn builder(protocol: impl Into<Cow<'a, str>>, keyExchange: impl Into<Cow<'a, str>>, cipher: impl Into<Cow<'a, str>>, certificateId: crate::security::CertificateId, subjectName: impl Into<Cow<'a, str>>, sanList: Vec<Cow<'a, str>>, issuer: impl Into<Cow<'a, str>>, validFrom: TimeSinceEpoch, validTo: TimeSinceEpoch, signedCertificateTimestampList: Vec<SignedCertificateTimestamp<'a>>, certificateTransparencyCompliance: CertificateTransparencyCompliance, encryptedClientHello: bool) -> SecurityDetailsBuilder<'a> {
667        SecurityDetailsBuilder {
668            protocol: protocol.into(),
669            keyExchange: keyExchange.into(),
670            keyExchangeGroup: None,
671            cipher: cipher.into(),
672            mac: None,
673            certificateId: certificateId,
674            subjectName: subjectName.into(),
675            sanList: sanList,
676            issuer: issuer.into(),
677            validFrom: validFrom,
678            validTo: validTo,
679            signedCertificateTimestampList: signedCertificateTimestampList,
680            certificateTransparencyCompliance: certificateTransparencyCompliance,
681            serverSignatureAlgorithm: None,
682            encryptedClientHello: encryptedClientHello,
683        }
684    }
685    pub fn protocol(&self) -> &str { self.protocol.as_ref() }
686    pub fn keyExchange(&self) -> &str { self.keyExchange.as_ref() }
687    pub fn keyExchangeGroup(&self) -> Option<&str> { self.keyExchangeGroup.as_deref() }
688    pub fn cipher(&self) -> &str { self.cipher.as_ref() }
689    pub fn mac(&self) -> Option<&str> { self.mac.as_deref() }
690    pub fn certificateId(&self) -> &crate::security::CertificateId { &self.certificateId }
691    pub fn subjectName(&self) -> &str { self.subjectName.as_ref() }
692    pub fn sanList(&self) -> &[Cow<'a, str>] { &self.sanList }
693    pub fn issuer(&self) -> &str { self.issuer.as_ref() }
694    pub fn validFrom(&self) -> &TimeSinceEpoch { &self.validFrom }
695    pub fn validTo(&self) -> &TimeSinceEpoch { &self.validTo }
696    pub fn signedCertificateTimestampList(&self) -> &[SignedCertificateTimestamp<'a>] { &self.signedCertificateTimestampList }
697    pub fn certificateTransparencyCompliance(&self) -> &CertificateTransparencyCompliance { &self.certificateTransparencyCompliance }
698    pub fn serverSignatureAlgorithm(&self) -> Option<i64> { self.serverSignatureAlgorithm }
699    pub fn encryptedClientHello(&self) -> bool { self.encryptedClientHello }
700}
701
702
703pub struct SecurityDetailsBuilder<'a> {
704    protocol: Cow<'a, str>,
705    keyExchange: Cow<'a, str>,
706    keyExchangeGroup: Option<Cow<'a, str>>,
707    cipher: Cow<'a, str>,
708    mac: Option<Cow<'a, str>>,
709    certificateId: crate::security::CertificateId,
710    subjectName: Cow<'a, str>,
711    sanList: Vec<Cow<'a, str>>,
712    issuer: Cow<'a, str>,
713    validFrom: TimeSinceEpoch,
714    validTo: TimeSinceEpoch,
715    signedCertificateTimestampList: Vec<SignedCertificateTimestamp<'a>>,
716    certificateTransparencyCompliance: CertificateTransparencyCompliance,
717    serverSignatureAlgorithm: Option<i64>,
718    encryptedClientHello: bool,
719}
720
721impl<'a> SecurityDetailsBuilder<'a> {
722    /// (EC)DH group used by the connection, if applicable.
723    pub fn keyExchangeGroup(mut self, keyExchangeGroup: impl Into<Cow<'a, str>>) -> Self { self.keyExchangeGroup = Some(keyExchangeGroup.into()); self }
724    /// TLS MAC. Note that AEAD ciphers do not have separate MACs.
725    pub fn mac(mut self, mac: impl Into<Cow<'a, str>>) -> Self { self.mac = Some(mac.into()); self }
726    /// The signature algorithm used by the server in the TLS server signature,
727    /// represented as a TLS SignatureScheme code point. Omitted if not
728    /// applicable or not known.
729    pub fn serverSignatureAlgorithm(mut self, serverSignatureAlgorithm: i64) -> Self { self.serverSignatureAlgorithm = Some(serverSignatureAlgorithm); self }
730    pub fn build(self) -> SecurityDetails<'a> {
731        SecurityDetails {
732            protocol: self.protocol,
733            keyExchange: self.keyExchange,
734            keyExchangeGroup: self.keyExchangeGroup,
735            cipher: self.cipher,
736            mac: self.mac,
737            certificateId: self.certificateId,
738            subjectName: self.subjectName,
739            sanList: self.sanList,
740            issuer: self.issuer,
741            validFrom: self.validFrom,
742            validTo: self.validTo,
743            signedCertificateTimestampList: self.signedCertificateTimestampList,
744            certificateTransparencyCompliance: self.certificateTransparencyCompliance,
745            serverSignatureAlgorithm: self.serverSignatureAlgorithm,
746            encryptedClientHello: self.encryptedClientHello,
747        }
748    }
749}
750
751/// Whether the request complied with Certificate Transparency policy.
752
753#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
754pub enum CertificateTransparencyCompliance {
755    #[default]
756    #[serde(rename = "unknown")]
757    Unknown,
758    #[serde(rename = "not-compliant")]
759    NotCompliant,
760    #[serde(rename = "compliant")]
761    Compliant,
762}
763
764/// The reason why request was blocked.
765
766#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
767pub enum BlockedReason {
768    #[default]
769    #[serde(rename = "other")]
770    Other,
771    #[serde(rename = "csp")]
772    Csp,
773    #[serde(rename = "mixed-content")]
774    MixedContent,
775    #[serde(rename = "origin")]
776    Origin,
777    #[serde(rename = "inspector")]
778    Inspector,
779    #[serde(rename = "integrity")]
780    Integrity,
781    #[serde(rename = "subresource-filter")]
782    SubresourceFilter,
783    #[serde(rename = "content-type")]
784    ContentType,
785    #[serde(rename = "coep-frame-resource-needs-coep-header")]
786    CoepFrameResourceNeedsCoepHeader,
787    #[serde(rename = "coop-sandboxed-iframe-cannot-navigate-to-coop-page")]
788    CoopSandboxedIframeCannotNavigateToCoopPage,
789    #[serde(rename = "corp-not-same-origin")]
790    CorpNotSameOrigin,
791    #[serde(rename = "corp-not-same-origin-after-defaulted-to-same-origin-by-coep")]
792    CorpNotSameOriginAfterDefaultedToSameOriginByCoep,
793    #[serde(rename = "corp-not-same-origin-after-defaulted-to-same-origin-by-dip")]
794    CorpNotSameOriginAfterDefaultedToSameOriginByDip,
795    #[serde(rename = "corp-not-same-origin-after-defaulted-to-same-origin-by-coep-and-dip")]
796    CorpNotSameOriginAfterDefaultedToSameOriginByCoepAndDip,
797    #[serde(rename = "corp-not-same-site")]
798    CorpNotSameSite,
799    #[serde(rename = "sri-message-signature-mismatch")]
800    SriMessageSignatureMismatch,
801}
802
803/// The reason why request was blocked.
804
805#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
806pub enum CorsError {
807    #[default]
808    #[serde(rename = "DisallowedByMode")]
809    DisallowedByMode,
810    #[serde(rename = "InvalidResponse")]
811    InvalidResponse,
812    #[serde(rename = "WildcardOriginNotAllowed")]
813    WildcardOriginNotAllowed,
814    #[serde(rename = "MissingAllowOriginHeader")]
815    MissingAllowOriginHeader,
816    #[serde(rename = "MultipleAllowOriginValues")]
817    MultipleAllowOriginValues,
818    #[serde(rename = "InvalidAllowOriginValue")]
819    InvalidAllowOriginValue,
820    #[serde(rename = "AllowOriginMismatch")]
821    AllowOriginMismatch,
822    #[serde(rename = "InvalidAllowCredentials")]
823    InvalidAllowCredentials,
824    #[serde(rename = "CorsDisabledScheme")]
825    CorsDisabledScheme,
826    #[serde(rename = "PreflightInvalidStatus")]
827    PreflightInvalidStatus,
828    #[serde(rename = "PreflightDisallowedRedirect")]
829    PreflightDisallowedRedirect,
830    #[serde(rename = "PreflightWildcardOriginNotAllowed")]
831    PreflightWildcardOriginNotAllowed,
832    #[serde(rename = "PreflightMissingAllowOriginHeader")]
833    PreflightMissingAllowOriginHeader,
834    #[serde(rename = "PreflightMultipleAllowOriginValues")]
835    PreflightMultipleAllowOriginValues,
836    #[serde(rename = "PreflightInvalidAllowOriginValue")]
837    PreflightInvalidAllowOriginValue,
838    #[serde(rename = "PreflightAllowOriginMismatch")]
839    PreflightAllowOriginMismatch,
840    #[serde(rename = "PreflightInvalidAllowCredentials")]
841    PreflightInvalidAllowCredentials,
842    #[serde(rename = "PreflightMissingAllowExternal")]
843    PreflightMissingAllowExternal,
844    #[serde(rename = "PreflightInvalidAllowExternal")]
845    PreflightInvalidAllowExternal,
846    #[serde(rename = "InvalidAllowMethodsPreflightResponse")]
847    InvalidAllowMethodsPreflightResponse,
848    #[serde(rename = "InvalidAllowHeadersPreflightResponse")]
849    InvalidAllowHeadersPreflightResponse,
850    #[serde(rename = "MethodDisallowedByPreflightResponse")]
851    MethodDisallowedByPreflightResponse,
852    #[serde(rename = "HeaderDisallowedByPreflightResponse")]
853    HeaderDisallowedByPreflightResponse,
854    #[serde(rename = "RedirectContainsCredentials")]
855    RedirectContainsCredentials,
856    #[serde(rename = "InsecureLocalNetwork")]
857    InsecureLocalNetwork,
858    #[serde(rename = "InvalidLocalNetworkAccess")]
859    InvalidLocalNetworkAccess,
860    #[serde(rename = "NoCorsRedirectModeNotFollow")]
861    NoCorsRedirectModeNotFollow,
862    #[serde(rename = "LocalNetworkAccessPermissionDenied")]
863    LocalNetworkAccessPermissionDenied,
864}
865
866
867#[derive(Debug, Clone, Serialize, Deserialize, Default)]
868#[serde(rename_all = "camelCase")]
869pub struct CorsErrorStatus<'a> {
870    corsError: CorsError,
871    failedParameter: Cow<'a, str>,
872}
873
874impl<'a> CorsErrorStatus<'a> {
875    pub fn builder(corsError: CorsError, failedParameter: impl Into<Cow<'a, str>>) -> CorsErrorStatusBuilder<'a> {
876        CorsErrorStatusBuilder {
877            corsError: corsError,
878            failedParameter: failedParameter.into(),
879        }
880    }
881    pub fn corsError(&self) -> &CorsError { &self.corsError }
882    pub fn failedParameter(&self) -> &str { self.failedParameter.as_ref() }
883}
884
885
886pub struct CorsErrorStatusBuilder<'a> {
887    corsError: CorsError,
888    failedParameter: Cow<'a, str>,
889}
890
891impl<'a> CorsErrorStatusBuilder<'a> {
892    pub fn build(self) -> CorsErrorStatus<'a> {
893        CorsErrorStatus {
894            corsError: self.corsError,
895            failedParameter: self.failedParameter,
896        }
897    }
898}
899
900/// Source of serviceworker response.
901
902#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
903pub enum ServiceWorkerResponseSource {
904    #[default]
905    #[serde(rename = "cache-storage")]
906    CacheStorage,
907    #[serde(rename = "http-cache")]
908    HttpCache,
909    #[serde(rename = "fallback-code")]
910    FallbackCode,
911    #[serde(rename = "network")]
912    Network,
913}
914
915/// Determines what type of Trust Token operation is executed and
916/// depending on the type, some additional parameters. The values
917/// are specified in third_party/blink/renderer/core/fetch/trust_token.idl.
918
919#[derive(Debug, Clone, Serialize, Deserialize, Default)]
920#[serde(rename_all = "camelCase")]
921pub struct TrustTokenParams<'a> {
922    operation: TrustTokenOperationType,
923    /// Only set for "token-redemption" operation and determine whether
924    /// to request a fresh SRR or use a still valid cached SRR.
925    refreshPolicy: Cow<'a, str>,
926    /// Origins of issuers from whom to request tokens or redemption
927    /// records.
928    #[serde(skip_serializing_if = "Option::is_none")]
929    issuers: Option<Vec<Cow<'a, str>>>,
930}
931
932impl<'a> TrustTokenParams<'a> {
933    pub fn builder(operation: TrustTokenOperationType, refreshPolicy: impl Into<Cow<'a, str>>) -> TrustTokenParamsBuilder<'a> {
934        TrustTokenParamsBuilder {
935            operation: operation,
936            refreshPolicy: refreshPolicy.into(),
937            issuers: None,
938        }
939    }
940    pub fn operation(&self) -> &TrustTokenOperationType { &self.operation }
941    pub fn refreshPolicy(&self) -> &str { self.refreshPolicy.as_ref() }
942    pub fn issuers(&self) -> Option<&[Cow<'a, str>]> { self.issuers.as_deref() }
943}
944
945
946pub struct TrustTokenParamsBuilder<'a> {
947    operation: TrustTokenOperationType,
948    refreshPolicy: Cow<'a, str>,
949    issuers: Option<Vec<Cow<'a, str>>>,
950}
951
952impl<'a> TrustTokenParamsBuilder<'a> {
953    /// Origins of issuers from whom to request tokens or redemption
954    /// records.
955    pub fn issuers(mut self, issuers: Vec<Cow<'a, str>>) -> Self { self.issuers = Some(issuers); self }
956    pub fn build(self) -> TrustTokenParams<'a> {
957        TrustTokenParams {
958            operation: self.operation,
959            refreshPolicy: self.refreshPolicy,
960            issuers: self.issuers,
961        }
962    }
963}
964
965
966#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
967pub enum TrustTokenOperationType {
968    #[default]
969    #[serde(rename = "Issuance")]
970    Issuance,
971    #[serde(rename = "Redemption")]
972    Redemption,
973    #[serde(rename = "Signing")]
974    Signing,
975}
976
977/// The reason why Chrome uses a specific transport protocol for HTTP semantics.
978
979#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
980pub enum AlternateProtocolUsage {
981    #[default]
982    #[serde(rename = "alternativeJobWonWithoutRace")]
983    AlternativeJobWonWithoutRace,
984    #[serde(rename = "alternativeJobWonRace")]
985    AlternativeJobWonRace,
986    #[serde(rename = "mainJobWonRace")]
987    MainJobWonRace,
988    #[serde(rename = "mappingMissing")]
989    MappingMissing,
990    #[serde(rename = "broken")]
991    Broken,
992    #[serde(rename = "dnsAlpnH3JobWonWithoutRace")]
993    DnsAlpnH3JobWonWithoutRace,
994    #[serde(rename = "dnsAlpnH3JobWonRace")]
995    DnsAlpnH3JobWonRace,
996    #[serde(rename = "unspecifiedReason")]
997    UnspecifiedReason,
998}
999
1000/// Source of service worker router.
1001
1002#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
1003pub enum ServiceWorkerRouterSource {
1004    #[default]
1005    #[serde(rename = "network")]
1006    Network,
1007    #[serde(rename = "cache")]
1008    Cache,
1009    #[serde(rename = "fetch-event")]
1010    FetchEvent,
1011    #[serde(rename = "race-network-and-fetch-handler")]
1012    RaceNetworkAndFetchHandler,
1013    #[serde(rename = "race-network-and-cache")]
1014    RaceNetworkAndCache,
1015}
1016
1017
1018#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1019#[serde(rename_all = "camelCase")]
1020pub struct ServiceWorkerRouterInfo {
1021    /// ID of the rule matched. If there is a matched rule, this field will
1022    /// be set, otherwiser no value will be set.
1023    #[serde(skip_serializing_if = "Option::is_none")]
1024    ruleIdMatched: Option<u64>,
1025    /// The router source of the matched rule. If there is a matched rule, this
1026    /// field will be set, otherwise no value will be set.
1027    #[serde(skip_serializing_if = "Option::is_none")]
1028    matchedSourceType: Option<ServiceWorkerRouterSource>,
1029    /// The actual router source used.
1030    #[serde(skip_serializing_if = "Option::is_none")]
1031    actualSourceType: Option<ServiceWorkerRouterSource>,
1032}
1033
1034impl ServiceWorkerRouterInfo {
1035    pub fn builder() -> ServiceWorkerRouterInfoBuilder {
1036        ServiceWorkerRouterInfoBuilder {
1037            ruleIdMatched: None,
1038            matchedSourceType: None,
1039            actualSourceType: None,
1040        }
1041    }
1042    pub fn ruleIdMatched(&self) -> Option<u64> { self.ruleIdMatched }
1043    pub fn matchedSourceType(&self) -> Option<&ServiceWorkerRouterSource> { self.matchedSourceType.as_ref() }
1044    pub fn actualSourceType(&self) -> Option<&ServiceWorkerRouterSource> { self.actualSourceType.as_ref() }
1045}
1046
1047#[derive(Default)]
1048pub struct ServiceWorkerRouterInfoBuilder {
1049    ruleIdMatched: Option<u64>,
1050    matchedSourceType: Option<ServiceWorkerRouterSource>,
1051    actualSourceType: Option<ServiceWorkerRouterSource>,
1052}
1053
1054impl ServiceWorkerRouterInfoBuilder {
1055    /// ID of the rule matched. If there is a matched rule, this field will
1056    /// be set, otherwiser no value will be set.
1057    pub fn ruleIdMatched(mut self, ruleIdMatched: u64) -> Self { self.ruleIdMatched = Some(ruleIdMatched); self }
1058    /// The router source of the matched rule. If there is a matched rule, this
1059    /// field will be set, otherwise no value will be set.
1060    pub fn matchedSourceType(mut self, matchedSourceType: ServiceWorkerRouterSource) -> Self { self.matchedSourceType = Some(matchedSourceType); self }
1061    /// The actual router source used.
1062    pub fn actualSourceType(mut self, actualSourceType: ServiceWorkerRouterSource) -> Self { self.actualSourceType = Some(actualSourceType); self }
1063    pub fn build(self) -> ServiceWorkerRouterInfo {
1064        ServiceWorkerRouterInfo {
1065            ruleIdMatched: self.ruleIdMatched,
1066            matchedSourceType: self.matchedSourceType,
1067            actualSourceType: self.actualSourceType,
1068        }
1069    }
1070}
1071
1072/// HTTP response data.
1073
1074#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1075#[serde(rename_all = "camelCase")]
1076pub struct Response<'a> {
1077    /// Response URL. This URL can be different from CachedResource.url in case of redirect.
1078    url: Cow<'a, str>,
1079    /// HTTP response status code.
1080    status: i64,
1081    /// HTTP response status text.
1082    statusText: Cow<'a, str>,
1083    /// HTTP response headers.
1084    headers: Headers,
1085    /// HTTP response headers text. This has been replaced by the headers in Network.responseReceivedExtraInfo.
1086    #[serde(skip_serializing_if = "Option::is_none")]
1087    headersText: Option<Cow<'a, str>>,
1088    /// Resource mimeType as determined by the browser.
1089    mimeType: Cow<'a, str>,
1090    /// Resource charset as determined by the browser (if applicable).
1091    charset: Cow<'a, str>,
1092    /// Refined HTTP request headers that were actually transmitted over the network.
1093    #[serde(skip_serializing_if = "Option::is_none")]
1094    requestHeaders: Option<Headers>,
1095    /// HTTP request headers text. This has been replaced by the headers in Network.requestWillBeSentExtraInfo.
1096    #[serde(skip_serializing_if = "Option::is_none")]
1097    requestHeadersText: Option<Cow<'a, str>>,
1098    /// Specifies whether physical connection was actually reused for this request.
1099    connectionReused: bool,
1100    /// Physical connection id that was actually used for this request.
1101    connectionId: f64,
1102    /// Remote IP address.
1103    #[serde(skip_serializing_if = "Option::is_none")]
1104    remoteIPAddress: Option<Cow<'a, str>>,
1105    /// Remote port.
1106    #[serde(skip_serializing_if = "Option::is_none")]
1107    remotePort: Option<i64>,
1108    /// Specifies that the request was served from the disk cache.
1109    #[serde(skip_serializing_if = "Option::is_none")]
1110    fromDiskCache: Option<bool>,
1111    /// Specifies that the request was served from the ServiceWorker.
1112    #[serde(skip_serializing_if = "Option::is_none")]
1113    fromServiceWorker: Option<bool>,
1114    /// Specifies that the request was served from the prefetch cache.
1115    #[serde(skip_serializing_if = "Option::is_none")]
1116    fromPrefetchCache: Option<bool>,
1117    /// Specifies that the request was served from the prefetch cache.
1118    #[serde(skip_serializing_if = "Option::is_none")]
1119    fromEarlyHints: Option<bool>,
1120    /// Information about how ServiceWorker Static Router API was used. If this
1121    /// field is set with 'matchedSourceType' field, a matching rule is found.
1122    /// If this field is set without 'matchedSource', no matching rule is found.
1123    /// Otherwise, the API is not used.
1124    #[serde(skip_serializing_if = "Option::is_none")]
1125    serviceWorkerRouterInfo: Option<ServiceWorkerRouterInfo>,
1126    /// Total number of bytes received for this request so far.
1127    encodedDataLength: f64,
1128    /// Timing information for the given request.
1129    #[serde(skip_serializing_if = "Option::is_none")]
1130    timing: Option<ResourceTiming>,
1131    /// Response source of response from ServiceWorker.
1132    #[serde(skip_serializing_if = "Option::is_none")]
1133    serviceWorkerResponseSource: Option<ServiceWorkerResponseSource>,
1134    /// The time at which the returned response was generated.
1135    #[serde(skip_serializing_if = "Option::is_none")]
1136    responseTime: Option<TimeSinceEpoch>,
1137    /// Cache Storage Cache Name.
1138    #[serde(skip_serializing_if = "Option::is_none")]
1139    cacheStorageCacheName: Option<Cow<'a, str>>,
1140    /// Protocol used to fetch this request.
1141    #[serde(skip_serializing_if = "Option::is_none")]
1142    protocol: Option<Cow<'a, str>>,
1143    /// The reason why Chrome uses a specific transport protocol for HTTP semantics.
1144    #[serde(skip_serializing_if = "Option::is_none")]
1145    alternateProtocolUsage: Option<AlternateProtocolUsage>,
1146    /// Security state of the request resource.
1147    securityState: crate::security::SecurityState,
1148    /// Security details for the request.
1149    #[serde(skip_serializing_if = "Option::is_none")]
1150    securityDetails: Option<SecurityDetails<'a>>,
1151}
1152
1153impl<'a> Response<'a> {
1154    pub fn builder(url: impl Into<Cow<'a, str>>, status: i64, statusText: impl Into<Cow<'a, str>>, headers: Headers, mimeType: impl Into<Cow<'a, str>>, charset: impl Into<Cow<'a, str>>, connectionReused: bool, connectionId: f64, encodedDataLength: f64, securityState: crate::security::SecurityState) -> ResponseBuilder<'a> {
1155        ResponseBuilder {
1156            url: url.into(),
1157            status: status,
1158            statusText: statusText.into(),
1159            headers: headers,
1160            headersText: None,
1161            mimeType: mimeType.into(),
1162            charset: charset.into(),
1163            requestHeaders: None,
1164            requestHeadersText: None,
1165            connectionReused: connectionReused,
1166            connectionId: connectionId,
1167            remoteIPAddress: None,
1168            remotePort: None,
1169            fromDiskCache: None,
1170            fromServiceWorker: None,
1171            fromPrefetchCache: None,
1172            fromEarlyHints: None,
1173            serviceWorkerRouterInfo: None,
1174            encodedDataLength: encodedDataLength,
1175            timing: None,
1176            serviceWorkerResponseSource: None,
1177            responseTime: None,
1178            cacheStorageCacheName: None,
1179            protocol: None,
1180            alternateProtocolUsage: None,
1181            securityState: securityState,
1182            securityDetails: None,
1183        }
1184    }
1185    pub fn url(&self) -> &str { self.url.as_ref() }
1186    pub fn status(&self) -> i64 { self.status }
1187    pub fn statusText(&self) -> &str { self.statusText.as_ref() }
1188    pub fn headers(&self) -> &Headers { &self.headers }
1189    pub fn headersText(&self) -> Option<&str> { self.headersText.as_deref() }
1190    pub fn mimeType(&self) -> &str { self.mimeType.as_ref() }
1191    pub fn charset(&self) -> &str { self.charset.as_ref() }
1192    pub fn requestHeaders(&self) -> Option<&Headers> { self.requestHeaders.as_ref() }
1193    pub fn requestHeadersText(&self) -> Option<&str> { self.requestHeadersText.as_deref() }
1194    pub fn connectionReused(&self) -> bool { self.connectionReused }
1195    pub fn connectionId(&self) -> f64 { self.connectionId }
1196    pub fn remoteIPAddress(&self) -> Option<&str> { self.remoteIPAddress.as_deref() }
1197    pub fn remotePort(&self) -> Option<i64> { self.remotePort }
1198    pub fn fromDiskCache(&self) -> Option<bool> { self.fromDiskCache }
1199    pub fn fromServiceWorker(&self) -> Option<bool> { self.fromServiceWorker }
1200    pub fn fromPrefetchCache(&self) -> Option<bool> { self.fromPrefetchCache }
1201    pub fn fromEarlyHints(&self) -> Option<bool> { self.fromEarlyHints }
1202    pub fn serviceWorkerRouterInfo(&self) -> Option<&ServiceWorkerRouterInfo> { self.serviceWorkerRouterInfo.as_ref() }
1203    pub fn encodedDataLength(&self) -> f64 { self.encodedDataLength }
1204    pub fn timing(&self) -> Option<&ResourceTiming> { self.timing.as_ref() }
1205    pub fn serviceWorkerResponseSource(&self) -> Option<&ServiceWorkerResponseSource> { self.serviceWorkerResponseSource.as_ref() }
1206    pub fn responseTime(&self) -> Option<&TimeSinceEpoch> { self.responseTime.as_ref() }
1207    pub fn cacheStorageCacheName(&self) -> Option<&str> { self.cacheStorageCacheName.as_deref() }
1208    pub fn protocol(&self) -> Option<&str> { self.protocol.as_deref() }
1209    pub fn alternateProtocolUsage(&self) -> Option<&AlternateProtocolUsage> { self.alternateProtocolUsage.as_ref() }
1210    pub fn securityState(&self) -> &crate::security::SecurityState { &self.securityState }
1211    pub fn securityDetails(&self) -> Option<&SecurityDetails<'a>> { self.securityDetails.as_ref() }
1212}
1213
1214
1215pub struct ResponseBuilder<'a> {
1216    url: Cow<'a, str>,
1217    status: i64,
1218    statusText: Cow<'a, str>,
1219    headers: Headers,
1220    headersText: Option<Cow<'a, str>>,
1221    mimeType: Cow<'a, str>,
1222    charset: Cow<'a, str>,
1223    requestHeaders: Option<Headers>,
1224    requestHeadersText: Option<Cow<'a, str>>,
1225    connectionReused: bool,
1226    connectionId: f64,
1227    remoteIPAddress: Option<Cow<'a, str>>,
1228    remotePort: Option<i64>,
1229    fromDiskCache: Option<bool>,
1230    fromServiceWorker: Option<bool>,
1231    fromPrefetchCache: Option<bool>,
1232    fromEarlyHints: Option<bool>,
1233    serviceWorkerRouterInfo: Option<ServiceWorkerRouterInfo>,
1234    encodedDataLength: f64,
1235    timing: Option<ResourceTiming>,
1236    serviceWorkerResponseSource: Option<ServiceWorkerResponseSource>,
1237    responseTime: Option<TimeSinceEpoch>,
1238    cacheStorageCacheName: Option<Cow<'a, str>>,
1239    protocol: Option<Cow<'a, str>>,
1240    alternateProtocolUsage: Option<AlternateProtocolUsage>,
1241    securityState: crate::security::SecurityState,
1242    securityDetails: Option<SecurityDetails<'a>>,
1243}
1244
1245impl<'a> ResponseBuilder<'a> {
1246    /// HTTP response headers text. This has been replaced by the headers in Network.responseReceivedExtraInfo.
1247    pub fn headersText(mut self, headersText: impl Into<Cow<'a, str>>) -> Self { self.headersText = Some(headersText.into()); self }
1248    /// Refined HTTP request headers that were actually transmitted over the network.
1249    pub fn requestHeaders(mut self, requestHeaders: Headers) -> Self { self.requestHeaders = Some(requestHeaders); self }
1250    /// HTTP request headers text. This has been replaced by the headers in Network.requestWillBeSentExtraInfo.
1251    pub fn requestHeadersText(mut self, requestHeadersText: impl Into<Cow<'a, str>>) -> Self { self.requestHeadersText = Some(requestHeadersText.into()); self }
1252    /// Remote IP address.
1253    pub fn remoteIPAddress(mut self, remoteIPAddress: impl Into<Cow<'a, str>>) -> Self { self.remoteIPAddress = Some(remoteIPAddress.into()); self }
1254    /// Remote port.
1255    pub fn remotePort(mut self, remotePort: i64) -> Self { self.remotePort = Some(remotePort); self }
1256    /// Specifies that the request was served from the disk cache.
1257    pub fn fromDiskCache(mut self, fromDiskCache: bool) -> Self { self.fromDiskCache = Some(fromDiskCache); self }
1258    /// Specifies that the request was served from the ServiceWorker.
1259    pub fn fromServiceWorker(mut self, fromServiceWorker: bool) -> Self { self.fromServiceWorker = Some(fromServiceWorker); self }
1260    /// Specifies that the request was served from the prefetch cache.
1261    pub fn fromPrefetchCache(mut self, fromPrefetchCache: bool) -> Self { self.fromPrefetchCache = Some(fromPrefetchCache); self }
1262    /// Specifies that the request was served from the prefetch cache.
1263    pub fn fromEarlyHints(mut self, fromEarlyHints: bool) -> Self { self.fromEarlyHints = Some(fromEarlyHints); self }
1264    /// Information about how ServiceWorker Static Router API was used. If this
1265    /// field is set with 'matchedSourceType' field, a matching rule is found.
1266    /// If this field is set without 'matchedSource', no matching rule is found.
1267    /// Otherwise, the API is not used.
1268    pub fn serviceWorkerRouterInfo(mut self, serviceWorkerRouterInfo: ServiceWorkerRouterInfo) -> Self { self.serviceWorkerRouterInfo = Some(serviceWorkerRouterInfo); self }
1269    /// Timing information for the given request.
1270    pub fn timing(mut self, timing: ResourceTiming) -> Self { self.timing = Some(timing); self }
1271    /// Response source of response from ServiceWorker.
1272    pub fn serviceWorkerResponseSource(mut self, serviceWorkerResponseSource: ServiceWorkerResponseSource) -> Self { self.serviceWorkerResponseSource = Some(serviceWorkerResponseSource); self }
1273    /// The time at which the returned response was generated.
1274    pub fn responseTime(mut self, responseTime: TimeSinceEpoch) -> Self { self.responseTime = Some(responseTime); self }
1275    /// Cache Storage Cache Name.
1276    pub fn cacheStorageCacheName(mut self, cacheStorageCacheName: impl Into<Cow<'a, str>>) -> Self { self.cacheStorageCacheName = Some(cacheStorageCacheName.into()); self }
1277    /// Protocol used to fetch this request.
1278    pub fn protocol(mut self, protocol: impl Into<Cow<'a, str>>) -> Self { self.protocol = Some(protocol.into()); self }
1279    /// The reason why Chrome uses a specific transport protocol for HTTP semantics.
1280    pub fn alternateProtocolUsage(mut self, alternateProtocolUsage: AlternateProtocolUsage) -> Self { self.alternateProtocolUsage = Some(alternateProtocolUsage); self }
1281    /// Security details for the request.
1282    pub fn securityDetails(mut self, securityDetails: SecurityDetails<'a>) -> Self { self.securityDetails = Some(securityDetails); self }
1283    pub fn build(self) -> Response<'a> {
1284        Response {
1285            url: self.url,
1286            status: self.status,
1287            statusText: self.statusText,
1288            headers: self.headers,
1289            headersText: self.headersText,
1290            mimeType: self.mimeType,
1291            charset: self.charset,
1292            requestHeaders: self.requestHeaders,
1293            requestHeadersText: self.requestHeadersText,
1294            connectionReused: self.connectionReused,
1295            connectionId: self.connectionId,
1296            remoteIPAddress: self.remoteIPAddress,
1297            remotePort: self.remotePort,
1298            fromDiskCache: self.fromDiskCache,
1299            fromServiceWorker: self.fromServiceWorker,
1300            fromPrefetchCache: self.fromPrefetchCache,
1301            fromEarlyHints: self.fromEarlyHints,
1302            serviceWorkerRouterInfo: self.serviceWorkerRouterInfo,
1303            encodedDataLength: self.encodedDataLength,
1304            timing: self.timing,
1305            serviceWorkerResponseSource: self.serviceWorkerResponseSource,
1306            responseTime: self.responseTime,
1307            cacheStorageCacheName: self.cacheStorageCacheName,
1308            protocol: self.protocol,
1309            alternateProtocolUsage: self.alternateProtocolUsage,
1310            securityState: self.securityState,
1311            securityDetails: self.securityDetails,
1312        }
1313    }
1314}
1315
1316/// WebSocket request data.
1317
1318#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1319#[serde(rename_all = "camelCase")]
1320pub struct WebSocketRequest {
1321    /// HTTP request headers.
1322    headers: Headers,
1323}
1324
1325impl WebSocketRequest {
1326    pub fn builder(headers: Headers) -> WebSocketRequestBuilder {
1327        WebSocketRequestBuilder {
1328            headers: headers,
1329        }
1330    }
1331    pub fn headers(&self) -> &Headers { &self.headers }
1332}
1333
1334
1335pub struct WebSocketRequestBuilder {
1336    headers: Headers,
1337}
1338
1339impl WebSocketRequestBuilder {
1340    pub fn build(self) -> WebSocketRequest {
1341        WebSocketRequest {
1342            headers: self.headers,
1343        }
1344    }
1345}
1346
1347/// WebSocket response data.
1348
1349#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1350#[serde(rename_all = "camelCase")]
1351pub struct WebSocketResponse<'a> {
1352    /// HTTP response status code.
1353    status: i64,
1354    /// HTTP response status text.
1355    statusText: Cow<'a, str>,
1356    /// HTTP response headers.
1357    headers: Headers,
1358    /// HTTP response headers text.
1359    #[serde(skip_serializing_if = "Option::is_none")]
1360    headersText: Option<Cow<'a, str>>,
1361    /// HTTP request headers.
1362    #[serde(skip_serializing_if = "Option::is_none")]
1363    requestHeaders: Option<Headers>,
1364    /// HTTP request headers text.
1365    #[serde(skip_serializing_if = "Option::is_none")]
1366    requestHeadersText: Option<Cow<'a, str>>,
1367}
1368
1369impl<'a> WebSocketResponse<'a> {
1370    pub fn builder(status: i64, statusText: impl Into<Cow<'a, str>>, headers: Headers) -> WebSocketResponseBuilder<'a> {
1371        WebSocketResponseBuilder {
1372            status: status,
1373            statusText: statusText.into(),
1374            headers: headers,
1375            headersText: None,
1376            requestHeaders: None,
1377            requestHeadersText: None,
1378        }
1379    }
1380    pub fn status(&self) -> i64 { self.status }
1381    pub fn statusText(&self) -> &str { self.statusText.as_ref() }
1382    pub fn headers(&self) -> &Headers { &self.headers }
1383    pub fn headersText(&self) -> Option<&str> { self.headersText.as_deref() }
1384    pub fn requestHeaders(&self) -> Option<&Headers> { self.requestHeaders.as_ref() }
1385    pub fn requestHeadersText(&self) -> Option<&str> { self.requestHeadersText.as_deref() }
1386}
1387
1388
1389pub struct WebSocketResponseBuilder<'a> {
1390    status: i64,
1391    statusText: Cow<'a, str>,
1392    headers: Headers,
1393    headersText: Option<Cow<'a, str>>,
1394    requestHeaders: Option<Headers>,
1395    requestHeadersText: Option<Cow<'a, str>>,
1396}
1397
1398impl<'a> WebSocketResponseBuilder<'a> {
1399    /// HTTP response headers text.
1400    pub fn headersText(mut self, headersText: impl Into<Cow<'a, str>>) -> Self { self.headersText = Some(headersText.into()); self }
1401    /// HTTP request headers.
1402    pub fn requestHeaders(mut self, requestHeaders: Headers) -> Self { self.requestHeaders = Some(requestHeaders); self }
1403    /// HTTP request headers text.
1404    pub fn requestHeadersText(mut self, requestHeadersText: impl Into<Cow<'a, str>>) -> Self { self.requestHeadersText = Some(requestHeadersText.into()); self }
1405    pub fn build(self) -> WebSocketResponse<'a> {
1406        WebSocketResponse {
1407            status: self.status,
1408            statusText: self.statusText,
1409            headers: self.headers,
1410            headersText: self.headersText,
1411            requestHeaders: self.requestHeaders,
1412            requestHeadersText: self.requestHeadersText,
1413        }
1414    }
1415}
1416
1417/// WebSocket message data. This represents an entire WebSocket message, not just a fragmented frame as the name suggests.
1418
1419#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1420#[serde(rename_all = "camelCase")]
1421pub struct WebSocketFrame<'a> {
1422    /// WebSocket message opcode.
1423    opcode: f64,
1424    /// WebSocket message mask.
1425    mask: bool,
1426    /// WebSocket message payload data.
1427    /// If the opcode is 1, this is a text message and payloadData is a UTF-8 string.
1428    /// If the opcode isn't 1, then payloadData is a base64 encoded string representing binary data.
1429    payloadData: Cow<'a, str>,
1430}
1431
1432impl<'a> WebSocketFrame<'a> {
1433    pub fn builder(opcode: f64, mask: bool, payloadData: impl Into<Cow<'a, str>>) -> WebSocketFrameBuilder<'a> {
1434        WebSocketFrameBuilder {
1435            opcode: opcode,
1436            mask: mask,
1437            payloadData: payloadData.into(),
1438        }
1439    }
1440    pub fn opcode(&self) -> f64 { self.opcode }
1441    pub fn mask(&self) -> bool { self.mask }
1442    pub fn payloadData(&self) -> &str { self.payloadData.as_ref() }
1443}
1444
1445
1446pub struct WebSocketFrameBuilder<'a> {
1447    opcode: f64,
1448    mask: bool,
1449    payloadData: Cow<'a, str>,
1450}
1451
1452impl<'a> WebSocketFrameBuilder<'a> {
1453    pub fn build(self) -> WebSocketFrame<'a> {
1454        WebSocketFrame {
1455            opcode: self.opcode,
1456            mask: self.mask,
1457            payloadData: self.payloadData,
1458        }
1459    }
1460}
1461
1462/// Information about the cached resource.
1463
1464#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1465#[serde(rename_all = "camelCase")]
1466pub struct CachedResource<'a> {
1467    /// Resource URL. This is the url of the original network request.
1468    url: Cow<'a, str>,
1469    /// Type of this resource.
1470    #[serde(rename = "type")]
1471    type_: ResourceType,
1472    /// Cached response data.
1473    #[serde(skip_serializing_if = "Option::is_none")]
1474    response: Option<Response<'a>>,
1475    /// Cached response body size.
1476    bodySize: f64,
1477}
1478
1479impl<'a> CachedResource<'a> {
1480    pub fn builder(url: impl Into<Cow<'a, str>>, type_: ResourceType, bodySize: f64) -> CachedResourceBuilder<'a> {
1481        CachedResourceBuilder {
1482            url: url.into(),
1483            type_: type_,
1484            response: None,
1485            bodySize: bodySize,
1486        }
1487    }
1488    pub fn url(&self) -> &str { self.url.as_ref() }
1489    pub fn type_(&self) -> &ResourceType { &self.type_ }
1490    pub fn response(&self) -> Option<&Response<'a>> { self.response.as_ref() }
1491    pub fn bodySize(&self) -> f64 { self.bodySize }
1492}
1493
1494
1495pub struct CachedResourceBuilder<'a> {
1496    url: Cow<'a, str>,
1497    type_: ResourceType,
1498    response: Option<Response<'a>>,
1499    bodySize: f64,
1500}
1501
1502impl<'a> CachedResourceBuilder<'a> {
1503    /// Cached response data.
1504    pub fn response(mut self, response: Response<'a>) -> Self { self.response = Some(response); self }
1505    pub fn build(self) -> CachedResource<'a> {
1506        CachedResource {
1507            url: self.url,
1508            type_: self.type_,
1509            response: self.response,
1510            bodySize: self.bodySize,
1511        }
1512    }
1513}
1514
1515/// Information about the request initiator.
1516
1517#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1518#[serde(rename_all = "camelCase")]
1519pub struct Initiator<'a> {
1520    /// Type of this initiator.
1521    #[serde(rename = "type")]
1522    type_: Cow<'a, str>,
1523    /// Initiator JavaScript stack trace, set for Script only.
1524    /// Requires the Debugger domain to be enabled.
1525    #[serde(skip_serializing_if = "Option::is_none")]
1526    stack: Option<crate::runtime::StackTrace>,
1527    /// Initiator URL, set for Parser type or for Script type (when script is importing module) or for SignedExchange type.
1528    #[serde(skip_serializing_if = "Option::is_none")]
1529    url: Option<Cow<'a, str>>,
1530    /// Initiator line number, set for Parser type or for Script type (when script is importing
1531    /// module) (0-based).
1532    #[serde(skip_serializing_if = "Option::is_none")]
1533    lineNumber: Option<f64>,
1534    /// Initiator column number, set for Parser type or for Script type (when script is importing
1535    /// module) (0-based).
1536    #[serde(skip_serializing_if = "Option::is_none")]
1537    columnNumber: Option<f64>,
1538    /// Set if another request triggered this request (e.g. preflight).
1539    #[serde(skip_serializing_if = "Option::is_none")]
1540    requestId: Option<RequestId<'a>>,
1541}
1542
1543impl<'a> Initiator<'a> {
1544    pub fn builder(type_: impl Into<Cow<'a, str>>) -> InitiatorBuilder<'a> {
1545        InitiatorBuilder {
1546            type_: type_.into(),
1547            stack: None,
1548            url: None,
1549            lineNumber: None,
1550            columnNumber: None,
1551            requestId: None,
1552        }
1553    }
1554    pub fn type_(&self) -> &str { self.type_.as_ref() }
1555    pub fn stack(&self) -> Option<&crate::runtime::StackTrace> { self.stack.as_ref() }
1556    pub fn url(&self) -> Option<&str> { self.url.as_deref() }
1557    pub fn lineNumber(&self) -> Option<f64> { self.lineNumber }
1558    pub fn columnNumber(&self) -> Option<f64> { self.columnNumber }
1559    pub fn requestId(&self) -> Option<&RequestId<'a>> { self.requestId.as_ref() }
1560}
1561
1562
1563pub struct InitiatorBuilder<'a> {
1564    type_: Cow<'a, str>,
1565    stack: Option<crate::runtime::StackTrace>,
1566    url: Option<Cow<'a, str>>,
1567    lineNumber: Option<f64>,
1568    columnNumber: Option<f64>,
1569    requestId: Option<RequestId<'a>>,
1570}
1571
1572impl<'a> InitiatorBuilder<'a> {
1573    /// Initiator JavaScript stack trace, set for Script only.
1574    /// Requires the Debugger domain to be enabled.
1575    pub fn stack(mut self, stack: crate::runtime::StackTrace) -> Self { self.stack = Some(stack); self }
1576    /// Initiator URL, set for Parser type or for Script type (when script is importing module) or for SignedExchange type.
1577    pub fn url(mut self, url: impl Into<Cow<'a, str>>) -> Self { self.url = Some(url.into()); self }
1578    /// Initiator line number, set for Parser type or for Script type (when script is importing
1579    /// module) (0-based).
1580    pub fn lineNumber(mut self, lineNumber: f64) -> Self { self.lineNumber = Some(lineNumber); self }
1581    /// Initiator column number, set for Parser type or for Script type (when script is importing
1582    /// module) (0-based).
1583    pub fn columnNumber(mut self, columnNumber: f64) -> Self { self.columnNumber = Some(columnNumber); self }
1584    /// Set if another request triggered this request (e.g. preflight).
1585    pub fn requestId(mut self, requestId: RequestId<'a>) -> Self { self.requestId = Some(requestId); self }
1586    pub fn build(self) -> Initiator<'a> {
1587        Initiator {
1588            type_: self.type_,
1589            stack: self.stack,
1590            url: self.url,
1591            lineNumber: self.lineNumber,
1592            columnNumber: self.columnNumber,
1593            requestId: self.requestId,
1594        }
1595    }
1596}
1597
1598/// cookiePartitionKey object
1599/// The representation of the components of the key that are created by the cookiePartitionKey class contained in net/cookies/cookie_partition_key.h.
1600
1601#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1602#[serde(rename_all = "camelCase")]
1603pub struct CookiePartitionKey<'a> {
1604    /// The site of the top-level URL the browser was visiting at the start
1605    /// of the request to the endpoint that set the cookie.
1606    topLevelSite: Cow<'a, str>,
1607    /// Indicates if the cookie has any ancestors that are cross-site to the topLevelSite.
1608    hasCrossSiteAncestor: bool,
1609}
1610
1611impl<'a> CookiePartitionKey<'a> {
1612    pub fn builder(topLevelSite: impl Into<Cow<'a, str>>, hasCrossSiteAncestor: bool) -> CookiePartitionKeyBuilder<'a> {
1613        CookiePartitionKeyBuilder {
1614            topLevelSite: topLevelSite.into(),
1615            hasCrossSiteAncestor: hasCrossSiteAncestor,
1616        }
1617    }
1618    pub fn topLevelSite(&self) -> &str { self.topLevelSite.as_ref() }
1619    pub fn hasCrossSiteAncestor(&self) -> bool { self.hasCrossSiteAncestor }
1620}
1621
1622
1623pub struct CookiePartitionKeyBuilder<'a> {
1624    topLevelSite: Cow<'a, str>,
1625    hasCrossSiteAncestor: bool,
1626}
1627
1628impl<'a> CookiePartitionKeyBuilder<'a> {
1629    pub fn build(self) -> CookiePartitionKey<'a> {
1630        CookiePartitionKey {
1631            topLevelSite: self.topLevelSite,
1632            hasCrossSiteAncestor: self.hasCrossSiteAncestor,
1633        }
1634    }
1635}
1636
1637/// Cookie object
1638
1639#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1640#[serde(rename_all = "camelCase")]
1641pub struct Cookie<'a> {
1642    /// Cookie name.
1643    name: Cow<'a, str>,
1644    /// Cookie value.
1645    value: Cow<'a, str>,
1646    /// Cookie domain.
1647    domain: Cow<'a, str>,
1648    /// Cookie path.
1649    path: Cow<'a, str>,
1650    /// Cookie expiration date as the number of seconds since the UNIX epoch.
1651    /// The value is set to -1 if the expiry date is not set.
1652    /// The value can be null for values that cannot be represented in
1653    /// JSON (±Inf).
1654    expires: f64,
1655    /// Cookie size.
1656    size: u64,
1657    /// True if cookie is http-only.
1658    httpOnly: bool,
1659    /// True if cookie is secure.
1660    secure: bool,
1661    /// True in case of session cookie.
1662    session: bool,
1663    /// Cookie SameSite type.
1664    #[serde(skip_serializing_if = "Option::is_none")]
1665    sameSite: Option<CookieSameSite>,
1666    /// Cookie Priority
1667    priority: CookiePriority,
1668    /// Cookie source scheme type.
1669    sourceScheme: CookieSourceScheme,
1670    /// Cookie source port. Valid values are {-1, [1, 65535]}, -1 indicates an unspecified port.
1671    /// An unspecified port value allows protocol clients to emulate legacy cookie scope for the port.
1672    /// This is a temporary ability and it will be removed in the future.
1673    sourcePort: i64,
1674    /// Cookie partition key.
1675    #[serde(skip_serializing_if = "Option::is_none")]
1676    partitionKey: Option<CookiePartitionKey<'a>>,
1677    /// True if cookie partition key is opaque.
1678    #[serde(skip_serializing_if = "Option::is_none")]
1679    partitionKeyOpaque: Option<bool>,
1680}
1681
1682impl<'a> Cookie<'a> {
1683    pub fn builder(name: impl Into<Cow<'a, str>>, value: impl Into<Cow<'a, str>>, domain: impl Into<Cow<'a, str>>, path: impl Into<Cow<'a, str>>, expires: f64, size: u64, httpOnly: bool, secure: bool, session: bool, priority: CookiePriority, sourceScheme: CookieSourceScheme, sourcePort: i64) -> CookieBuilder<'a> {
1684        CookieBuilder {
1685            name: name.into(),
1686            value: value.into(),
1687            domain: domain.into(),
1688            path: path.into(),
1689            expires: expires,
1690            size: size,
1691            httpOnly: httpOnly,
1692            secure: secure,
1693            session: session,
1694            sameSite: None,
1695            priority: priority,
1696            sourceScheme: sourceScheme,
1697            sourcePort: sourcePort,
1698            partitionKey: None,
1699            partitionKeyOpaque: None,
1700        }
1701    }
1702    pub fn name(&self) -> &str { self.name.as_ref() }
1703    pub fn value(&self) -> &str { self.value.as_ref() }
1704    pub fn domain(&self) -> &str { self.domain.as_ref() }
1705    pub fn path(&self) -> &str { self.path.as_ref() }
1706    pub fn expires(&self) -> f64 { self.expires }
1707    pub fn size(&self) -> u64 { self.size }
1708    pub fn httpOnly(&self) -> bool { self.httpOnly }
1709    pub fn secure(&self) -> bool { self.secure }
1710    pub fn session(&self) -> bool { self.session }
1711    pub fn sameSite(&self) -> Option<&CookieSameSite> { self.sameSite.as_ref() }
1712    pub fn priority(&self) -> &CookiePriority { &self.priority }
1713    pub fn sourceScheme(&self) -> &CookieSourceScheme { &self.sourceScheme }
1714    pub fn sourcePort(&self) -> i64 { self.sourcePort }
1715    pub fn partitionKey(&self) -> Option<&CookiePartitionKey<'a>> { self.partitionKey.as_ref() }
1716    pub fn partitionKeyOpaque(&self) -> Option<bool> { self.partitionKeyOpaque }
1717}
1718
1719
1720pub struct CookieBuilder<'a> {
1721    name: Cow<'a, str>,
1722    value: Cow<'a, str>,
1723    domain: Cow<'a, str>,
1724    path: Cow<'a, str>,
1725    expires: f64,
1726    size: u64,
1727    httpOnly: bool,
1728    secure: bool,
1729    session: bool,
1730    sameSite: Option<CookieSameSite>,
1731    priority: CookiePriority,
1732    sourceScheme: CookieSourceScheme,
1733    sourcePort: i64,
1734    partitionKey: Option<CookiePartitionKey<'a>>,
1735    partitionKeyOpaque: Option<bool>,
1736}
1737
1738impl<'a> CookieBuilder<'a> {
1739    /// Cookie SameSite type.
1740    pub fn sameSite(mut self, sameSite: CookieSameSite) -> Self { self.sameSite = Some(sameSite); self }
1741    /// Cookie partition key.
1742    pub fn partitionKey(mut self, partitionKey: CookiePartitionKey<'a>) -> Self { self.partitionKey = Some(partitionKey); self }
1743    /// True if cookie partition key is opaque.
1744    pub fn partitionKeyOpaque(mut self, partitionKeyOpaque: bool) -> Self { self.partitionKeyOpaque = Some(partitionKeyOpaque); self }
1745    pub fn build(self) -> Cookie<'a> {
1746        Cookie {
1747            name: self.name,
1748            value: self.value,
1749            domain: self.domain,
1750            path: self.path,
1751            expires: self.expires,
1752            size: self.size,
1753            httpOnly: self.httpOnly,
1754            secure: self.secure,
1755            session: self.session,
1756            sameSite: self.sameSite,
1757            priority: self.priority,
1758            sourceScheme: self.sourceScheme,
1759            sourcePort: self.sourcePort,
1760            partitionKey: self.partitionKey,
1761            partitionKeyOpaque: self.partitionKeyOpaque,
1762        }
1763    }
1764}
1765
1766/// Types of reasons why a cookie may not be stored from a response.
1767
1768#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
1769pub enum SetCookieBlockedReason {
1770    #[default]
1771    #[serde(rename = "SecureOnly")]
1772    SecureOnly,
1773    #[serde(rename = "SameSiteStrict")]
1774    SameSiteStrict,
1775    #[serde(rename = "SameSiteLax")]
1776    SameSiteLax,
1777    #[serde(rename = "SameSiteUnspecifiedTreatedAsLax")]
1778    SameSiteUnspecifiedTreatedAsLax,
1779    #[serde(rename = "SameSiteNoneInsecure")]
1780    SameSiteNoneInsecure,
1781    #[serde(rename = "UserPreferences")]
1782    UserPreferences,
1783    #[serde(rename = "ThirdPartyPhaseout")]
1784    ThirdPartyPhaseout,
1785    #[serde(rename = "ThirdPartyBlockedInFirstPartySet")]
1786    ThirdPartyBlockedInFirstPartySet,
1787    #[serde(rename = "SyntaxError")]
1788    SyntaxError,
1789    #[serde(rename = "SchemeNotSupported")]
1790    SchemeNotSupported,
1791    #[serde(rename = "OverwriteSecure")]
1792    OverwriteSecure,
1793    #[serde(rename = "InvalidDomain")]
1794    InvalidDomain,
1795    #[serde(rename = "InvalidPrefix")]
1796    InvalidPrefix,
1797    #[serde(rename = "UnknownError")]
1798    UnknownError,
1799    #[serde(rename = "SchemefulSameSiteStrict")]
1800    SchemefulSameSiteStrict,
1801    #[serde(rename = "SchemefulSameSiteLax")]
1802    SchemefulSameSiteLax,
1803    #[serde(rename = "SchemefulSameSiteUnspecifiedTreatedAsLax")]
1804    SchemefulSameSiteUnspecifiedTreatedAsLax,
1805    #[serde(rename = "NameValuePairExceedsMaxSize")]
1806    NameValuePairExceedsMaxSize,
1807    #[serde(rename = "DisallowedCharacter")]
1808    DisallowedCharacter,
1809    #[serde(rename = "NoCookieContent")]
1810    NoCookieContent,
1811}
1812
1813/// Types of reasons why a cookie may not be sent with a request.
1814
1815#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
1816pub enum CookieBlockedReason {
1817    #[default]
1818    #[serde(rename = "SecureOnly")]
1819    SecureOnly,
1820    #[serde(rename = "NotOnPath")]
1821    NotOnPath,
1822    #[serde(rename = "DomainMismatch")]
1823    DomainMismatch,
1824    #[serde(rename = "SameSiteStrict")]
1825    SameSiteStrict,
1826    #[serde(rename = "SameSiteLax")]
1827    SameSiteLax,
1828    #[serde(rename = "SameSiteUnspecifiedTreatedAsLax")]
1829    SameSiteUnspecifiedTreatedAsLax,
1830    #[serde(rename = "SameSiteNoneInsecure")]
1831    SameSiteNoneInsecure,
1832    #[serde(rename = "UserPreferences")]
1833    UserPreferences,
1834    #[serde(rename = "ThirdPartyPhaseout")]
1835    ThirdPartyPhaseout,
1836    #[serde(rename = "ThirdPartyBlockedInFirstPartySet")]
1837    ThirdPartyBlockedInFirstPartySet,
1838    #[serde(rename = "UnknownError")]
1839    UnknownError,
1840    #[serde(rename = "SchemefulSameSiteStrict")]
1841    SchemefulSameSiteStrict,
1842    #[serde(rename = "SchemefulSameSiteLax")]
1843    SchemefulSameSiteLax,
1844    #[serde(rename = "SchemefulSameSiteUnspecifiedTreatedAsLax")]
1845    SchemefulSameSiteUnspecifiedTreatedAsLax,
1846    #[serde(rename = "NameValuePairExceedsMaxSize")]
1847    NameValuePairExceedsMaxSize,
1848    #[serde(rename = "PortMismatch")]
1849    PortMismatch,
1850    #[serde(rename = "SchemeMismatch")]
1851    SchemeMismatch,
1852    #[serde(rename = "AnonymousContext")]
1853    AnonymousContext,
1854}
1855
1856/// Types of reasons why a cookie should have been blocked by 3PCD but is exempted for the request.
1857
1858#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
1859pub enum CookieExemptionReason {
1860    #[default]
1861    #[serde(rename = "None")]
1862    None,
1863    #[serde(rename = "UserSetting")]
1864    UserSetting,
1865    #[serde(rename = "TPCDMetadata")]
1866    TPCDMetadata,
1867    #[serde(rename = "TPCDDeprecationTrial")]
1868    TPCDDeprecationTrial,
1869    #[serde(rename = "TopLevelTPCDDeprecationTrial")]
1870    TopLevelTPCDDeprecationTrial,
1871    #[serde(rename = "TPCDHeuristics")]
1872    TPCDHeuristics,
1873    #[serde(rename = "EnterprisePolicy")]
1874    EnterprisePolicy,
1875    #[serde(rename = "StorageAccess")]
1876    StorageAccess,
1877    #[serde(rename = "TopLevelStorageAccess")]
1878    TopLevelStorageAccess,
1879    #[serde(rename = "Scheme")]
1880    Scheme,
1881    #[serde(rename = "SameSiteNoneCookiesInSandbox")]
1882    SameSiteNoneCookiesInSandbox,
1883}
1884
1885/// A cookie which was not stored from a response with the corresponding reason.
1886
1887#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1888#[serde(rename_all = "camelCase")]
1889pub struct BlockedSetCookieWithReason<'a> {
1890    /// The reason(s) this cookie was blocked.
1891    blockedReasons: Vec<SetCookieBlockedReason>,
1892    /// The string representing this individual cookie as it would appear in the header.
1893    /// This is not the entire "cookie" or "set-cookie" header which could have multiple cookies.
1894    cookieLine: Cow<'a, str>,
1895    /// The cookie object which represents the cookie which was not stored. It is optional because
1896    /// sometimes complete cookie information is not available, such as in the case of parsing
1897    /// errors.
1898    #[serde(skip_serializing_if = "Option::is_none")]
1899    cookie: Option<Cookie<'a>>,
1900}
1901
1902impl<'a> BlockedSetCookieWithReason<'a> {
1903    pub fn builder(blockedReasons: Vec<SetCookieBlockedReason>, cookieLine: impl Into<Cow<'a, str>>) -> BlockedSetCookieWithReasonBuilder<'a> {
1904        BlockedSetCookieWithReasonBuilder {
1905            blockedReasons: blockedReasons,
1906            cookieLine: cookieLine.into(),
1907            cookie: None,
1908        }
1909    }
1910    pub fn blockedReasons(&self) -> &[SetCookieBlockedReason] { &self.blockedReasons }
1911    pub fn cookieLine(&self) -> &str { self.cookieLine.as_ref() }
1912    pub fn cookie(&self) -> Option<&Cookie<'a>> { self.cookie.as_ref() }
1913}
1914
1915
1916pub struct BlockedSetCookieWithReasonBuilder<'a> {
1917    blockedReasons: Vec<SetCookieBlockedReason>,
1918    cookieLine: Cow<'a, str>,
1919    cookie: Option<Cookie<'a>>,
1920}
1921
1922impl<'a> BlockedSetCookieWithReasonBuilder<'a> {
1923    /// The cookie object which represents the cookie which was not stored. It is optional because
1924    /// sometimes complete cookie information is not available, such as in the case of parsing
1925    /// errors.
1926    pub fn cookie(mut self, cookie: Cookie<'a>) -> Self { self.cookie = Some(cookie); self }
1927    pub fn build(self) -> BlockedSetCookieWithReason<'a> {
1928        BlockedSetCookieWithReason {
1929            blockedReasons: self.blockedReasons,
1930            cookieLine: self.cookieLine,
1931            cookie: self.cookie,
1932        }
1933    }
1934}
1935
1936/// A cookie should have been blocked by 3PCD but is exempted and stored from a response with the
1937/// corresponding reason. A cookie could only have at most one exemption reason.
1938
1939#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1940#[serde(rename_all = "camelCase")]
1941pub struct ExemptedSetCookieWithReason<'a> {
1942    /// The reason the cookie was exempted.
1943    exemptionReason: CookieExemptionReason,
1944    /// The string representing this individual cookie as it would appear in the header.
1945    cookieLine: Cow<'a, str>,
1946    /// The cookie object representing the cookie.
1947    cookie: Cookie<'a>,
1948}
1949
1950impl<'a> ExemptedSetCookieWithReason<'a> {
1951    pub fn builder(exemptionReason: CookieExemptionReason, cookieLine: impl Into<Cow<'a, str>>, cookie: Cookie<'a>) -> ExemptedSetCookieWithReasonBuilder<'a> {
1952        ExemptedSetCookieWithReasonBuilder {
1953            exemptionReason: exemptionReason,
1954            cookieLine: cookieLine.into(),
1955            cookie: cookie,
1956        }
1957    }
1958    pub fn exemptionReason(&self) -> &CookieExemptionReason { &self.exemptionReason }
1959    pub fn cookieLine(&self) -> &str { self.cookieLine.as_ref() }
1960    pub fn cookie(&self) -> &Cookie<'a> { &self.cookie }
1961}
1962
1963
1964pub struct ExemptedSetCookieWithReasonBuilder<'a> {
1965    exemptionReason: CookieExemptionReason,
1966    cookieLine: Cow<'a, str>,
1967    cookie: Cookie<'a>,
1968}
1969
1970impl<'a> ExemptedSetCookieWithReasonBuilder<'a> {
1971    pub fn build(self) -> ExemptedSetCookieWithReason<'a> {
1972        ExemptedSetCookieWithReason {
1973            exemptionReason: self.exemptionReason,
1974            cookieLine: self.cookieLine,
1975            cookie: self.cookie,
1976        }
1977    }
1978}
1979
1980/// A cookie associated with the request which may or may not be sent with it.
1981/// Includes the cookies itself and reasons for blocking or exemption.
1982
1983#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1984#[serde(rename_all = "camelCase")]
1985pub struct AssociatedCookie<'a> {
1986    /// The cookie object representing the cookie which was not sent.
1987    cookie: Cookie<'a>,
1988    /// The reason(s) the cookie was blocked. If empty means the cookie is included.
1989    blockedReasons: Vec<CookieBlockedReason>,
1990    /// The reason the cookie should have been blocked by 3PCD but is exempted. A cookie could
1991    /// only have at most one exemption reason.
1992    #[serde(skip_serializing_if = "Option::is_none")]
1993    exemptionReason: Option<CookieExemptionReason>,
1994}
1995
1996impl<'a> AssociatedCookie<'a> {
1997    pub fn builder(cookie: Cookie<'a>, blockedReasons: Vec<CookieBlockedReason>) -> AssociatedCookieBuilder<'a> {
1998        AssociatedCookieBuilder {
1999            cookie: cookie,
2000            blockedReasons: blockedReasons,
2001            exemptionReason: None,
2002        }
2003    }
2004    pub fn cookie(&self) -> &Cookie<'a> { &self.cookie }
2005    pub fn blockedReasons(&self) -> &[CookieBlockedReason] { &self.blockedReasons }
2006    pub fn exemptionReason(&self) -> Option<&CookieExemptionReason> { self.exemptionReason.as_ref() }
2007}
2008
2009
2010pub struct AssociatedCookieBuilder<'a> {
2011    cookie: Cookie<'a>,
2012    blockedReasons: Vec<CookieBlockedReason>,
2013    exemptionReason: Option<CookieExemptionReason>,
2014}
2015
2016impl<'a> AssociatedCookieBuilder<'a> {
2017    /// The reason the cookie should have been blocked by 3PCD but is exempted. A cookie could
2018    /// only have at most one exemption reason.
2019    pub fn exemptionReason(mut self, exemptionReason: CookieExemptionReason) -> Self { self.exemptionReason = Some(exemptionReason); self }
2020    pub fn build(self) -> AssociatedCookie<'a> {
2021        AssociatedCookie {
2022            cookie: self.cookie,
2023            blockedReasons: self.blockedReasons,
2024            exemptionReason: self.exemptionReason,
2025        }
2026    }
2027}
2028
2029/// Cookie parameter object
2030
2031#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2032#[serde(rename_all = "camelCase")]
2033pub struct CookieParam<'a> {
2034    /// Cookie name.
2035    name: Cow<'a, str>,
2036    /// Cookie value.
2037    value: Cow<'a, str>,
2038    /// The request-URI to associate with the setting of the cookie. This value can affect the
2039    /// default domain, path, source port, and source scheme values of the created cookie.
2040    #[serde(skip_serializing_if = "Option::is_none")]
2041    url: Option<Cow<'a, str>>,
2042    /// Cookie domain.
2043    #[serde(skip_serializing_if = "Option::is_none")]
2044    domain: Option<Cow<'a, str>>,
2045    /// Cookie path.
2046    #[serde(skip_serializing_if = "Option::is_none")]
2047    path: Option<Cow<'a, str>>,
2048    /// True if cookie is secure.
2049    #[serde(skip_serializing_if = "Option::is_none")]
2050    secure: Option<bool>,
2051    /// True if cookie is http-only.
2052    #[serde(skip_serializing_if = "Option::is_none")]
2053    httpOnly: Option<bool>,
2054    /// Cookie SameSite type.
2055    #[serde(skip_serializing_if = "Option::is_none")]
2056    sameSite: Option<CookieSameSite>,
2057    /// Cookie expiration date, session cookie if not set
2058    #[serde(skip_serializing_if = "Option::is_none")]
2059    expires: Option<TimeSinceEpoch>,
2060    /// Cookie Priority.
2061    #[serde(skip_serializing_if = "Option::is_none")]
2062    priority: Option<CookiePriority>,
2063    /// Cookie source scheme type.
2064    #[serde(skip_serializing_if = "Option::is_none")]
2065    sourceScheme: Option<CookieSourceScheme>,
2066    /// Cookie source port. Valid values are {-1, [1, 65535]}, -1 indicates an unspecified port.
2067    /// An unspecified port value allows protocol clients to emulate legacy cookie scope for the port.
2068    /// This is a temporary ability and it will be removed in the future.
2069    #[serde(skip_serializing_if = "Option::is_none")]
2070    sourcePort: Option<i64>,
2071    /// Cookie partition key. If not set, the cookie will be set as not partitioned.
2072    #[serde(skip_serializing_if = "Option::is_none")]
2073    partitionKey: Option<CookiePartitionKey<'a>>,
2074}
2075
2076impl<'a> CookieParam<'a> {
2077    pub fn builder(name: impl Into<Cow<'a, str>>, value: impl Into<Cow<'a, str>>) -> CookieParamBuilder<'a> {
2078        CookieParamBuilder {
2079            name: name.into(),
2080            value: value.into(),
2081            url: None,
2082            domain: None,
2083            path: None,
2084            secure: None,
2085            httpOnly: None,
2086            sameSite: None,
2087            expires: None,
2088            priority: None,
2089            sourceScheme: None,
2090            sourcePort: None,
2091            partitionKey: None,
2092        }
2093    }
2094    pub fn name(&self) -> &str { self.name.as_ref() }
2095    pub fn value(&self) -> &str { self.value.as_ref() }
2096    pub fn url(&self) -> Option<&str> { self.url.as_deref() }
2097    pub fn domain(&self) -> Option<&str> { self.domain.as_deref() }
2098    pub fn path(&self) -> Option<&str> { self.path.as_deref() }
2099    pub fn secure(&self) -> Option<bool> { self.secure }
2100    pub fn httpOnly(&self) -> Option<bool> { self.httpOnly }
2101    pub fn sameSite(&self) -> Option<&CookieSameSite> { self.sameSite.as_ref() }
2102    pub fn expires(&self) -> Option<&TimeSinceEpoch> { self.expires.as_ref() }
2103    pub fn priority(&self) -> Option<&CookiePriority> { self.priority.as_ref() }
2104    pub fn sourceScheme(&self) -> Option<&CookieSourceScheme> { self.sourceScheme.as_ref() }
2105    pub fn sourcePort(&self) -> Option<i64> { self.sourcePort }
2106    pub fn partitionKey(&self) -> Option<&CookiePartitionKey<'a>> { self.partitionKey.as_ref() }
2107}
2108
2109
2110pub struct CookieParamBuilder<'a> {
2111    name: Cow<'a, str>,
2112    value: Cow<'a, str>,
2113    url: Option<Cow<'a, str>>,
2114    domain: Option<Cow<'a, str>>,
2115    path: Option<Cow<'a, str>>,
2116    secure: Option<bool>,
2117    httpOnly: Option<bool>,
2118    sameSite: Option<CookieSameSite>,
2119    expires: Option<TimeSinceEpoch>,
2120    priority: Option<CookiePriority>,
2121    sourceScheme: Option<CookieSourceScheme>,
2122    sourcePort: Option<i64>,
2123    partitionKey: Option<CookiePartitionKey<'a>>,
2124}
2125
2126impl<'a> CookieParamBuilder<'a> {
2127    /// The request-URI to associate with the setting of the cookie. This value can affect the
2128    /// default domain, path, source port, and source scheme values of the created cookie.
2129    pub fn url(mut self, url: impl Into<Cow<'a, str>>) -> Self { self.url = Some(url.into()); self }
2130    /// Cookie domain.
2131    pub fn domain(mut self, domain: impl Into<Cow<'a, str>>) -> Self { self.domain = Some(domain.into()); self }
2132    /// Cookie path.
2133    pub fn path(mut self, path: impl Into<Cow<'a, str>>) -> Self { self.path = Some(path.into()); self }
2134    /// True if cookie is secure.
2135    pub fn secure(mut self, secure: bool) -> Self { self.secure = Some(secure); self }
2136    /// True if cookie is http-only.
2137    pub fn httpOnly(mut self, httpOnly: bool) -> Self { self.httpOnly = Some(httpOnly); self }
2138    /// Cookie SameSite type.
2139    pub fn sameSite(mut self, sameSite: CookieSameSite) -> Self { self.sameSite = Some(sameSite); self }
2140    /// Cookie expiration date, session cookie if not set
2141    pub fn expires(mut self, expires: TimeSinceEpoch) -> Self { self.expires = Some(expires); self }
2142    /// Cookie Priority.
2143    pub fn priority(mut self, priority: CookiePriority) -> Self { self.priority = Some(priority); self }
2144    /// Cookie source scheme type.
2145    pub fn sourceScheme(mut self, sourceScheme: CookieSourceScheme) -> Self { self.sourceScheme = Some(sourceScheme); self }
2146    /// Cookie source port. Valid values are {-1, [1, 65535]}, -1 indicates an unspecified port.
2147    /// An unspecified port value allows protocol clients to emulate legacy cookie scope for the port.
2148    /// This is a temporary ability and it will be removed in the future.
2149    pub fn sourcePort(mut self, sourcePort: i64) -> Self { self.sourcePort = Some(sourcePort); self }
2150    /// Cookie partition key. If not set, the cookie will be set as not partitioned.
2151    pub fn partitionKey(mut self, partitionKey: CookiePartitionKey<'a>) -> Self { self.partitionKey = Some(partitionKey); self }
2152    pub fn build(self) -> CookieParam<'a> {
2153        CookieParam {
2154            name: self.name,
2155            value: self.value,
2156            url: self.url,
2157            domain: self.domain,
2158            path: self.path,
2159            secure: self.secure,
2160            httpOnly: self.httpOnly,
2161            sameSite: self.sameSite,
2162            expires: self.expires,
2163            priority: self.priority,
2164            sourceScheme: self.sourceScheme,
2165            sourcePort: self.sourcePort,
2166            partitionKey: self.partitionKey,
2167        }
2168    }
2169}
2170
2171/// Authorization challenge for HTTP status code 401 or 407.
2172
2173#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2174#[serde(rename_all = "camelCase")]
2175pub struct AuthChallenge<'a> {
2176    /// Source of the authentication challenge.
2177    #[serde(skip_serializing_if = "Option::is_none")]
2178    source: Option<Cow<'a, str>>,
2179    /// Origin of the challenger.
2180    origin: Cow<'a, str>,
2181    /// The authentication scheme used, such as basic or digest
2182    scheme: Cow<'a, str>,
2183    /// The realm of the challenge. May be empty.
2184    realm: Cow<'a, str>,
2185}
2186
2187impl<'a> AuthChallenge<'a> {
2188    pub fn builder(origin: impl Into<Cow<'a, str>>, scheme: impl Into<Cow<'a, str>>, realm: impl Into<Cow<'a, str>>) -> AuthChallengeBuilder<'a> {
2189        AuthChallengeBuilder {
2190            source: None,
2191            origin: origin.into(),
2192            scheme: scheme.into(),
2193            realm: realm.into(),
2194        }
2195    }
2196    pub fn source(&self) -> Option<&str> { self.source.as_deref() }
2197    pub fn origin(&self) -> &str { self.origin.as_ref() }
2198    pub fn scheme(&self) -> &str { self.scheme.as_ref() }
2199    pub fn realm(&self) -> &str { self.realm.as_ref() }
2200}
2201
2202
2203pub struct AuthChallengeBuilder<'a> {
2204    source: Option<Cow<'a, str>>,
2205    origin: Cow<'a, str>,
2206    scheme: Cow<'a, str>,
2207    realm: Cow<'a, str>,
2208}
2209
2210impl<'a> AuthChallengeBuilder<'a> {
2211    /// Source of the authentication challenge.
2212    pub fn source(mut self, source: impl Into<Cow<'a, str>>) -> Self { self.source = Some(source.into()); self }
2213    pub fn build(self) -> AuthChallenge<'a> {
2214        AuthChallenge {
2215            source: self.source,
2216            origin: self.origin,
2217            scheme: self.scheme,
2218            realm: self.realm,
2219        }
2220    }
2221}
2222
2223/// Response to an AuthChallenge.
2224
2225#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2226#[serde(rename_all = "camelCase")]
2227pub struct AuthChallengeResponse<'a> {
2228    /// The decision on what to do in response to the authorization challenge.  Default means
2229    /// deferring to the default behavior of the net stack, which will likely either the Cancel
2230    /// authentication or display a popup dialog box.
2231    response: Cow<'a, str>,
2232    /// The username to provide, possibly empty. Should only be set if response is
2233    /// ProvideCredentials.
2234    #[serde(skip_serializing_if = "Option::is_none")]
2235    username: Option<Cow<'a, str>>,
2236    /// The password to provide, possibly empty. Should only be set if response is
2237    /// ProvideCredentials.
2238    #[serde(skip_serializing_if = "Option::is_none")]
2239    password: Option<Cow<'a, str>>,
2240}
2241
2242impl<'a> AuthChallengeResponse<'a> {
2243    pub fn builder(response: impl Into<Cow<'a, str>>) -> AuthChallengeResponseBuilder<'a> {
2244        AuthChallengeResponseBuilder {
2245            response: response.into(),
2246            username: None,
2247            password: None,
2248        }
2249    }
2250    pub fn response(&self) -> &str { self.response.as_ref() }
2251    pub fn username(&self) -> Option<&str> { self.username.as_deref() }
2252    pub fn password(&self) -> Option<&str> { self.password.as_deref() }
2253}
2254
2255
2256pub struct AuthChallengeResponseBuilder<'a> {
2257    response: Cow<'a, str>,
2258    username: Option<Cow<'a, str>>,
2259    password: Option<Cow<'a, str>>,
2260}
2261
2262impl<'a> AuthChallengeResponseBuilder<'a> {
2263    /// The username to provide, possibly empty. Should only be set if response is
2264    /// ProvideCredentials.
2265    pub fn username(mut self, username: impl Into<Cow<'a, str>>) -> Self { self.username = Some(username.into()); self }
2266    /// The password to provide, possibly empty. Should only be set if response is
2267    /// ProvideCredentials.
2268    pub fn password(mut self, password: impl Into<Cow<'a, str>>) -> Self { self.password = Some(password.into()); self }
2269    pub fn build(self) -> AuthChallengeResponse<'a> {
2270        AuthChallengeResponse {
2271            response: self.response,
2272            username: self.username,
2273            password: self.password,
2274        }
2275    }
2276}
2277
2278/// Stages of the interception to begin intercepting. Request will intercept before the request is
2279/// sent. Response will intercept after the response is received.
2280
2281#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
2282pub enum InterceptionStage {
2283    #[default]
2284    #[serde(rename = "Request")]
2285    Request,
2286    #[serde(rename = "HeadersReceived")]
2287    HeadersReceived,
2288}
2289
2290/// Request pattern for interception.
2291
2292#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2293#[serde(rename_all = "camelCase")]
2294pub struct RequestPattern<'a> {
2295    /// Wildcards (''*'' -> zero or more, ''?'' -> exactly one) are allowed. Escape character is
2296    /// backslash. Omitting is equivalent to '"*"'.
2297    #[serde(skip_serializing_if = "Option::is_none")]
2298    urlPattern: Option<Cow<'a, str>>,
2299    /// If set, only requests for matching resource types will be intercepted.
2300    #[serde(skip_serializing_if = "Option::is_none")]
2301    resourceType: Option<ResourceType>,
2302    /// Stage at which to begin intercepting requests. Default is Request.
2303    #[serde(skip_serializing_if = "Option::is_none")]
2304    interceptionStage: Option<InterceptionStage>,
2305}
2306
2307impl<'a> RequestPattern<'a> {
2308    pub fn builder() -> RequestPatternBuilder<'a> {
2309        RequestPatternBuilder {
2310            urlPattern: None,
2311            resourceType: None,
2312            interceptionStage: None,
2313        }
2314    }
2315    pub fn urlPattern(&self) -> Option<&str> { self.urlPattern.as_deref() }
2316    pub fn resourceType(&self) -> Option<&ResourceType> { self.resourceType.as_ref() }
2317    pub fn interceptionStage(&self) -> Option<&InterceptionStage> { self.interceptionStage.as_ref() }
2318}
2319
2320#[derive(Default)]
2321pub struct RequestPatternBuilder<'a> {
2322    urlPattern: Option<Cow<'a, str>>,
2323    resourceType: Option<ResourceType>,
2324    interceptionStage: Option<InterceptionStage>,
2325}
2326
2327impl<'a> RequestPatternBuilder<'a> {
2328    /// Wildcards (''*'' -> zero or more, ''?'' -> exactly one) are allowed. Escape character is
2329    /// backslash. Omitting is equivalent to '"*"'.
2330    pub fn urlPattern(mut self, urlPattern: impl Into<Cow<'a, str>>) -> Self { self.urlPattern = Some(urlPattern.into()); self }
2331    /// If set, only requests for matching resource types will be intercepted.
2332    pub fn resourceType(mut self, resourceType: ResourceType) -> Self { self.resourceType = Some(resourceType); self }
2333    /// Stage at which to begin intercepting requests. Default is Request.
2334    pub fn interceptionStage(mut self, interceptionStage: InterceptionStage) -> Self { self.interceptionStage = Some(interceptionStage); self }
2335    pub fn build(self) -> RequestPattern<'a> {
2336        RequestPattern {
2337            urlPattern: self.urlPattern,
2338            resourceType: self.resourceType,
2339            interceptionStage: self.interceptionStage,
2340        }
2341    }
2342}
2343
2344/// Information about a signed exchange signature.
2345/// https://wicg.github.io/webpackage/draft-yasskin-httpbis-origin-signed-exchanges-impl.html#rfc.section.3.1
2346
2347#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2348#[serde(rename_all = "camelCase")]
2349pub struct SignedExchangeSignature<'a> {
2350    /// Signed exchange signature label.
2351    label: Cow<'a, str>,
2352    /// The hex string of signed exchange signature.
2353    signature: Cow<'a, str>,
2354    /// Signed exchange signature integrity.
2355    integrity: Cow<'a, str>,
2356    /// Signed exchange signature cert Url.
2357    #[serde(skip_serializing_if = "Option::is_none")]
2358    certUrl: Option<Cow<'a, str>>,
2359    /// The hex string of signed exchange signature cert sha256.
2360    #[serde(skip_serializing_if = "Option::is_none")]
2361    certSha256: Option<Cow<'a, str>>,
2362    /// Signed exchange signature validity Url.
2363    validityUrl: Cow<'a, str>,
2364    /// Signed exchange signature date.
2365    date: i64,
2366    /// Signed exchange signature expires.
2367    expires: i64,
2368    /// The encoded certificates.
2369    #[serde(skip_serializing_if = "Option::is_none")]
2370    certificates: Option<Vec<Cow<'a, str>>>,
2371}
2372
2373impl<'a> SignedExchangeSignature<'a> {
2374    pub fn builder(label: impl Into<Cow<'a, str>>, signature: impl Into<Cow<'a, str>>, integrity: impl Into<Cow<'a, str>>, validityUrl: impl Into<Cow<'a, str>>, date: i64, expires: i64) -> SignedExchangeSignatureBuilder<'a> {
2375        SignedExchangeSignatureBuilder {
2376            label: label.into(),
2377            signature: signature.into(),
2378            integrity: integrity.into(),
2379            certUrl: None,
2380            certSha256: None,
2381            validityUrl: validityUrl.into(),
2382            date: date,
2383            expires: expires,
2384            certificates: None,
2385        }
2386    }
2387    pub fn label(&self) -> &str { self.label.as_ref() }
2388    pub fn signature(&self) -> &str { self.signature.as_ref() }
2389    pub fn integrity(&self) -> &str { self.integrity.as_ref() }
2390    pub fn certUrl(&self) -> Option<&str> { self.certUrl.as_deref() }
2391    pub fn certSha256(&self) -> Option<&str> { self.certSha256.as_deref() }
2392    pub fn validityUrl(&self) -> &str { self.validityUrl.as_ref() }
2393    pub fn date(&self) -> i64 { self.date }
2394    pub fn expires(&self) -> i64 { self.expires }
2395    pub fn certificates(&self) -> Option<&[Cow<'a, str>]> { self.certificates.as_deref() }
2396}
2397
2398
2399pub struct SignedExchangeSignatureBuilder<'a> {
2400    label: Cow<'a, str>,
2401    signature: Cow<'a, str>,
2402    integrity: Cow<'a, str>,
2403    certUrl: Option<Cow<'a, str>>,
2404    certSha256: Option<Cow<'a, str>>,
2405    validityUrl: Cow<'a, str>,
2406    date: i64,
2407    expires: i64,
2408    certificates: Option<Vec<Cow<'a, str>>>,
2409}
2410
2411impl<'a> SignedExchangeSignatureBuilder<'a> {
2412    /// Signed exchange signature cert Url.
2413    pub fn certUrl(mut self, certUrl: impl Into<Cow<'a, str>>) -> Self { self.certUrl = Some(certUrl.into()); self }
2414    /// The hex string of signed exchange signature cert sha256.
2415    pub fn certSha256(mut self, certSha256: impl Into<Cow<'a, str>>) -> Self { self.certSha256 = Some(certSha256.into()); self }
2416    /// The encoded certificates.
2417    pub fn certificates(mut self, certificates: Vec<Cow<'a, str>>) -> Self { self.certificates = Some(certificates); self }
2418    pub fn build(self) -> SignedExchangeSignature<'a> {
2419        SignedExchangeSignature {
2420            label: self.label,
2421            signature: self.signature,
2422            integrity: self.integrity,
2423            certUrl: self.certUrl,
2424            certSha256: self.certSha256,
2425            validityUrl: self.validityUrl,
2426            date: self.date,
2427            expires: self.expires,
2428            certificates: self.certificates,
2429        }
2430    }
2431}
2432
2433/// Information about a signed exchange header.
2434/// https://wicg.github.io/webpackage/draft-yasskin-httpbis-origin-signed-exchanges-impl.html#cbor-representation
2435
2436#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2437#[serde(rename_all = "camelCase")]
2438pub struct SignedExchangeHeader<'a> {
2439    /// Signed exchange request URL.
2440    requestUrl: Cow<'a, str>,
2441    /// Signed exchange response code.
2442    responseCode: i64,
2443    /// Signed exchange response headers.
2444    responseHeaders: Headers,
2445    /// Signed exchange response signature.
2446    signatures: Vec<SignedExchangeSignature<'a>>,
2447    /// Signed exchange header integrity hash in the form of 'sha256-<base64-hash-value>'.
2448    headerIntegrity: Cow<'a, str>,
2449}
2450
2451impl<'a> SignedExchangeHeader<'a> {
2452    pub fn builder(requestUrl: impl Into<Cow<'a, str>>, responseCode: i64, responseHeaders: Headers, signatures: Vec<SignedExchangeSignature<'a>>, headerIntegrity: impl Into<Cow<'a, str>>) -> SignedExchangeHeaderBuilder<'a> {
2453        SignedExchangeHeaderBuilder {
2454            requestUrl: requestUrl.into(),
2455            responseCode: responseCode,
2456            responseHeaders: responseHeaders,
2457            signatures: signatures,
2458            headerIntegrity: headerIntegrity.into(),
2459        }
2460    }
2461    pub fn requestUrl(&self) -> &str { self.requestUrl.as_ref() }
2462    pub fn responseCode(&self) -> i64 { self.responseCode }
2463    pub fn responseHeaders(&self) -> &Headers { &self.responseHeaders }
2464    pub fn signatures(&self) -> &[SignedExchangeSignature<'a>] { &self.signatures }
2465    pub fn headerIntegrity(&self) -> &str { self.headerIntegrity.as_ref() }
2466}
2467
2468
2469pub struct SignedExchangeHeaderBuilder<'a> {
2470    requestUrl: Cow<'a, str>,
2471    responseCode: i64,
2472    responseHeaders: Headers,
2473    signatures: Vec<SignedExchangeSignature<'a>>,
2474    headerIntegrity: Cow<'a, str>,
2475}
2476
2477impl<'a> SignedExchangeHeaderBuilder<'a> {
2478    pub fn build(self) -> SignedExchangeHeader<'a> {
2479        SignedExchangeHeader {
2480            requestUrl: self.requestUrl,
2481            responseCode: self.responseCode,
2482            responseHeaders: self.responseHeaders,
2483            signatures: self.signatures,
2484            headerIntegrity: self.headerIntegrity,
2485        }
2486    }
2487}
2488
2489/// Field type for a signed exchange related error.
2490
2491#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
2492pub enum SignedExchangeErrorField {
2493    #[default]
2494    #[serde(rename = "signatureSig")]
2495    SignatureSig,
2496    #[serde(rename = "signatureIntegrity")]
2497    SignatureIntegrity,
2498    #[serde(rename = "signatureCertUrl")]
2499    SignatureCertUrl,
2500    #[serde(rename = "signatureCertSha256")]
2501    SignatureCertSha256,
2502    #[serde(rename = "signatureValidityUrl")]
2503    SignatureValidityUrl,
2504    #[serde(rename = "signatureTimestamps")]
2505    SignatureTimestamps,
2506}
2507
2508/// Information about a signed exchange response.
2509
2510#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2511#[serde(rename_all = "camelCase")]
2512pub struct SignedExchangeError<'a> {
2513    /// Error message.
2514    message: Cow<'a, str>,
2515    /// The index of the signature which caused the error.
2516    #[serde(skip_serializing_if = "Option::is_none")]
2517    signatureIndex: Option<u64>,
2518    /// The field which caused the error.
2519    #[serde(skip_serializing_if = "Option::is_none")]
2520    errorField: Option<SignedExchangeErrorField>,
2521}
2522
2523impl<'a> SignedExchangeError<'a> {
2524    pub fn builder(message: impl Into<Cow<'a, str>>) -> SignedExchangeErrorBuilder<'a> {
2525        SignedExchangeErrorBuilder {
2526            message: message.into(),
2527            signatureIndex: None,
2528            errorField: None,
2529        }
2530    }
2531    pub fn message(&self) -> &str { self.message.as_ref() }
2532    pub fn signatureIndex(&self) -> Option<u64> { self.signatureIndex }
2533    pub fn errorField(&self) -> Option<&SignedExchangeErrorField> { self.errorField.as_ref() }
2534}
2535
2536
2537pub struct SignedExchangeErrorBuilder<'a> {
2538    message: Cow<'a, str>,
2539    signatureIndex: Option<u64>,
2540    errorField: Option<SignedExchangeErrorField>,
2541}
2542
2543impl<'a> SignedExchangeErrorBuilder<'a> {
2544    /// The index of the signature which caused the error.
2545    pub fn signatureIndex(mut self, signatureIndex: u64) -> Self { self.signatureIndex = Some(signatureIndex); self }
2546    /// The field which caused the error.
2547    pub fn errorField(mut self, errorField: SignedExchangeErrorField) -> Self { self.errorField = Some(errorField); self }
2548    pub fn build(self) -> SignedExchangeError<'a> {
2549        SignedExchangeError {
2550            message: self.message,
2551            signatureIndex: self.signatureIndex,
2552            errorField: self.errorField,
2553        }
2554    }
2555}
2556
2557/// Information about a signed exchange response.
2558
2559#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2560#[serde(rename_all = "camelCase")]
2561pub struct SignedExchangeInfo<'a> {
2562    /// The outer response of signed HTTP exchange which was received from network.
2563    outerResponse: Response<'a>,
2564    /// Whether network response for the signed exchange was accompanied by
2565    /// extra headers.
2566    hasExtraInfo: bool,
2567    /// Information about the signed exchange header.
2568    #[serde(skip_serializing_if = "Option::is_none")]
2569    header: Option<SignedExchangeHeader<'a>>,
2570    /// Security details for the signed exchange header.
2571    #[serde(skip_serializing_if = "Option::is_none")]
2572    securityDetails: Option<SecurityDetails<'a>>,
2573    /// Errors occurred while handling the signed exchange.
2574    #[serde(skip_serializing_if = "Option::is_none")]
2575    errors: Option<Vec<SignedExchangeError<'a>>>,
2576}
2577
2578impl<'a> SignedExchangeInfo<'a> {
2579    pub fn builder(outerResponse: Response<'a>, hasExtraInfo: bool) -> SignedExchangeInfoBuilder<'a> {
2580        SignedExchangeInfoBuilder {
2581            outerResponse: outerResponse,
2582            hasExtraInfo: hasExtraInfo,
2583            header: None,
2584            securityDetails: None,
2585            errors: None,
2586        }
2587    }
2588    pub fn outerResponse(&self) -> &Response<'a> { &self.outerResponse }
2589    pub fn hasExtraInfo(&self) -> bool { self.hasExtraInfo }
2590    pub fn header(&self) -> Option<&SignedExchangeHeader<'a>> { self.header.as_ref() }
2591    pub fn securityDetails(&self) -> Option<&SecurityDetails<'a>> { self.securityDetails.as_ref() }
2592    pub fn errors(&self) -> Option<&[SignedExchangeError<'a>]> { self.errors.as_deref() }
2593}
2594
2595
2596pub struct SignedExchangeInfoBuilder<'a> {
2597    outerResponse: Response<'a>,
2598    hasExtraInfo: bool,
2599    header: Option<SignedExchangeHeader<'a>>,
2600    securityDetails: Option<SecurityDetails<'a>>,
2601    errors: Option<Vec<SignedExchangeError<'a>>>,
2602}
2603
2604impl<'a> SignedExchangeInfoBuilder<'a> {
2605    /// Information about the signed exchange header.
2606    pub fn header(mut self, header: SignedExchangeHeader<'a>) -> Self { self.header = Some(header); self }
2607    /// Security details for the signed exchange header.
2608    pub fn securityDetails(mut self, securityDetails: SecurityDetails<'a>) -> Self { self.securityDetails = Some(securityDetails); self }
2609    /// Errors occurred while handling the signed exchange.
2610    pub fn errors(mut self, errors: Vec<SignedExchangeError<'a>>) -> Self { self.errors = Some(errors); self }
2611    pub fn build(self) -> SignedExchangeInfo<'a> {
2612        SignedExchangeInfo {
2613            outerResponse: self.outerResponse,
2614            hasExtraInfo: self.hasExtraInfo,
2615            header: self.header,
2616            securityDetails: self.securityDetails,
2617            errors: self.errors,
2618        }
2619    }
2620}
2621
2622/// List of content encodings supported by the backend.
2623
2624#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
2625pub enum ContentEncoding {
2626    #[default]
2627    #[serde(rename = "deflate")]
2628    Deflate,
2629    #[serde(rename = "gzip")]
2630    Gzip,
2631    #[serde(rename = "br")]
2632    Br,
2633    #[serde(rename = "zstd")]
2634    Zstd,
2635}
2636
2637
2638#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2639#[serde(rename_all = "camelCase")]
2640pub struct NetworkConditions<'a> {
2641    /// Only matching requests will be affected by these conditions. Patterns use the URLPattern constructor string
2642    /// syntax (https://urlpattern.spec.whatwg.org/) and must be absolute. If the pattern is empty, all requests are
2643    /// matched (including p2p connections).
2644    urlPattern: Cow<'a, str>,
2645    /// Minimum latency from request sent to response headers received (ms).
2646    latency: f64,
2647    /// Maximal aggregated download throughput (bytes/sec). -1 disables download throttling.
2648    downloadThroughput: f64,
2649    /// Maximal aggregated upload throughput (bytes/sec).  -1 disables upload throttling.
2650    uploadThroughput: f64,
2651    /// Connection type if known.
2652    #[serde(skip_serializing_if = "Option::is_none")]
2653    connectionType: Option<ConnectionType>,
2654    /// WebRTC packet loss (percent, 0-100). 0 disables packet loss emulation, 100 drops all the packets.
2655    #[serde(skip_serializing_if = "Option::is_none")]
2656    packetLoss: Option<f64>,
2657    /// WebRTC packet queue length (packet). 0 removes any queue length limitations.
2658    #[serde(skip_serializing_if = "Option::is_none")]
2659    packetQueueLength: Option<u64>,
2660    /// WebRTC packetReordering feature.
2661    #[serde(skip_serializing_if = "Option::is_none")]
2662    packetReordering: Option<bool>,
2663    /// True to emulate internet disconnection.
2664    #[serde(skip_serializing_if = "Option::is_none")]
2665    offline: Option<bool>,
2666}
2667
2668impl<'a> NetworkConditions<'a> {
2669    pub fn builder(urlPattern: impl Into<Cow<'a, str>>, latency: f64, downloadThroughput: f64, uploadThroughput: f64) -> NetworkConditionsBuilder<'a> {
2670        NetworkConditionsBuilder {
2671            urlPattern: urlPattern.into(),
2672            latency: latency,
2673            downloadThroughput: downloadThroughput,
2674            uploadThroughput: uploadThroughput,
2675            connectionType: None,
2676            packetLoss: None,
2677            packetQueueLength: None,
2678            packetReordering: None,
2679            offline: None,
2680        }
2681    }
2682    pub fn urlPattern(&self) -> &str { self.urlPattern.as_ref() }
2683    pub fn latency(&self) -> f64 { self.latency }
2684    pub fn downloadThroughput(&self) -> f64 { self.downloadThroughput }
2685    pub fn uploadThroughput(&self) -> f64 { self.uploadThroughput }
2686    pub fn connectionType(&self) -> Option<&ConnectionType> { self.connectionType.as_ref() }
2687    pub fn packetLoss(&self) -> Option<f64> { self.packetLoss }
2688    pub fn packetQueueLength(&self) -> Option<u64> { self.packetQueueLength }
2689    pub fn packetReordering(&self) -> Option<bool> { self.packetReordering }
2690    pub fn offline(&self) -> Option<bool> { self.offline }
2691}
2692
2693
2694pub struct NetworkConditionsBuilder<'a> {
2695    urlPattern: Cow<'a, str>,
2696    latency: f64,
2697    downloadThroughput: f64,
2698    uploadThroughput: f64,
2699    connectionType: Option<ConnectionType>,
2700    packetLoss: Option<f64>,
2701    packetQueueLength: Option<u64>,
2702    packetReordering: Option<bool>,
2703    offline: Option<bool>,
2704}
2705
2706impl<'a> NetworkConditionsBuilder<'a> {
2707    /// Connection type if known.
2708    pub fn connectionType(mut self, connectionType: ConnectionType) -> Self { self.connectionType = Some(connectionType); self }
2709    /// WebRTC packet loss (percent, 0-100). 0 disables packet loss emulation, 100 drops all the packets.
2710    pub fn packetLoss(mut self, packetLoss: f64) -> Self { self.packetLoss = Some(packetLoss); self }
2711    /// WebRTC packet queue length (packet). 0 removes any queue length limitations.
2712    pub fn packetQueueLength(mut self, packetQueueLength: u64) -> Self { self.packetQueueLength = Some(packetQueueLength); self }
2713    /// WebRTC packetReordering feature.
2714    pub fn packetReordering(mut self, packetReordering: bool) -> Self { self.packetReordering = Some(packetReordering); self }
2715    /// True to emulate internet disconnection.
2716    pub fn offline(mut self, offline: bool) -> Self { self.offline = Some(offline); self }
2717    pub fn build(self) -> NetworkConditions<'a> {
2718        NetworkConditions {
2719            urlPattern: self.urlPattern,
2720            latency: self.latency,
2721            downloadThroughput: self.downloadThroughput,
2722            uploadThroughput: self.uploadThroughput,
2723            connectionType: self.connectionType,
2724            packetLoss: self.packetLoss,
2725            packetQueueLength: self.packetQueueLength,
2726            packetReordering: self.packetReordering,
2727            offline: self.offline,
2728        }
2729    }
2730}
2731
2732
2733#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2734#[serde(rename_all = "camelCase")]
2735pub struct BlockPattern<'a> {
2736    /// URL pattern to match. Patterns use the URLPattern constructor string syntax
2737    /// (https://urlpattern.spec.whatwg.org/) and must be absolute. Example: '*://*:*/*.css'.
2738    urlPattern: Cow<'a, str>,
2739    /// Whether or not to block the pattern. If false, a matching request will not be blocked even if it matches a later
2740    /// 'BlockPattern'.
2741    block: bool,
2742}
2743
2744impl<'a> BlockPattern<'a> {
2745    pub fn builder(urlPattern: impl Into<Cow<'a, str>>, block: bool) -> BlockPatternBuilder<'a> {
2746        BlockPatternBuilder {
2747            urlPattern: urlPattern.into(),
2748            block: block,
2749        }
2750    }
2751    pub fn urlPattern(&self) -> &str { self.urlPattern.as_ref() }
2752    pub fn block(&self) -> bool { self.block }
2753}
2754
2755
2756pub struct BlockPatternBuilder<'a> {
2757    urlPattern: Cow<'a, str>,
2758    block: bool,
2759}
2760
2761impl<'a> BlockPatternBuilder<'a> {
2762    pub fn build(self) -> BlockPattern<'a> {
2763        BlockPattern {
2764            urlPattern: self.urlPattern,
2765            block: self.block,
2766        }
2767    }
2768}
2769
2770
2771#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
2772pub enum DirectSocketDnsQueryType {
2773    #[default]
2774    #[serde(rename = "ipv4")]
2775    Ipv4,
2776    #[serde(rename = "ipv6")]
2777    Ipv6,
2778}
2779
2780
2781#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2782#[serde(rename_all = "camelCase")]
2783pub struct DirectTCPSocketOptions {
2784    /// TCP_NODELAY option
2785    noDelay: bool,
2786    /// Expected to be unsigned integer.
2787    #[serde(skip_serializing_if = "Option::is_none")]
2788    keepAliveDelay: Option<f64>,
2789    /// Expected to be unsigned integer.
2790    #[serde(skip_serializing_if = "Option::is_none")]
2791    sendBufferSize: Option<f64>,
2792    /// Expected to be unsigned integer.
2793    #[serde(skip_serializing_if = "Option::is_none")]
2794    receiveBufferSize: Option<f64>,
2795    #[serde(skip_serializing_if = "Option::is_none")]
2796    dnsQueryType: Option<DirectSocketDnsQueryType>,
2797}
2798
2799impl DirectTCPSocketOptions {
2800    pub fn builder(noDelay: bool) -> DirectTCPSocketOptionsBuilder {
2801        DirectTCPSocketOptionsBuilder {
2802            noDelay: noDelay,
2803            keepAliveDelay: None,
2804            sendBufferSize: None,
2805            receiveBufferSize: None,
2806            dnsQueryType: None,
2807        }
2808    }
2809    pub fn noDelay(&self) -> bool { self.noDelay }
2810    pub fn keepAliveDelay(&self) -> Option<f64> { self.keepAliveDelay }
2811    pub fn sendBufferSize(&self) -> Option<f64> { self.sendBufferSize }
2812    pub fn receiveBufferSize(&self) -> Option<f64> { self.receiveBufferSize }
2813    pub fn dnsQueryType(&self) -> Option<&DirectSocketDnsQueryType> { self.dnsQueryType.as_ref() }
2814}
2815
2816
2817pub struct DirectTCPSocketOptionsBuilder {
2818    noDelay: bool,
2819    keepAliveDelay: Option<f64>,
2820    sendBufferSize: Option<f64>,
2821    receiveBufferSize: Option<f64>,
2822    dnsQueryType: Option<DirectSocketDnsQueryType>,
2823}
2824
2825impl DirectTCPSocketOptionsBuilder {
2826    /// Expected to be unsigned integer.
2827    pub fn keepAliveDelay(mut self, keepAliveDelay: f64) -> Self { self.keepAliveDelay = Some(keepAliveDelay); self }
2828    /// Expected to be unsigned integer.
2829    pub fn sendBufferSize(mut self, sendBufferSize: f64) -> Self { self.sendBufferSize = Some(sendBufferSize); self }
2830    /// Expected to be unsigned integer.
2831    pub fn receiveBufferSize(mut self, receiveBufferSize: f64) -> Self { self.receiveBufferSize = Some(receiveBufferSize); self }
2832    pub fn dnsQueryType(mut self, dnsQueryType: DirectSocketDnsQueryType) -> Self { self.dnsQueryType = Some(dnsQueryType); self }
2833    pub fn build(self) -> DirectTCPSocketOptions {
2834        DirectTCPSocketOptions {
2835            noDelay: self.noDelay,
2836            keepAliveDelay: self.keepAliveDelay,
2837            sendBufferSize: self.sendBufferSize,
2838            receiveBufferSize: self.receiveBufferSize,
2839            dnsQueryType: self.dnsQueryType,
2840        }
2841    }
2842}
2843
2844
2845#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2846#[serde(rename_all = "camelCase")]
2847pub struct DirectUDPSocketOptions<'a> {
2848    #[serde(skip_serializing_if = "Option::is_none")]
2849    remoteAddr: Option<Cow<'a, str>>,
2850    /// Unsigned int 16.
2851    #[serde(skip_serializing_if = "Option::is_none")]
2852    remotePort: Option<i64>,
2853    #[serde(skip_serializing_if = "Option::is_none")]
2854    localAddr: Option<Cow<'a, str>>,
2855    /// Unsigned int 16.
2856    #[serde(skip_serializing_if = "Option::is_none")]
2857    localPort: Option<i64>,
2858    #[serde(skip_serializing_if = "Option::is_none")]
2859    dnsQueryType: Option<DirectSocketDnsQueryType>,
2860    /// Expected to be unsigned integer.
2861    #[serde(skip_serializing_if = "Option::is_none")]
2862    sendBufferSize: Option<f64>,
2863    /// Expected to be unsigned integer.
2864    #[serde(skip_serializing_if = "Option::is_none")]
2865    receiveBufferSize: Option<f64>,
2866    #[serde(skip_serializing_if = "Option::is_none")]
2867    multicastLoopback: Option<bool>,
2868    /// Unsigned int 8.
2869    #[serde(skip_serializing_if = "Option::is_none")]
2870    multicastTimeToLive: Option<i64>,
2871    #[serde(skip_serializing_if = "Option::is_none")]
2872    multicastAllowAddressSharing: Option<bool>,
2873}
2874
2875impl<'a> DirectUDPSocketOptions<'a> {
2876    pub fn builder() -> DirectUDPSocketOptionsBuilder<'a> {
2877        DirectUDPSocketOptionsBuilder {
2878            remoteAddr: None,
2879            remotePort: None,
2880            localAddr: None,
2881            localPort: None,
2882            dnsQueryType: None,
2883            sendBufferSize: None,
2884            receiveBufferSize: None,
2885            multicastLoopback: None,
2886            multicastTimeToLive: None,
2887            multicastAllowAddressSharing: None,
2888        }
2889    }
2890    pub fn remoteAddr(&self) -> Option<&str> { self.remoteAddr.as_deref() }
2891    pub fn remotePort(&self) -> Option<i64> { self.remotePort }
2892    pub fn localAddr(&self) -> Option<&str> { self.localAddr.as_deref() }
2893    pub fn localPort(&self) -> Option<i64> { self.localPort }
2894    pub fn dnsQueryType(&self) -> Option<&DirectSocketDnsQueryType> { self.dnsQueryType.as_ref() }
2895    pub fn sendBufferSize(&self) -> Option<f64> { self.sendBufferSize }
2896    pub fn receiveBufferSize(&self) -> Option<f64> { self.receiveBufferSize }
2897    pub fn multicastLoopback(&self) -> Option<bool> { self.multicastLoopback }
2898    pub fn multicastTimeToLive(&self) -> Option<i64> { self.multicastTimeToLive }
2899    pub fn multicastAllowAddressSharing(&self) -> Option<bool> { self.multicastAllowAddressSharing }
2900}
2901
2902#[derive(Default)]
2903pub struct DirectUDPSocketOptionsBuilder<'a> {
2904    remoteAddr: Option<Cow<'a, str>>,
2905    remotePort: Option<i64>,
2906    localAddr: Option<Cow<'a, str>>,
2907    localPort: Option<i64>,
2908    dnsQueryType: Option<DirectSocketDnsQueryType>,
2909    sendBufferSize: Option<f64>,
2910    receiveBufferSize: Option<f64>,
2911    multicastLoopback: Option<bool>,
2912    multicastTimeToLive: Option<i64>,
2913    multicastAllowAddressSharing: Option<bool>,
2914}
2915
2916impl<'a> DirectUDPSocketOptionsBuilder<'a> {
2917    pub fn remoteAddr(mut self, remoteAddr: impl Into<Cow<'a, str>>) -> Self { self.remoteAddr = Some(remoteAddr.into()); self }
2918    /// Unsigned int 16.
2919    pub fn remotePort(mut self, remotePort: i64) -> Self { self.remotePort = Some(remotePort); self }
2920    pub fn localAddr(mut self, localAddr: impl Into<Cow<'a, str>>) -> Self { self.localAddr = Some(localAddr.into()); self }
2921    /// Unsigned int 16.
2922    pub fn localPort(mut self, localPort: i64) -> Self { self.localPort = Some(localPort); self }
2923    pub fn dnsQueryType(mut self, dnsQueryType: DirectSocketDnsQueryType) -> Self { self.dnsQueryType = Some(dnsQueryType); self }
2924    /// Expected to be unsigned integer.
2925    pub fn sendBufferSize(mut self, sendBufferSize: f64) -> Self { self.sendBufferSize = Some(sendBufferSize); self }
2926    /// Expected to be unsigned integer.
2927    pub fn receiveBufferSize(mut self, receiveBufferSize: f64) -> Self { self.receiveBufferSize = Some(receiveBufferSize); self }
2928    pub fn multicastLoopback(mut self, multicastLoopback: bool) -> Self { self.multicastLoopback = Some(multicastLoopback); self }
2929    /// Unsigned int 8.
2930    pub fn multicastTimeToLive(mut self, multicastTimeToLive: i64) -> Self { self.multicastTimeToLive = Some(multicastTimeToLive); self }
2931    pub fn multicastAllowAddressSharing(mut self, multicastAllowAddressSharing: bool) -> Self { self.multicastAllowAddressSharing = Some(multicastAllowAddressSharing); self }
2932    pub fn build(self) -> DirectUDPSocketOptions<'a> {
2933        DirectUDPSocketOptions {
2934            remoteAddr: self.remoteAddr,
2935            remotePort: self.remotePort,
2936            localAddr: self.localAddr,
2937            localPort: self.localPort,
2938            dnsQueryType: self.dnsQueryType,
2939            sendBufferSize: self.sendBufferSize,
2940            receiveBufferSize: self.receiveBufferSize,
2941            multicastLoopback: self.multicastLoopback,
2942            multicastTimeToLive: self.multicastTimeToLive,
2943            multicastAllowAddressSharing: self.multicastAllowAddressSharing,
2944        }
2945    }
2946}
2947
2948
2949#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2950#[serde(rename_all = "camelCase")]
2951pub struct DirectUDPMessage<'a> {
2952    data: Cow<'a, str>,
2953    /// Null for connected mode.
2954    #[serde(skip_serializing_if = "Option::is_none")]
2955    remoteAddr: Option<Cow<'a, str>>,
2956    /// Null for connected mode.
2957    /// Expected to be unsigned integer.
2958    #[serde(skip_serializing_if = "Option::is_none")]
2959    remotePort: Option<i64>,
2960}
2961
2962impl<'a> DirectUDPMessage<'a> {
2963    pub fn builder(data: impl Into<Cow<'a, str>>) -> DirectUDPMessageBuilder<'a> {
2964        DirectUDPMessageBuilder {
2965            data: data.into(),
2966            remoteAddr: None,
2967            remotePort: None,
2968        }
2969    }
2970    pub fn data(&self) -> &str { self.data.as_ref() }
2971    pub fn remoteAddr(&self) -> Option<&str> { self.remoteAddr.as_deref() }
2972    pub fn remotePort(&self) -> Option<i64> { self.remotePort }
2973}
2974
2975
2976pub struct DirectUDPMessageBuilder<'a> {
2977    data: Cow<'a, str>,
2978    remoteAddr: Option<Cow<'a, str>>,
2979    remotePort: Option<i64>,
2980}
2981
2982impl<'a> DirectUDPMessageBuilder<'a> {
2983    /// Null for connected mode.
2984    pub fn remoteAddr(mut self, remoteAddr: impl Into<Cow<'a, str>>) -> Self { self.remoteAddr = Some(remoteAddr.into()); self }
2985    /// Null for connected mode.
2986    /// Expected to be unsigned integer.
2987    pub fn remotePort(mut self, remotePort: i64) -> Self { self.remotePort = Some(remotePort); self }
2988    pub fn build(self) -> DirectUDPMessage<'a> {
2989        DirectUDPMessage {
2990            data: self.data,
2991            remoteAddr: self.remoteAddr,
2992            remotePort: self.remotePort,
2993        }
2994    }
2995}
2996
2997
2998#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
2999pub enum LocalNetworkAccessRequestPolicy {
3000    #[default]
3001    #[serde(rename = "Allow")]
3002    Allow,
3003    #[serde(rename = "BlockFromInsecureToMorePrivate")]
3004    BlockFromInsecureToMorePrivate,
3005    #[serde(rename = "WarnFromInsecureToMorePrivate")]
3006    WarnFromInsecureToMorePrivate,
3007    #[serde(rename = "PermissionBlock")]
3008    PermissionBlock,
3009    #[serde(rename = "PermissionWarn")]
3010    PermissionWarn,
3011}
3012
3013
3014#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
3015pub enum IPAddressSpace {
3016    #[default]
3017    #[serde(rename = "Loopback")]
3018    Loopback,
3019    #[serde(rename = "Local")]
3020    Local,
3021    #[serde(rename = "Public")]
3022    Public,
3023    #[serde(rename = "Unknown")]
3024    Unknown,
3025}
3026
3027
3028#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3029#[serde(rename_all = "camelCase")]
3030pub struct ConnectTiming {
3031    /// Timing's requestTime is a baseline in seconds, while the other numbers are ticks in
3032    /// milliseconds relatively to this requestTime. Matches ResourceTiming's requestTime for
3033    /// the same request (but not for redirected requests).
3034    requestTime: f64,
3035}
3036
3037impl ConnectTiming {
3038    pub fn builder(requestTime: f64) -> ConnectTimingBuilder {
3039        ConnectTimingBuilder {
3040            requestTime: requestTime,
3041        }
3042    }
3043    pub fn requestTime(&self) -> f64 { self.requestTime }
3044}
3045
3046
3047pub struct ConnectTimingBuilder {
3048    requestTime: f64,
3049}
3050
3051impl ConnectTimingBuilder {
3052    pub fn build(self) -> ConnectTiming {
3053        ConnectTiming {
3054            requestTime: self.requestTime,
3055        }
3056    }
3057}
3058
3059
3060#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3061#[serde(rename_all = "camelCase")]
3062pub struct ClientSecurityState {
3063    initiatorIsSecureContext: bool,
3064    initiatorIPAddressSpace: IPAddressSpace,
3065    localNetworkAccessRequestPolicy: LocalNetworkAccessRequestPolicy,
3066}
3067
3068impl ClientSecurityState {
3069    pub fn builder(initiatorIsSecureContext: bool, initiatorIPAddressSpace: IPAddressSpace, localNetworkAccessRequestPolicy: LocalNetworkAccessRequestPolicy) -> ClientSecurityStateBuilder {
3070        ClientSecurityStateBuilder {
3071            initiatorIsSecureContext: initiatorIsSecureContext,
3072            initiatorIPAddressSpace: initiatorIPAddressSpace,
3073            localNetworkAccessRequestPolicy: localNetworkAccessRequestPolicy,
3074        }
3075    }
3076    pub fn initiatorIsSecureContext(&self) -> bool { self.initiatorIsSecureContext }
3077    pub fn initiatorIPAddressSpace(&self) -> &IPAddressSpace { &self.initiatorIPAddressSpace }
3078    pub fn localNetworkAccessRequestPolicy(&self) -> &LocalNetworkAccessRequestPolicy { &self.localNetworkAccessRequestPolicy }
3079}
3080
3081
3082pub struct ClientSecurityStateBuilder {
3083    initiatorIsSecureContext: bool,
3084    initiatorIPAddressSpace: IPAddressSpace,
3085    localNetworkAccessRequestPolicy: LocalNetworkAccessRequestPolicy,
3086}
3087
3088impl ClientSecurityStateBuilder {
3089    pub fn build(self) -> ClientSecurityState {
3090        ClientSecurityState {
3091            initiatorIsSecureContext: self.initiatorIsSecureContext,
3092            initiatorIPAddressSpace: self.initiatorIPAddressSpace,
3093            localNetworkAccessRequestPolicy: self.localNetworkAccessRequestPolicy,
3094        }
3095    }
3096}
3097
3098/// Identifies the script on the stack that caused a resource or element to be
3099/// labeled as an ad. For resources, this indicates the context that triggered
3100/// the fetch. For elements, this indicates the context that caused the element
3101/// to be appended to the DOM.
3102
3103#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3104#[serde(rename_all = "camelCase")]
3105pub struct AdScriptIdentifier<'a> {
3106    /// The script's V8 identifier.
3107    scriptId: crate::runtime::ScriptId<'a>,
3108    /// V8's debugging ID for the v8::Context.
3109    debuggerId: crate::runtime::UniqueDebuggerId<'a>,
3110    /// The script's url (or generated name based on id if inline script).
3111    name: Cow<'a, str>,
3112}
3113
3114impl<'a> AdScriptIdentifier<'a> {
3115    pub fn builder(scriptId: crate::runtime::ScriptId<'a>, debuggerId: crate::runtime::UniqueDebuggerId<'a>, name: impl Into<Cow<'a, str>>) -> AdScriptIdentifierBuilder<'a> {
3116        AdScriptIdentifierBuilder {
3117            scriptId: scriptId,
3118            debuggerId: debuggerId,
3119            name: name.into(),
3120        }
3121    }
3122    pub fn scriptId(&self) -> &crate::runtime::ScriptId<'a> { &self.scriptId }
3123    pub fn debuggerId(&self) -> &crate::runtime::UniqueDebuggerId<'a> { &self.debuggerId }
3124    pub fn name(&self) -> &str { self.name.as_ref() }
3125}
3126
3127
3128pub struct AdScriptIdentifierBuilder<'a> {
3129    scriptId: crate::runtime::ScriptId<'a>,
3130    debuggerId: crate::runtime::UniqueDebuggerId<'a>,
3131    name: Cow<'a, str>,
3132}
3133
3134impl<'a> AdScriptIdentifierBuilder<'a> {
3135    pub fn build(self) -> AdScriptIdentifier<'a> {
3136        AdScriptIdentifier {
3137            scriptId: self.scriptId,
3138            debuggerId: self.debuggerId,
3139            name: self.name,
3140        }
3141    }
3142}
3143
3144/// Encapsulates the script ancestry and the root script filter list rule that
3145/// caused the resource or element to be labeled as an ad.
3146
3147#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3148#[serde(rename_all = "camelCase")]
3149pub struct AdAncestry<'a> {
3150    /// A chain of 'AdScriptIdentifier's representing the ancestry of an ad
3151    /// script that led to the creation of a resource or element. The chain is
3152    /// ordered from the script itself (lowest level) up to its root ancestor
3153    /// that was flagged by a filter list.
3154    ancestryChain: Vec<AdScriptIdentifier<'a>>,
3155    /// The filter list rule that caused the root (last) script in
3156    /// 'ancestryChain' to be tagged as an ad.
3157    #[serde(skip_serializing_if = "Option::is_none")]
3158    rootScriptFilterlistRule: Option<Cow<'a, str>>,
3159}
3160
3161impl<'a> AdAncestry<'a> {
3162    pub fn builder(ancestryChain: Vec<AdScriptIdentifier<'a>>) -> AdAncestryBuilder<'a> {
3163        AdAncestryBuilder {
3164            ancestryChain: ancestryChain,
3165            rootScriptFilterlistRule: None,
3166        }
3167    }
3168    pub fn ancestryChain(&self) -> &[AdScriptIdentifier<'a>] { &self.ancestryChain }
3169    pub fn rootScriptFilterlistRule(&self) -> Option<&str> { self.rootScriptFilterlistRule.as_deref() }
3170}
3171
3172
3173pub struct AdAncestryBuilder<'a> {
3174    ancestryChain: Vec<AdScriptIdentifier<'a>>,
3175    rootScriptFilterlistRule: Option<Cow<'a, str>>,
3176}
3177
3178impl<'a> AdAncestryBuilder<'a> {
3179    /// The filter list rule that caused the root (last) script in
3180    /// 'ancestryChain' to be tagged as an ad.
3181    pub fn rootScriptFilterlistRule(mut self, rootScriptFilterlistRule: impl Into<Cow<'a, str>>) -> Self { self.rootScriptFilterlistRule = Some(rootScriptFilterlistRule.into()); self }
3182    pub fn build(self) -> AdAncestry<'a> {
3183        AdAncestry {
3184            ancestryChain: self.ancestryChain,
3185            rootScriptFilterlistRule: self.rootScriptFilterlistRule,
3186        }
3187    }
3188}
3189
3190/// Represents the provenance of an ad resource or element. Only one of
3191/// 'filterlistRule' or 'adScriptAncestry' can be set. If 'filterlistRule'
3192/// is provided, the resource URL directly matches a filter list rule. If
3193/// 'adScriptAncestry' is provided, an ad script initiated the resource fetch or
3194/// appended the element to the DOM. If neither is provided, the entity is
3195/// known to be an ad, but provenance tracking information is unavailable.
3196
3197#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3198#[serde(rename_all = "camelCase")]
3199pub struct AdProvenance<'a> {
3200    /// The filterlist rule that matched, if any.
3201    #[serde(skip_serializing_if = "Option::is_none")]
3202    filterlistRule: Option<Cow<'a, str>>,
3203    /// The script ancestry that created the ad, if any.
3204    #[serde(skip_serializing_if = "Option::is_none")]
3205    adScriptAncestry: Option<AdAncestry<'a>>,
3206}
3207
3208impl<'a> AdProvenance<'a> {
3209    pub fn builder() -> AdProvenanceBuilder<'a> {
3210        AdProvenanceBuilder {
3211            filterlistRule: None,
3212            adScriptAncestry: None,
3213        }
3214    }
3215    pub fn filterlistRule(&self) -> Option<&str> { self.filterlistRule.as_deref() }
3216    pub fn adScriptAncestry(&self) -> Option<&AdAncestry<'a>> { self.adScriptAncestry.as_ref() }
3217}
3218
3219#[derive(Default)]
3220pub struct AdProvenanceBuilder<'a> {
3221    filterlistRule: Option<Cow<'a, str>>,
3222    adScriptAncestry: Option<AdAncestry<'a>>,
3223}
3224
3225impl<'a> AdProvenanceBuilder<'a> {
3226    /// The filterlist rule that matched, if any.
3227    pub fn filterlistRule(mut self, filterlistRule: impl Into<Cow<'a, str>>) -> Self { self.filterlistRule = Some(filterlistRule.into()); self }
3228    /// The script ancestry that created the ad, if any.
3229    pub fn adScriptAncestry(mut self, adScriptAncestry: AdAncestry<'a>) -> Self { self.adScriptAncestry = Some(adScriptAncestry); self }
3230    pub fn build(self) -> AdProvenance<'a> {
3231        AdProvenance {
3232            filterlistRule: self.filterlistRule,
3233            adScriptAncestry: self.adScriptAncestry,
3234        }
3235    }
3236}
3237
3238
3239#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
3240pub enum CrossOriginOpenerPolicyValue {
3241    #[default]
3242    #[serde(rename = "SameOrigin")]
3243    SameOrigin,
3244    #[serde(rename = "SameOriginAllowPopups")]
3245    SameOriginAllowPopups,
3246    #[serde(rename = "RestrictProperties")]
3247    RestrictProperties,
3248    #[serde(rename = "UnsafeNone")]
3249    UnsafeNone,
3250    #[serde(rename = "SameOriginPlusCoep")]
3251    SameOriginPlusCoep,
3252    #[serde(rename = "RestrictPropertiesPlusCoep")]
3253    RestrictPropertiesPlusCoep,
3254    #[serde(rename = "NoopenerAllowPopups")]
3255    NoopenerAllowPopups,
3256}
3257
3258
3259#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3260#[serde(rename_all = "camelCase")]
3261pub struct CrossOriginOpenerPolicyStatus<'a> {
3262    value: CrossOriginOpenerPolicyValue,
3263    reportOnlyValue: CrossOriginOpenerPolicyValue,
3264    #[serde(skip_serializing_if = "Option::is_none")]
3265    reportingEndpoint: Option<Cow<'a, str>>,
3266    #[serde(skip_serializing_if = "Option::is_none")]
3267    reportOnlyReportingEndpoint: Option<Cow<'a, str>>,
3268}
3269
3270impl<'a> CrossOriginOpenerPolicyStatus<'a> {
3271    pub fn builder(value: CrossOriginOpenerPolicyValue, reportOnlyValue: CrossOriginOpenerPolicyValue) -> CrossOriginOpenerPolicyStatusBuilder<'a> {
3272        CrossOriginOpenerPolicyStatusBuilder {
3273            value: value,
3274            reportOnlyValue: reportOnlyValue,
3275            reportingEndpoint: None,
3276            reportOnlyReportingEndpoint: None,
3277        }
3278    }
3279    pub fn value(&self) -> &CrossOriginOpenerPolicyValue { &self.value }
3280    pub fn reportOnlyValue(&self) -> &CrossOriginOpenerPolicyValue { &self.reportOnlyValue }
3281    pub fn reportingEndpoint(&self) -> Option<&str> { self.reportingEndpoint.as_deref() }
3282    pub fn reportOnlyReportingEndpoint(&self) -> Option<&str> { self.reportOnlyReportingEndpoint.as_deref() }
3283}
3284
3285
3286pub struct CrossOriginOpenerPolicyStatusBuilder<'a> {
3287    value: CrossOriginOpenerPolicyValue,
3288    reportOnlyValue: CrossOriginOpenerPolicyValue,
3289    reportingEndpoint: Option<Cow<'a, str>>,
3290    reportOnlyReportingEndpoint: Option<Cow<'a, str>>,
3291}
3292
3293impl<'a> CrossOriginOpenerPolicyStatusBuilder<'a> {
3294    pub fn reportingEndpoint(mut self, reportingEndpoint: impl Into<Cow<'a, str>>) -> Self { self.reportingEndpoint = Some(reportingEndpoint.into()); self }
3295    pub fn reportOnlyReportingEndpoint(mut self, reportOnlyReportingEndpoint: impl Into<Cow<'a, str>>) -> Self { self.reportOnlyReportingEndpoint = Some(reportOnlyReportingEndpoint.into()); self }
3296    pub fn build(self) -> CrossOriginOpenerPolicyStatus<'a> {
3297        CrossOriginOpenerPolicyStatus {
3298            value: self.value,
3299            reportOnlyValue: self.reportOnlyValue,
3300            reportingEndpoint: self.reportingEndpoint,
3301            reportOnlyReportingEndpoint: self.reportOnlyReportingEndpoint,
3302        }
3303    }
3304}
3305
3306
3307#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
3308pub enum CrossOriginEmbedderPolicyValue {
3309    #[default]
3310    #[serde(rename = "None")]
3311    None,
3312    #[serde(rename = "Credentialless")]
3313    Credentialless,
3314    #[serde(rename = "RequireCorp")]
3315    RequireCorp,
3316}
3317
3318
3319#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3320#[serde(rename_all = "camelCase")]
3321pub struct CrossOriginEmbedderPolicyStatus<'a> {
3322    value: CrossOriginEmbedderPolicyValue,
3323    reportOnlyValue: CrossOriginEmbedderPolicyValue,
3324    #[serde(skip_serializing_if = "Option::is_none")]
3325    reportingEndpoint: Option<Cow<'a, str>>,
3326    #[serde(skip_serializing_if = "Option::is_none")]
3327    reportOnlyReportingEndpoint: Option<Cow<'a, str>>,
3328}
3329
3330impl<'a> CrossOriginEmbedderPolicyStatus<'a> {
3331    pub fn builder(value: CrossOriginEmbedderPolicyValue, reportOnlyValue: CrossOriginEmbedderPolicyValue) -> CrossOriginEmbedderPolicyStatusBuilder<'a> {
3332        CrossOriginEmbedderPolicyStatusBuilder {
3333            value: value,
3334            reportOnlyValue: reportOnlyValue,
3335            reportingEndpoint: None,
3336            reportOnlyReportingEndpoint: None,
3337        }
3338    }
3339    pub fn value(&self) -> &CrossOriginEmbedderPolicyValue { &self.value }
3340    pub fn reportOnlyValue(&self) -> &CrossOriginEmbedderPolicyValue { &self.reportOnlyValue }
3341    pub fn reportingEndpoint(&self) -> Option<&str> { self.reportingEndpoint.as_deref() }
3342    pub fn reportOnlyReportingEndpoint(&self) -> Option<&str> { self.reportOnlyReportingEndpoint.as_deref() }
3343}
3344
3345
3346pub struct CrossOriginEmbedderPolicyStatusBuilder<'a> {
3347    value: CrossOriginEmbedderPolicyValue,
3348    reportOnlyValue: CrossOriginEmbedderPolicyValue,
3349    reportingEndpoint: Option<Cow<'a, str>>,
3350    reportOnlyReportingEndpoint: Option<Cow<'a, str>>,
3351}
3352
3353impl<'a> CrossOriginEmbedderPolicyStatusBuilder<'a> {
3354    pub fn reportingEndpoint(mut self, reportingEndpoint: impl Into<Cow<'a, str>>) -> Self { self.reportingEndpoint = Some(reportingEndpoint.into()); self }
3355    pub fn reportOnlyReportingEndpoint(mut self, reportOnlyReportingEndpoint: impl Into<Cow<'a, str>>) -> Self { self.reportOnlyReportingEndpoint = Some(reportOnlyReportingEndpoint.into()); self }
3356    pub fn build(self) -> CrossOriginEmbedderPolicyStatus<'a> {
3357        CrossOriginEmbedderPolicyStatus {
3358            value: self.value,
3359            reportOnlyValue: self.reportOnlyValue,
3360            reportingEndpoint: self.reportingEndpoint,
3361            reportOnlyReportingEndpoint: self.reportOnlyReportingEndpoint,
3362        }
3363    }
3364}
3365
3366
3367#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
3368pub enum ContentSecurityPolicySource {
3369    #[default]
3370    #[serde(rename = "HTTP")]
3371    HTTP,
3372    #[serde(rename = "Meta")]
3373    Meta,
3374}
3375
3376
3377#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3378#[serde(rename_all = "camelCase")]
3379pub struct ContentSecurityPolicyStatus<'a> {
3380    effectiveDirectives: Cow<'a, str>,
3381    isEnforced: bool,
3382    source: ContentSecurityPolicySource,
3383}
3384
3385impl<'a> ContentSecurityPolicyStatus<'a> {
3386    pub fn builder(effectiveDirectives: impl Into<Cow<'a, str>>, isEnforced: bool, source: ContentSecurityPolicySource) -> ContentSecurityPolicyStatusBuilder<'a> {
3387        ContentSecurityPolicyStatusBuilder {
3388            effectiveDirectives: effectiveDirectives.into(),
3389            isEnforced: isEnforced,
3390            source: source,
3391        }
3392    }
3393    pub fn effectiveDirectives(&self) -> &str { self.effectiveDirectives.as_ref() }
3394    pub fn isEnforced(&self) -> bool { self.isEnforced }
3395    pub fn source(&self) -> &ContentSecurityPolicySource { &self.source }
3396}
3397
3398
3399pub struct ContentSecurityPolicyStatusBuilder<'a> {
3400    effectiveDirectives: Cow<'a, str>,
3401    isEnforced: bool,
3402    source: ContentSecurityPolicySource,
3403}
3404
3405impl<'a> ContentSecurityPolicyStatusBuilder<'a> {
3406    pub fn build(self) -> ContentSecurityPolicyStatus<'a> {
3407        ContentSecurityPolicyStatus {
3408            effectiveDirectives: self.effectiveDirectives,
3409            isEnforced: self.isEnforced,
3410            source: self.source,
3411        }
3412    }
3413}
3414
3415
3416#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3417#[serde(rename_all = "camelCase")]
3418pub struct SecurityIsolationStatus<'a> {
3419    #[serde(skip_serializing_if = "Option::is_none")]
3420    coop: Option<CrossOriginOpenerPolicyStatus<'a>>,
3421    #[serde(skip_serializing_if = "Option::is_none")]
3422    coep: Option<CrossOriginEmbedderPolicyStatus<'a>>,
3423    #[serde(skip_serializing_if = "Option::is_none")]
3424    csp: Option<Vec<ContentSecurityPolicyStatus<'a>>>,
3425}
3426
3427impl<'a> SecurityIsolationStatus<'a> {
3428    pub fn builder() -> SecurityIsolationStatusBuilder<'a> {
3429        SecurityIsolationStatusBuilder {
3430            coop: None,
3431            coep: None,
3432            csp: None,
3433        }
3434    }
3435    pub fn coop(&self) -> Option<&CrossOriginOpenerPolicyStatus<'a>> { self.coop.as_ref() }
3436    pub fn coep(&self) -> Option<&CrossOriginEmbedderPolicyStatus<'a>> { self.coep.as_ref() }
3437    pub fn csp(&self) -> Option<&[ContentSecurityPolicyStatus<'a>]> { self.csp.as_deref() }
3438}
3439
3440#[derive(Default)]
3441pub struct SecurityIsolationStatusBuilder<'a> {
3442    coop: Option<CrossOriginOpenerPolicyStatus<'a>>,
3443    coep: Option<CrossOriginEmbedderPolicyStatus<'a>>,
3444    csp: Option<Vec<ContentSecurityPolicyStatus<'a>>>,
3445}
3446
3447impl<'a> SecurityIsolationStatusBuilder<'a> {
3448    pub fn coop(mut self, coop: CrossOriginOpenerPolicyStatus<'a>) -> Self { self.coop = Some(coop); self }
3449    pub fn coep(mut self, coep: CrossOriginEmbedderPolicyStatus<'a>) -> Self { self.coep = Some(coep); self }
3450    pub fn csp(mut self, csp: Vec<ContentSecurityPolicyStatus<'a>>) -> Self { self.csp = Some(csp); self }
3451    pub fn build(self) -> SecurityIsolationStatus<'a> {
3452        SecurityIsolationStatus {
3453            coop: self.coop,
3454            coep: self.coep,
3455            csp: self.csp,
3456        }
3457    }
3458}
3459
3460/// The status of a Reporting API report.
3461
3462#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
3463pub enum ReportStatus {
3464    #[default]
3465    #[serde(rename = "Queued")]
3466    Queued,
3467    #[serde(rename = "Pending")]
3468    Pending,
3469    #[serde(rename = "MarkedForRemoval")]
3470    MarkedForRemoval,
3471    #[serde(rename = "Success")]
3472    Success,
3473}
3474
3475
3476pub type ReportId<'a> = Cow<'a, str>;
3477
3478/// An object representing a report generated by the Reporting API.
3479
3480#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3481#[serde(rename_all = "camelCase")]
3482pub struct ReportingApiReport<'a> {
3483    id: ReportId<'a>,
3484    /// The URL of the document that triggered the report.
3485    initiatorUrl: Cow<'a, str>,
3486    /// The name of the endpoint group that should be used to deliver the report.
3487    destination: Cow<'a, str>,
3488    /// The type of the report (specifies the set of data that is contained in the report body).
3489    #[serde(rename = "type")]
3490    type_: Cow<'a, str>,
3491    /// When the report was generated.
3492    timestamp: crate::network::TimeSinceEpoch,
3493    /// How many uploads deep the related request was.
3494    depth: i64,
3495    /// The number of delivery attempts made so far, not including an active attempt.
3496    completedAttempts: i64,
3497    body: serde_json::Map<String, JsonValue>,
3498    status: ReportStatus,
3499}
3500
3501impl<'a> ReportingApiReport<'a> {
3502    pub fn builder(id: ReportId<'a>, initiatorUrl: impl Into<Cow<'a, str>>, destination: impl Into<Cow<'a, str>>, type_: impl Into<Cow<'a, str>>, timestamp: crate::network::TimeSinceEpoch, depth: i64, completedAttempts: i64, body: serde_json::Map<String, JsonValue>, status: ReportStatus) -> ReportingApiReportBuilder<'a> {
3503        ReportingApiReportBuilder {
3504            id: id,
3505            initiatorUrl: initiatorUrl.into(),
3506            destination: destination.into(),
3507            type_: type_.into(),
3508            timestamp: timestamp,
3509            depth: depth,
3510            completedAttempts: completedAttempts,
3511            body: body,
3512            status: status,
3513        }
3514    }
3515    pub fn id(&self) -> &ReportId<'a> { &self.id }
3516    pub fn initiatorUrl(&self) -> &str { self.initiatorUrl.as_ref() }
3517    pub fn destination(&self) -> &str { self.destination.as_ref() }
3518    pub fn type_(&self) -> &str { self.type_.as_ref() }
3519    pub fn timestamp(&self) -> &crate::network::TimeSinceEpoch { &self.timestamp }
3520    pub fn depth(&self) -> i64 { self.depth }
3521    pub fn completedAttempts(&self) -> i64 { self.completedAttempts }
3522    pub fn body(&self) -> &serde_json::Map<String, JsonValue> { &self.body }
3523    pub fn status(&self) -> &ReportStatus { &self.status }
3524}
3525
3526
3527pub struct ReportingApiReportBuilder<'a> {
3528    id: ReportId<'a>,
3529    initiatorUrl: Cow<'a, str>,
3530    destination: Cow<'a, str>,
3531    type_: Cow<'a, str>,
3532    timestamp: crate::network::TimeSinceEpoch,
3533    depth: i64,
3534    completedAttempts: i64,
3535    body: serde_json::Map<String, JsonValue>,
3536    status: ReportStatus,
3537}
3538
3539impl<'a> ReportingApiReportBuilder<'a> {
3540    pub fn build(self) -> ReportingApiReport<'a> {
3541        ReportingApiReport {
3542            id: self.id,
3543            initiatorUrl: self.initiatorUrl,
3544            destination: self.destination,
3545            type_: self.type_,
3546            timestamp: self.timestamp,
3547            depth: self.depth,
3548            completedAttempts: self.completedAttempts,
3549            body: self.body,
3550            status: self.status,
3551        }
3552    }
3553}
3554
3555
3556#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3557#[serde(rename_all = "camelCase")]
3558pub struct ReportingApiEndpoint<'a> {
3559    /// The URL of the endpoint to which reports may be delivered.
3560    url: Cow<'a, str>,
3561    /// Name of the endpoint group.
3562    groupName: Cow<'a, str>,
3563}
3564
3565impl<'a> ReportingApiEndpoint<'a> {
3566    pub fn builder(url: impl Into<Cow<'a, str>>, groupName: impl Into<Cow<'a, str>>) -> ReportingApiEndpointBuilder<'a> {
3567        ReportingApiEndpointBuilder {
3568            url: url.into(),
3569            groupName: groupName.into(),
3570        }
3571    }
3572    pub fn url(&self) -> &str { self.url.as_ref() }
3573    pub fn groupName(&self) -> &str { self.groupName.as_ref() }
3574}
3575
3576
3577pub struct ReportingApiEndpointBuilder<'a> {
3578    url: Cow<'a, str>,
3579    groupName: Cow<'a, str>,
3580}
3581
3582impl<'a> ReportingApiEndpointBuilder<'a> {
3583    pub fn build(self) -> ReportingApiEndpoint<'a> {
3584        ReportingApiEndpoint {
3585            url: self.url,
3586            groupName: self.groupName,
3587        }
3588    }
3589}
3590
3591/// Unique identifier for a device bound session.
3592
3593#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3594#[serde(rename_all = "camelCase")]
3595pub struct DeviceBoundSessionKey<'a> {
3596    /// The site the session is set up for.
3597    site: Cow<'a, str>,
3598    /// The id of the session.
3599    id: Cow<'a, str>,
3600}
3601
3602impl<'a> DeviceBoundSessionKey<'a> {
3603    pub fn builder(site: impl Into<Cow<'a, str>>, id: impl Into<Cow<'a, str>>) -> DeviceBoundSessionKeyBuilder<'a> {
3604        DeviceBoundSessionKeyBuilder {
3605            site: site.into(),
3606            id: id.into(),
3607        }
3608    }
3609    pub fn site(&self) -> &str { self.site.as_ref() }
3610    pub fn id(&self) -> &str { self.id.as_ref() }
3611}
3612
3613
3614pub struct DeviceBoundSessionKeyBuilder<'a> {
3615    site: Cow<'a, str>,
3616    id: Cow<'a, str>,
3617}
3618
3619impl<'a> DeviceBoundSessionKeyBuilder<'a> {
3620    pub fn build(self) -> DeviceBoundSessionKey<'a> {
3621        DeviceBoundSessionKey {
3622            site: self.site,
3623            id: self.id,
3624        }
3625    }
3626}
3627
3628/// How a device bound session was used during a request.
3629
3630#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3631#[serde(rename_all = "camelCase")]
3632pub struct DeviceBoundSessionWithUsage<'a> {
3633    /// The key for the session.
3634    sessionKey: DeviceBoundSessionKey<'a>,
3635    /// How the session was used (or not used).
3636    usage: Cow<'a, str>,
3637}
3638
3639impl<'a> DeviceBoundSessionWithUsage<'a> {
3640    pub fn builder(sessionKey: DeviceBoundSessionKey<'a>, usage: impl Into<Cow<'a, str>>) -> DeviceBoundSessionWithUsageBuilder<'a> {
3641        DeviceBoundSessionWithUsageBuilder {
3642            sessionKey: sessionKey,
3643            usage: usage.into(),
3644        }
3645    }
3646    pub fn sessionKey(&self) -> &DeviceBoundSessionKey<'a> { &self.sessionKey }
3647    pub fn usage(&self) -> &str { self.usage.as_ref() }
3648}
3649
3650
3651pub struct DeviceBoundSessionWithUsageBuilder<'a> {
3652    sessionKey: DeviceBoundSessionKey<'a>,
3653    usage: Cow<'a, str>,
3654}
3655
3656impl<'a> DeviceBoundSessionWithUsageBuilder<'a> {
3657    pub fn build(self) -> DeviceBoundSessionWithUsage<'a> {
3658        DeviceBoundSessionWithUsage {
3659            sessionKey: self.sessionKey,
3660            usage: self.usage,
3661        }
3662    }
3663}
3664
3665/// A device bound session's cookie craving.
3666
3667#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3668#[serde(rename_all = "camelCase")]
3669pub struct DeviceBoundSessionCookieCraving<'a> {
3670    /// The name of the craving.
3671    name: Cow<'a, str>,
3672    /// The domain of the craving.
3673    domain: Cow<'a, str>,
3674    /// The path of the craving.
3675    path: Cow<'a, str>,
3676    /// The 'Secure' attribute of the craving attributes.
3677    secure: bool,
3678    /// The 'HttpOnly' attribute of the craving attributes.
3679    httpOnly: bool,
3680    /// The 'SameSite' attribute of the craving attributes.
3681    #[serde(skip_serializing_if = "Option::is_none")]
3682    sameSite: Option<CookieSameSite>,
3683}
3684
3685impl<'a> DeviceBoundSessionCookieCraving<'a> {
3686    pub fn builder(name: impl Into<Cow<'a, str>>, domain: impl Into<Cow<'a, str>>, path: impl Into<Cow<'a, str>>, secure: bool, httpOnly: bool) -> DeviceBoundSessionCookieCravingBuilder<'a> {
3687        DeviceBoundSessionCookieCravingBuilder {
3688            name: name.into(),
3689            domain: domain.into(),
3690            path: path.into(),
3691            secure: secure,
3692            httpOnly: httpOnly,
3693            sameSite: None,
3694        }
3695    }
3696    pub fn name(&self) -> &str { self.name.as_ref() }
3697    pub fn domain(&self) -> &str { self.domain.as_ref() }
3698    pub fn path(&self) -> &str { self.path.as_ref() }
3699    pub fn secure(&self) -> bool { self.secure }
3700    pub fn httpOnly(&self) -> bool { self.httpOnly }
3701    pub fn sameSite(&self) -> Option<&CookieSameSite> { self.sameSite.as_ref() }
3702}
3703
3704
3705pub struct DeviceBoundSessionCookieCravingBuilder<'a> {
3706    name: Cow<'a, str>,
3707    domain: Cow<'a, str>,
3708    path: Cow<'a, str>,
3709    secure: bool,
3710    httpOnly: bool,
3711    sameSite: Option<CookieSameSite>,
3712}
3713
3714impl<'a> DeviceBoundSessionCookieCravingBuilder<'a> {
3715    /// The 'SameSite' attribute of the craving attributes.
3716    pub fn sameSite(mut self, sameSite: CookieSameSite) -> Self { self.sameSite = Some(sameSite); self }
3717    pub fn build(self) -> DeviceBoundSessionCookieCraving<'a> {
3718        DeviceBoundSessionCookieCraving {
3719            name: self.name,
3720            domain: self.domain,
3721            path: self.path,
3722            secure: self.secure,
3723            httpOnly: self.httpOnly,
3724            sameSite: self.sameSite,
3725        }
3726    }
3727}
3728
3729/// A device bound session's inclusion URL rule.
3730
3731#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3732#[serde(rename_all = "camelCase")]
3733pub struct DeviceBoundSessionUrlRule<'a> {
3734    /// See comments on 'net::device_bound_sessions::SessionInclusionRules::UrlRule::rule_type'.
3735    ruleType: Cow<'a, str>,
3736    /// See comments on 'net::device_bound_sessions::SessionInclusionRules::UrlRule::host_pattern'.
3737    hostPattern: Cow<'a, str>,
3738    /// See comments on 'net::device_bound_sessions::SessionInclusionRules::UrlRule::path_prefix'.
3739    pathPrefix: Cow<'a, str>,
3740}
3741
3742impl<'a> DeviceBoundSessionUrlRule<'a> {
3743    pub fn builder(ruleType: impl Into<Cow<'a, str>>, hostPattern: impl Into<Cow<'a, str>>, pathPrefix: impl Into<Cow<'a, str>>) -> DeviceBoundSessionUrlRuleBuilder<'a> {
3744        DeviceBoundSessionUrlRuleBuilder {
3745            ruleType: ruleType.into(),
3746            hostPattern: hostPattern.into(),
3747            pathPrefix: pathPrefix.into(),
3748        }
3749    }
3750    pub fn ruleType(&self) -> &str { self.ruleType.as_ref() }
3751    pub fn hostPattern(&self) -> &str { self.hostPattern.as_ref() }
3752    pub fn pathPrefix(&self) -> &str { self.pathPrefix.as_ref() }
3753}
3754
3755
3756pub struct DeviceBoundSessionUrlRuleBuilder<'a> {
3757    ruleType: Cow<'a, str>,
3758    hostPattern: Cow<'a, str>,
3759    pathPrefix: Cow<'a, str>,
3760}
3761
3762impl<'a> DeviceBoundSessionUrlRuleBuilder<'a> {
3763    pub fn build(self) -> DeviceBoundSessionUrlRule<'a> {
3764        DeviceBoundSessionUrlRule {
3765            ruleType: self.ruleType,
3766            hostPattern: self.hostPattern,
3767            pathPrefix: self.pathPrefix,
3768        }
3769    }
3770}
3771
3772/// A device bound session's inclusion rules.
3773
3774#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3775#[serde(rename_all = "camelCase")]
3776pub struct DeviceBoundSessionInclusionRules<'a> {
3777    /// See comments on 'net::device_bound_sessions::SessionInclusionRules::origin_'.
3778    origin: Cow<'a, str>,
3779    /// Whether the whole site is included. See comments on
3780    /// 'net::device_bound_sessions::SessionInclusionRules::include_site_' for more
3781    /// details; this boolean is true if that value is populated.
3782    includeSite: bool,
3783    /// See comments on 'net::device_bound_sessions::SessionInclusionRules::url_rules_'.
3784    urlRules: Vec<DeviceBoundSessionUrlRule<'a>>,
3785}
3786
3787impl<'a> DeviceBoundSessionInclusionRules<'a> {
3788    pub fn builder(origin: impl Into<Cow<'a, str>>, includeSite: bool, urlRules: Vec<DeviceBoundSessionUrlRule<'a>>) -> DeviceBoundSessionInclusionRulesBuilder<'a> {
3789        DeviceBoundSessionInclusionRulesBuilder {
3790            origin: origin.into(),
3791            includeSite: includeSite,
3792            urlRules: urlRules,
3793        }
3794    }
3795    pub fn origin(&self) -> &str { self.origin.as_ref() }
3796    pub fn includeSite(&self) -> bool { self.includeSite }
3797    pub fn urlRules(&self) -> &[DeviceBoundSessionUrlRule<'a>] { &self.urlRules }
3798}
3799
3800
3801pub struct DeviceBoundSessionInclusionRulesBuilder<'a> {
3802    origin: Cow<'a, str>,
3803    includeSite: bool,
3804    urlRules: Vec<DeviceBoundSessionUrlRule<'a>>,
3805}
3806
3807impl<'a> DeviceBoundSessionInclusionRulesBuilder<'a> {
3808    pub fn build(self) -> DeviceBoundSessionInclusionRules<'a> {
3809        DeviceBoundSessionInclusionRules {
3810            origin: self.origin,
3811            includeSite: self.includeSite,
3812            urlRules: self.urlRules,
3813        }
3814    }
3815}
3816
3817/// A device bound session.
3818
3819#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3820#[serde(rename_all = "camelCase")]
3821pub struct DeviceBoundSession<'a> {
3822    /// The site and session ID of the session.
3823    key: DeviceBoundSessionKey<'a>,
3824    /// See comments on 'net::device_bound_sessions::Session::refresh_url_'.
3825    refreshUrl: Cow<'a, str>,
3826    /// See comments on 'net::device_bound_sessions::Session::inclusion_rules_'.
3827    inclusionRules: DeviceBoundSessionInclusionRules<'a>,
3828    /// See comments on 'net::device_bound_sessions::Session::cookie_cravings_'.
3829    cookieCravings: Vec<DeviceBoundSessionCookieCraving<'a>>,
3830    /// See comments on 'net::device_bound_sessions::Session::expiry_date_'.
3831    expiryDate: crate::network::TimeSinceEpoch,
3832    /// See comments on 'net::device_bound_sessions::Session::cached_challenge__'.
3833    #[serde(skip_serializing_if = "Option::is_none")]
3834    cachedChallenge: Option<Cow<'a, str>>,
3835    /// See comments on 'net::device_bound_sessions::Session::allowed_refresh_initiators_'.
3836    allowedRefreshInitiators: Vec<Cow<'a, str>>,
3837}
3838
3839impl<'a> DeviceBoundSession<'a> {
3840    pub fn builder(key: DeviceBoundSessionKey<'a>, refreshUrl: impl Into<Cow<'a, str>>, inclusionRules: DeviceBoundSessionInclusionRules<'a>, cookieCravings: Vec<DeviceBoundSessionCookieCraving<'a>>, expiryDate: crate::network::TimeSinceEpoch, allowedRefreshInitiators: Vec<Cow<'a, str>>) -> DeviceBoundSessionBuilder<'a> {
3841        DeviceBoundSessionBuilder {
3842            key: key,
3843            refreshUrl: refreshUrl.into(),
3844            inclusionRules: inclusionRules,
3845            cookieCravings: cookieCravings,
3846            expiryDate: expiryDate,
3847            cachedChallenge: None,
3848            allowedRefreshInitiators: allowedRefreshInitiators,
3849        }
3850    }
3851    pub fn key(&self) -> &DeviceBoundSessionKey<'a> { &self.key }
3852    pub fn refreshUrl(&self) -> &str { self.refreshUrl.as_ref() }
3853    pub fn inclusionRules(&self) -> &DeviceBoundSessionInclusionRules<'a> { &self.inclusionRules }
3854    pub fn cookieCravings(&self) -> &[DeviceBoundSessionCookieCraving<'a>] { &self.cookieCravings }
3855    pub fn expiryDate(&self) -> &crate::network::TimeSinceEpoch { &self.expiryDate }
3856    pub fn cachedChallenge(&self) -> Option<&str> { self.cachedChallenge.as_deref() }
3857    pub fn allowedRefreshInitiators(&self) -> &[Cow<'a, str>] { &self.allowedRefreshInitiators }
3858}
3859
3860
3861pub struct DeviceBoundSessionBuilder<'a> {
3862    key: DeviceBoundSessionKey<'a>,
3863    refreshUrl: Cow<'a, str>,
3864    inclusionRules: DeviceBoundSessionInclusionRules<'a>,
3865    cookieCravings: Vec<DeviceBoundSessionCookieCraving<'a>>,
3866    expiryDate: crate::network::TimeSinceEpoch,
3867    cachedChallenge: Option<Cow<'a, str>>,
3868    allowedRefreshInitiators: Vec<Cow<'a, str>>,
3869}
3870
3871impl<'a> DeviceBoundSessionBuilder<'a> {
3872    /// See comments on 'net::device_bound_sessions::Session::cached_challenge__'.
3873    pub fn cachedChallenge(mut self, cachedChallenge: impl Into<Cow<'a, str>>) -> Self { self.cachedChallenge = Some(cachedChallenge.into()); self }
3874    pub fn build(self) -> DeviceBoundSession<'a> {
3875        DeviceBoundSession {
3876            key: self.key,
3877            refreshUrl: self.refreshUrl,
3878            inclusionRules: self.inclusionRules,
3879            cookieCravings: self.cookieCravings,
3880            expiryDate: self.expiryDate,
3881            cachedChallenge: self.cachedChallenge,
3882            allowedRefreshInitiators: self.allowedRefreshInitiators,
3883        }
3884    }
3885}
3886
3887/// A unique identifier for a device bound session event.
3888
3889pub type DeviceBoundSessionEventId<'a> = Cow<'a, str>;
3890
3891/// A fetch result for a device bound session creation or refresh.
3892
3893#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
3894pub enum DeviceBoundSessionFetchResult {
3895    #[default]
3896    #[serde(rename = "Success")]
3897    Success,
3898    #[serde(rename = "KeyError")]
3899    KeyError,
3900    #[serde(rename = "SigningError")]
3901    SigningError,
3902    #[serde(rename = "ServerRequestedTermination")]
3903    ServerRequestedTermination,
3904    #[serde(rename = "InvalidSessionId")]
3905    InvalidSessionId,
3906    #[serde(rename = "InvalidChallenge")]
3907    InvalidChallenge,
3908    #[serde(rename = "TooManyChallenges")]
3909    TooManyChallenges,
3910    #[serde(rename = "InvalidFetcherUrl")]
3911    InvalidFetcherUrl,
3912    #[serde(rename = "InvalidRefreshUrl")]
3913    InvalidRefreshUrl,
3914    #[serde(rename = "TransientHttpError")]
3915    TransientHttpError,
3916    #[serde(rename = "ScopeOriginSameSiteMismatch")]
3917    ScopeOriginSameSiteMismatch,
3918    #[serde(rename = "RefreshUrlSameSiteMismatch")]
3919    RefreshUrlSameSiteMismatch,
3920    #[serde(rename = "MismatchedSessionId")]
3921    MismatchedSessionId,
3922    #[serde(rename = "MissingScope")]
3923    MissingScope,
3924    #[serde(rename = "NoCredentials")]
3925    NoCredentials,
3926    #[serde(rename = "SubdomainRegistrationWellKnownUnavailable")]
3927    SubdomainRegistrationWellKnownUnavailable,
3928    #[serde(rename = "SubdomainRegistrationUnauthorized")]
3929    SubdomainRegistrationUnauthorized,
3930    #[serde(rename = "SubdomainRegistrationWellKnownMalformed")]
3931    SubdomainRegistrationWellKnownMalformed,
3932    #[serde(rename = "SessionProviderWellKnownUnavailable")]
3933    SessionProviderWellKnownUnavailable,
3934    #[serde(rename = "RelyingPartyWellKnownUnavailable")]
3935    RelyingPartyWellKnownUnavailable,
3936    #[serde(rename = "FederatedKeyThumbprintMismatch")]
3937    FederatedKeyThumbprintMismatch,
3938    #[serde(rename = "InvalidFederatedSessionUrl")]
3939    InvalidFederatedSessionUrl,
3940    #[serde(rename = "InvalidFederatedKey")]
3941    InvalidFederatedKey,
3942    #[serde(rename = "TooManyRelyingOriginLabels")]
3943    TooManyRelyingOriginLabels,
3944    #[serde(rename = "BoundCookieSetForbidden")]
3945    BoundCookieSetForbidden,
3946    #[serde(rename = "NetError")]
3947    NetError,
3948    #[serde(rename = "ProxyError")]
3949    ProxyError,
3950    #[serde(rename = "EmptySessionConfig")]
3951    EmptySessionConfig,
3952    #[serde(rename = "InvalidCredentialsConfig")]
3953    InvalidCredentialsConfig,
3954    #[serde(rename = "InvalidCredentialsType")]
3955    InvalidCredentialsType,
3956    #[serde(rename = "InvalidCredentialsEmptyName")]
3957    InvalidCredentialsEmptyName,
3958    #[serde(rename = "InvalidCredentialsCookie")]
3959    InvalidCredentialsCookie,
3960    #[serde(rename = "PersistentHttpError")]
3961    PersistentHttpError,
3962    #[serde(rename = "RegistrationAttemptedChallenge")]
3963    RegistrationAttemptedChallenge,
3964    #[serde(rename = "InvalidScopeOrigin")]
3965    InvalidScopeOrigin,
3966    #[serde(rename = "ScopeOriginContainsPath")]
3967    ScopeOriginContainsPath,
3968    #[serde(rename = "RefreshInitiatorNotString")]
3969    RefreshInitiatorNotString,
3970    #[serde(rename = "RefreshInitiatorInvalidHostPattern")]
3971    RefreshInitiatorInvalidHostPattern,
3972    #[serde(rename = "InvalidScopeSpecification")]
3973    InvalidScopeSpecification,
3974    #[serde(rename = "MissingScopeSpecificationType")]
3975    MissingScopeSpecificationType,
3976    #[serde(rename = "EmptyScopeSpecificationDomain")]
3977    EmptyScopeSpecificationDomain,
3978    #[serde(rename = "EmptyScopeSpecificationPath")]
3979    EmptyScopeSpecificationPath,
3980    #[serde(rename = "InvalidScopeSpecificationType")]
3981    InvalidScopeSpecificationType,
3982    #[serde(rename = "InvalidScopeIncludeSite")]
3983    InvalidScopeIncludeSite,
3984    #[serde(rename = "MissingScopeIncludeSite")]
3985    MissingScopeIncludeSite,
3986    #[serde(rename = "FederatedNotAuthorizedByProvider")]
3987    FederatedNotAuthorizedByProvider,
3988    #[serde(rename = "FederatedNotAuthorizedByRelyingParty")]
3989    FederatedNotAuthorizedByRelyingParty,
3990    #[serde(rename = "SessionProviderWellKnownMalformed")]
3991    SessionProviderWellKnownMalformed,
3992    #[serde(rename = "SessionProviderWellKnownHasProviderOrigin")]
3993    SessionProviderWellKnownHasProviderOrigin,
3994    #[serde(rename = "RelyingPartyWellKnownMalformed")]
3995    RelyingPartyWellKnownMalformed,
3996    #[serde(rename = "RelyingPartyWellKnownHasRelyingOrigins")]
3997    RelyingPartyWellKnownHasRelyingOrigins,
3998    #[serde(rename = "InvalidFederatedSessionProviderSessionMissing")]
3999    InvalidFederatedSessionProviderSessionMissing,
4000    #[serde(rename = "InvalidFederatedSessionWrongProviderOrigin")]
4001    InvalidFederatedSessionWrongProviderOrigin,
4002    #[serde(rename = "InvalidCredentialsCookieCreationTime")]
4003    InvalidCredentialsCookieCreationTime,
4004    #[serde(rename = "InvalidCredentialsCookieName")]
4005    InvalidCredentialsCookieName,
4006    #[serde(rename = "InvalidCredentialsCookieParsing")]
4007    InvalidCredentialsCookieParsing,
4008    #[serde(rename = "InvalidCredentialsCookieUnpermittedAttribute")]
4009    InvalidCredentialsCookieUnpermittedAttribute,
4010    #[serde(rename = "InvalidCredentialsCookieInvalidDomain")]
4011    InvalidCredentialsCookieInvalidDomain,
4012    #[serde(rename = "InvalidCredentialsCookiePrefix")]
4013    InvalidCredentialsCookiePrefix,
4014    #[serde(rename = "InvalidScopeRulePath")]
4015    InvalidScopeRulePath,
4016    #[serde(rename = "InvalidScopeRuleHostPattern")]
4017    InvalidScopeRuleHostPattern,
4018    #[serde(rename = "ScopeRuleOriginScopedHostPatternMismatch")]
4019    ScopeRuleOriginScopedHostPatternMismatch,
4020    #[serde(rename = "ScopeRuleSiteScopedHostPatternMismatch")]
4021    ScopeRuleSiteScopedHostPatternMismatch,
4022    #[serde(rename = "SigningQuotaExceeded")]
4023    SigningQuotaExceeded,
4024    #[serde(rename = "InvalidConfigJson")]
4025    InvalidConfigJson,
4026    #[serde(rename = "InvalidFederatedSessionProviderFailedToRestoreKey")]
4027    InvalidFederatedSessionProviderFailedToRestoreKey,
4028    #[serde(rename = "FailedToUnwrapKey")]
4029    FailedToUnwrapKey,
4030    #[serde(rename = "SessionDeletedDuringRefresh")]
4031    SessionDeletedDuringRefresh,
4032}
4033
4034/// Details about a failed device bound session network request.
4035
4036#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4037#[serde(rename_all = "camelCase")]
4038pub struct DeviceBoundSessionFailedRequest<'a> {
4039    /// The failed request URL.
4040    requestUrl: Cow<'a, str>,
4041    /// The net error of the response if it was not OK.
4042    #[serde(skip_serializing_if = "Option::is_none")]
4043    netError: Option<Cow<'a, str>>,
4044    /// The response code if the net error was OK and the response code was not
4045    /// 200.
4046    #[serde(skip_serializing_if = "Option::is_none")]
4047    responseError: Option<i64>,
4048    /// The body of the response if the net error was OK, the response code was
4049    /// not 200, and the response body was not empty.
4050    #[serde(skip_serializing_if = "Option::is_none")]
4051    responseErrorBody: Option<Cow<'a, str>>,
4052}
4053
4054impl<'a> DeviceBoundSessionFailedRequest<'a> {
4055    pub fn builder(requestUrl: impl Into<Cow<'a, str>>) -> DeviceBoundSessionFailedRequestBuilder<'a> {
4056        DeviceBoundSessionFailedRequestBuilder {
4057            requestUrl: requestUrl.into(),
4058            netError: None,
4059            responseError: None,
4060            responseErrorBody: None,
4061        }
4062    }
4063    pub fn requestUrl(&self) -> &str { self.requestUrl.as_ref() }
4064    pub fn netError(&self) -> Option<&str> { self.netError.as_deref() }
4065    pub fn responseError(&self) -> Option<i64> { self.responseError }
4066    pub fn responseErrorBody(&self) -> Option<&str> { self.responseErrorBody.as_deref() }
4067}
4068
4069
4070pub struct DeviceBoundSessionFailedRequestBuilder<'a> {
4071    requestUrl: Cow<'a, str>,
4072    netError: Option<Cow<'a, str>>,
4073    responseError: Option<i64>,
4074    responseErrorBody: Option<Cow<'a, str>>,
4075}
4076
4077impl<'a> DeviceBoundSessionFailedRequestBuilder<'a> {
4078    /// The net error of the response if it was not OK.
4079    pub fn netError(mut self, netError: impl Into<Cow<'a, str>>) -> Self { self.netError = Some(netError.into()); self }
4080    /// The response code if the net error was OK and the response code was not
4081    /// 200.
4082    pub fn responseError(mut self, responseError: i64) -> Self { self.responseError = Some(responseError); self }
4083    /// The body of the response if the net error was OK, the response code was
4084    /// not 200, and the response body was not empty.
4085    pub fn responseErrorBody(mut self, responseErrorBody: impl Into<Cow<'a, str>>) -> Self { self.responseErrorBody = Some(responseErrorBody.into()); self }
4086    pub fn build(self) -> DeviceBoundSessionFailedRequest<'a> {
4087        DeviceBoundSessionFailedRequest {
4088            requestUrl: self.requestUrl,
4089            netError: self.netError,
4090            responseError: self.responseError,
4091            responseErrorBody: self.responseErrorBody,
4092        }
4093    }
4094}
4095
4096/// Session event details specific to creation.
4097
4098#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4099#[serde(rename_all = "camelCase")]
4100pub struct CreationEventDetails<'a> {
4101    /// The result of the fetch attempt.
4102    fetchResult: DeviceBoundSessionFetchResult,
4103    /// The session if there was a newly created session. This is populated for
4104    /// all successful creation events.
4105    #[serde(skip_serializing_if = "Option::is_none")]
4106    newSession: Option<DeviceBoundSession<'a>>,
4107    /// Details about a failed device bound session network request if there was
4108    /// one.
4109    #[serde(skip_serializing_if = "Option::is_none")]
4110    failedRequest: Option<DeviceBoundSessionFailedRequest<'a>>,
4111}
4112
4113impl<'a> CreationEventDetails<'a> {
4114    pub fn builder(fetchResult: DeviceBoundSessionFetchResult) -> CreationEventDetailsBuilder<'a> {
4115        CreationEventDetailsBuilder {
4116            fetchResult: fetchResult,
4117            newSession: None,
4118            failedRequest: None,
4119        }
4120    }
4121    pub fn fetchResult(&self) -> &DeviceBoundSessionFetchResult { &self.fetchResult }
4122    pub fn newSession(&self) -> Option<&DeviceBoundSession<'a>> { self.newSession.as_ref() }
4123    pub fn failedRequest(&self) -> Option<&DeviceBoundSessionFailedRequest<'a>> { self.failedRequest.as_ref() }
4124}
4125
4126
4127pub struct CreationEventDetailsBuilder<'a> {
4128    fetchResult: DeviceBoundSessionFetchResult,
4129    newSession: Option<DeviceBoundSession<'a>>,
4130    failedRequest: Option<DeviceBoundSessionFailedRequest<'a>>,
4131}
4132
4133impl<'a> CreationEventDetailsBuilder<'a> {
4134    /// The session if there was a newly created session. This is populated for
4135    /// all successful creation events.
4136    pub fn newSession(mut self, newSession: DeviceBoundSession<'a>) -> Self { self.newSession = Some(newSession); self }
4137    /// Details about a failed device bound session network request if there was
4138    /// one.
4139    pub fn failedRequest(mut self, failedRequest: DeviceBoundSessionFailedRequest<'a>) -> Self { self.failedRequest = Some(failedRequest); self }
4140    pub fn build(self) -> CreationEventDetails<'a> {
4141        CreationEventDetails {
4142            fetchResult: self.fetchResult,
4143            newSession: self.newSession,
4144            failedRequest: self.failedRequest,
4145        }
4146    }
4147}
4148
4149/// Session event details specific to refresh.
4150
4151#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4152#[serde(rename_all = "camelCase")]
4153pub struct RefreshEventDetails<'a> {
4154    /// The result of a refresh.
4155    refreshResult: Cow<'a, str>,
4156    /// If there was a fetch attempt, the result of that.
4157    #[serde(skip_serializing_if = "Option::is_none")]
4158    fetchResult: Option<DeviceBoundSessionFetchResult>,
4159    /// The session display if there was a newly created session. This is populated
4160    /// for any refresh event that modifies the session config.
4161    #[serde(skip_serializing_if = "Option::is_none")]
4162    newSession: Option<DeviceBoundSession<'a>>,
4163    /// See comments on 'net::device_bound_sessions::RefreshEventResult::was_fully_proactive_refresh'.
4164    wasFullyProactiveRefresh: bool,
4165    /// Details about a failed device bound session network request if there was
4166    /// one.
4167    #[serde(skip_serializing_if = "Option::is_none")]
4168    failedRequest: Option<DeviceBoundSessionFailedRequest<'a>>,
4169}
4170
4171impl<'a> RefreshEventDetails<'a> {
4172    pub fn builder(refreshResult: impl Into<Cow<'a, str>>, wasFullyProactiveRefresh: bool) -> RefreshEventDetailsBuilder<'a> {
4173        RefreshEventDetailsBuilder {
4174            refreshResult: refreshResult.into(),
4175            fetchResult: None,
4176            newSession: None,
4177            wasFullyProactiveRefresh: wasFullyProactiveRefresh,
4178            failedRequest: None,
4179        }
4180    }
4181    pub fn refreshResult(&self) -> &str { self.refreshResult.as_ref() }
4182    pub fn fetchResult(&self) -> Option<&DeviceBoundSessionFetchResult> { self.fetchResult.as_ref() }
4183    pub fn newSession(&self) -> Option<&DeviceBoundSession<'a>> { self.newSession.as_ref() }
4184    pub fn wasFullyProactiveRefresh(&self) -> bool { self.wasFullyProactiveRefresh }
4185    pub fn failedRequest(&self) -> Option<&DeviceBoundSessionFailedRequest<'a>> { self.failedRequest.as_ref() }
4186}
4187
4188
4189pub struct RefreshEventDetailsBuilder<'a> {
4190    refreshResult: Cow<'a, str>,
4191    fetchResult: Option<DeviceBoundSessionFetchResult>,
4192    newSession: Option<DeviceBoundSession<'a>>,
4193    wasFullyProactiveRefresh: bool,
4194    failedRequest: Option<DeviceBoundSessionFailedRequest<'a>>,
4195}
4196
4197impl<'a> RefreshEventDetailsBuilder<'a> {
4198    /// If there was a fetch attempt, the result of that.
4199    pub fn fetchResult(mut self, fetchResult: DeviceBoundSessionFetchResult) -> Self { self.fetchResult = Some(fetchResult); self }
4200    /// The session display if there was a newly created session. This is populated
4201    /// for any refresh event that modifies the session config.
4202    pub fn newSession(mut self, newSession: DeviceBoundSession<'a>) -> Self { self.newSession = Some(newSession); self }
4203    /// Details about a failed device bound session network request if there was
4204    /// one.
4205    pub fn failedRequest(mut self, failedRequest: DeviceBoundSessionFailedRequest<'a>) -> Self { self.failedRequest = Some(failedRequest); self }
4206    pub fn build(self) -> RefreshEventDetails<'a> {
4207        RefreshEventDetails {
4208            refreshResult: self.refreshResult,
4209            fetchResult: self.fetchResult,
4210            newSession: self.newSession,
4211            wasFullyProactiveRefresh: self.wasFullyProactiveRefresh,
4212            failedRequest: self.failedRequest,
4213        }
4214    }
4215}
4216
4217/// Session event details specific to termination.
4218
4219#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4220#[serde(rename_all = "camelCase")]
4221pub struct TerminationEventDetails<'a> {
4222    /// The reason for a session being deleted.
4223    deletionReason: Cow<'a, str>,
4224}
4225
4226impl<'a> TerminationEventDetails<'a> {
4227    pub fn builder(deletionReason: impl Into<Cow<'a, str>>) -> TerminationEventDetailsBuilder<'a> {
4228        TerminationEventDetailsBuilder {
4229            deletionReason: deletionReason.into(),
4230        }
4231    }
4232    pub fn deletionReason(&self) -> &str { self.deletionReason.as_ref() }
4233}
4234
4235
4236pub struct TerminationEventDetailsBuilder<'a> {
4237    deletionReason: Cow<'a, str>,
4238}
4239
4240impl<'a> TerminationEventDetailsBuilder<'a> {
4241    pub fn build(self) -> TerminationEventDetails<'a> {
4242        TerminationEventDetails {
4243            deletionReason: self.deletionReason,
4244        }
4245    }
4246}
4247
4248/// Session event details specific to challenges.
4249
4250#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4251#[serde(rename_all = "camelCase")]
4252pub struct ChallengeEventDetails<'a> {
4253    /// The result of a challenge.
4254    challengeResult: Cow<'a, str>,
4255    /// The challenge set.
4256    challenge: Cow<'a, str>,
4257}
4258
4259impl<'a> ChallengeEventDetails<'a> {
4260    pub fn builder(challengeResult: impl Into<Cow<'a, str>>, challenge: impl Into<Cow<'a, str>>) -> ChallengeEventDetailsBuilder<'a> {
4261        ChallengeEventDetailsBuilder {
4262            challengeResult: challengeResult.into(),
4263            challenge: challenge.into(),
4264        }
4265    }
4266    pub fn challengeResult(&self) -> &str { self.challengeResult.as_ref() }
4267    pub fn challenge(&self) -> &str { self.challenge.as_ref() }
4268}
4269
4270
4271pub struct ChallengeEventDetailsBuilder<'a> {
4272    challengeResult: Cow<'a, str>,
4273    challenge: Cow<'a, str>,
4274}
4275
4276impl<'a> ChallengeEventDetailsBuilder<'a> {
4277    pub fn build(self) -> ChallengeEventDetails<'a> {
4278        ChallengeEventDetails {
4279            challengeResult: self.challengeResult,
4280            challenge: self.challenge,
4281        }
4282    }
4283}
4284
4285/// An object providing the result of a network resource load.
4286
4287#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4288#[serde(rename_all = "camelCase")]
4289pub struct LoadNetworkResourcePageResult<'a> {
4290    success: bool,
4291    /// Optional values used for error reporting.
4292    #[serde(skip_serializing_if = "Option::is_none")]
4293    netError: Option<f64>,
4294    #[serde(skip_serializing_if = "Option::is_none")]
4295    netErrorName: Option<Cow<'a, str>>,
4296    #[serde(skip_serializing_if = "Option::is_none")]
4297    httpStatusCode: Option<f64>,
4298    /// If successful, one of the following two fields holds the result.
4299    #[serde(skip_serializing_if = "Option::is_none")]
4300    stream: Option<crate::io::StreamHandle<'a>>,
4301    /// Response headers.
4302    #[serde(skip_serializing_if = "Option::is_none")]
4303    headers: Option<crate::network::Headers>,
4304}
4305
4306impl<'a> LoadNetworkResourcePageResult<'a> {
4307    pub fn builder(success: bool) -> LoadNetworkResourcePageResultBuilder<'a> {
4308        LoadNetworkResourcePageResultBuilder {
4309            success: success,
4310            netError: None,
4311            netErrorName: None,
4312            httpStatusCode: None,
4313            stream: None,
4314            headers: None,
4315        }
4316    }
4317    pub fn success(&self) -> bool { self.success }
4318    pub fn netError(&self) -> Option<f64> { self.netError }
4319    pub fn netErrorName(&self) -> Option<&str> { self.netErrorName.as_deref() }
4320    pub fn httpStatusCode(&self) -> Option<f64> { self.httpStatusCode }
4321    pub fn stream(&self) -> Option<&crate::io::StreamHandle<'a>> { self.stream.as_ref() }
4322    pub fn headers(&self) -> Option<&crate::network::Headers> { self.headers.as_ref() }
4323}
4324
4325
4326pub struct LoadNetworkResourcePageResultBuilder<'a> {
4327    success: bool,
4328    netError: Option<f64>,
4329    netErrorName: Option<Cow<'a, str>>,
4330    httpStatusCode: Option<f64>,
4331    stream: Option<crate::io::StreamHandle<'a>>,
4332    headers: Option<crate::network::Headers>,
4333}
4334
4335impl<'a> LoadNetworkResourcePageResultBuilder<'a> {
4336    /// Optional values used for error reporting.
4337    pub fn netError(mut self, netError: f64) -> Self { self.netError = Some(netError); self }
4338    pub fn netErrorName(mut self, netErrorName: impl Into<Cow<'a, str>>) -> Self { self.netErrorName = Some(netErrorName.into()); self }
4339    pub fn httpStatusCode(mut self, httpStatusCode: f64) -> Self { self.httpStatusCode = Some(httpStatusCode); self }
4340    /// If successful, one of the following two fields holds the result.
4341    pub fn stream(mut self, stream: crate::io::StreamHandle<'a>) -> Self { self.stream = Some(stream); self }
4342    /// Response headers.
4343    pub fn headers(mut self, headers: crate::network::Headers) -> Self { self.headers = Some(headers); self }
4344    pub fn build(self) -> LoadNetworkResourcePageResult<'a> {
4345        LoadNetworkResourcePageResult {
4346            success: self.success,
4347            netError: self.netError,
4348            netErrorName: self.netErrorName,
4349            httpStatusCode: self.httpStatusCode,
4350            stream: self.stream,
4351            headers: self.headers,
4352        }
4353    }
4354}
4355
4356/// An options object that may be extended later to better support CORS,
4357/// CORB and streaming.
4358
4359#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4360#[serde(rename_all = "camelCase")]
4361pub struct LoadNetworkResourceOptions {
4362    disableCache: bool,
4363    includeCredentials: bool,
4364}
4365
4366impl LoadNetworkResourceOptions {
4367    pub fn builder(disableCache: bool, includeCredentials: bool) -> LoadNetworkResourceOptionsBuilder {
4368        LoadNetworkResourceOptionsBuilder {
4369            disableCache: disableCache,
4370            includeCredentials: includeCredentials,
4371        }
4372    }
4373    pub fn disableCache(&self) -> bool { self.disableCache }
4374    pub fn includeCredentials(&self) -> bool { self.includeCredentials }
4375}
4376
4377
4378pub struct LoadNetworkResourceOptionsBuilder {
4379    disableCache: bool,
4380    includeCredentials: bool,
4381}
4382
4383impl LoadNetworkResourceOptionsBuilder {
4384    pub fn build(self) -> LoadNetworkResourceOptions {
4385        LoadNetworkResourceOptions {
4386            disableCache: self.disableCache,
4387            includeCredentials: self.includeCredentials,
4388        }
4389    }
4390}
4391
4392/// Sets a list of content encodings that will be accepted. Empty list means no encoding is accepted.
4393
4394#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4395#[serde(rename_all = "camelCase")]
4396pub struct SetAcceptedEncodingsParams {
4397    /// List of accepted content encodings.
4398    encodings: Vec<ContentEncoding>,
4399}
4400
4401impl SetAcceptedEncodingsParams {
4402    pub fn builder(encodings: Vec<ContentEncoding>) -> SetAcceptedEncodingsParamsBuilder {
4403        SetAcceptedEncodingsParamsBuilder {
4404            encodings: encodings,
4405        }
4406    }
4407    pub fn encodings(&self) -> &[ContentEncoding] { &self.encodings }
4408}
4409
4410
4411pub struct SetAcceptedEncodingsParamsBuilder {
4412    encodings: Vec<ContentEncoding>,
4413}
4414
4415impl SetAcceptedEncodingsParamsBuilder {
4416    pub fn build(self) -> SetAcceptedEncodingsParams {
4417        SetAcceptedEncodingsParams {
4418            encodings: self.encodings,
4419        }
4420    }
4421}
4422
4423impl SetAcceptedEncodingsParams { pub const METHOD: &'static str = "Network.setAcceptedEncodings"; }
4424
4425impl<'a> crate::CdpCommand<'a> for SetAcceptedEncodingsParams {
4426    const METHOD: &'static str = "Network.setAcceptedEncodings";
4427    type Response = crate::EmptyReturns;
4428}
4429
4430#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4431pub struct ClearAcceptedEncodingsOverrideParams {}
4432
4433impl ClearAcceptedEncodingsOverrideParams { pub const METHOD: &'static str = "Network.clearAcceptedEncodingsOverride"; }
4434
4435impl<'a> crate::CdpCommand<'a> for ClearAcceptedEncodingsOverrideParams {
4436    const METHOD: &'static str = "Network.clearAcceptedEncodingsOverride";
4437    type Response = crate::EmptyReturns;
4438}
4439
4440/// Tells whether clearing browser cache is supported.
4441
4442#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4443#[serde(rename_all = "camelCase")]
4444pub struct CanClearBrowserCacheReturns {
4445    /// True if browser cache can be cleared.
4446    result: bool,
4447}
4448
4449impl CanClearBrowserCacheReturns {
4450    pub fn builder(result: bool) -> CanClearBrowserCacheReturnsBuilder {
4451        CanClearBrowserCacheReturnsBuilder {
4452            result: result,
4453        }
4454    }
4455    pub fn result(&self) -> bool { self.result }
4456}
4457
4458
4459pub struct CanClearBrowserCacheReturnsBuilder {
4460    result: bool,
4461}
4462
4463impl CanClearBrowserCacheReturnsBuilder {
4464    pub fn build(self) -> CanClearBrowserCacheReturns {
4465        CanClearBrowserCacheReturns {
4466            result: self.result,
4467        }
4468    }
4469}
4470
4471#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4472pub struct CanClearBrowserCacheParams {}
4473
4474impl CanClearBrowserCacheParams { pub const METHOD: &'static str = "Network.canClearBrowserCache"; }
4475
4476impl<'a> crate::CdpCommand<'a> for CanClearBrowserCacheParams {
4477    const METHOD: &'static str = "Network.canClearBrowserCache";
4478    type Response = CanClearBrowserCacheReturns;
4479}
4480
4481/// Tells whether clearing browser cookies is supported.
4482
4483#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4484#[serde(rename_all = "camelCase")]
4485pub struct CanClearBrowserCookiesReturns {
4486    /// True if browser cookies can be cleared.
4487    result: bool,
4488}
4489
4490impl CanClearBrowserCookiesReturns {
4491    pub fn builder(result: bool) -> CanClearBrowserCookiesReturnsBuilder {
4492        CanClearBrowserCookiesReturnsBuilder {
4493            result: result,
4494        }
4495    }
4496    pub fn result(&self) -> bool { self.result }
4497}
4498
4499
4500pub struct CanClearBrowserCookiesReturnsBuilder {
4501    result: bool,
4502}
4503
4504impl CanClearBrowserCookiesReturnsBuilder {
4505    pub fn build(self) -> CanClearBrowserCookiesReturns {
4506        CanClearBrowserCookiesReturns {
4507            result: self.result,
4508        }
4509    }
4510}
4511
4512#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4513pub struct CanClearBrowserCookiesParams {}
4514
4515impl CanClearBrowserCookiesParams { pub const METHOD: &'static str = "Network.canClearBrowserCookies"; }
4516
4517impl<'a> crate::CdpCommand<'a> for CanClearBrowserCookiesParams {
4518    const METHOD: &'static str = "Network.canClearBrowserCookies";
4519    type Response = CanClearBrowserCookiesReturns;
4520}
4521
4522/// Tells whether emulation of network conditions is supported.
4523
4524#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4525#[serde(rename_all = "camelCase")]
4526pub struct CanEmulateNetworkConditionsReturns {
4527    /// True if emulation of network conditions is supported.
4528    result: bool,
4529}
4530
4531impl CanEmulateNetworkConditionsReturns {
4532    pub fn builder(result: bool) -> CanEmulateNetworkConditionsReturnsBuilder {
4533        CanEmulateNetworkConditionsReturnsBuilder {
4534            result: result,
4535        }
4536    }
4537    pub fn result(&self) -> bool { self.result }
4538}
4539
4540
4541pub struct CanEmulateNetworkConditionsReturnsBuilder {
4542    result: bool,
4543}
4544
4545impl CanEmulateNetworkConditionsReturnsBuilder {
4546    pub fn build(self) -> CanEmulateNetworkConditionsReturns {
4547        CanEmulateNetworkConditionsReturns {
4548            result: self.result,
4549        }
4550    }
4551}
4552
4553#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4554pub struct CanEmulateNetworkConditionsParams {}
4555
4556impl CanEmulateNetworkConditionsParams { pub const METHOD: &'static str = "Network.canEmulateNetworkConditions"; }
4557
4558impl<'a> crate::CdpCommand<'a> for CanEmulateNetworkConditionsParams {
4559    const METHOD: &'static str = "Network.canEmulateNetworkConditions";
4560    type Response = CanEmulateNetworkConditionsReturns;
4561}
4562
4563#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4564pub struct ClearBrowserCacheParams {}
4565
4566impl ClearBrowserCacheParams { pub const METHOD: &'static str = "Network.clearBrowserCache"; }
4567
4568impl<'a> crate::CdpCommand<'a> for ClearBrowserCacheParams {
4569    const METHOD: &'static str = "Network.clearBrowserCache";
4570    type Response = crate::EmptyReturns;
4571}
4572
4573#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4574pub struct ClearBrowserCookiesParams {}
4575
4576impl ClearBrowserCookiesParams { pub const METHOD: &'static str = "Network.clearBrowserCookies"; }
4577
4578impl<'a> crate::CdpCommand<'a> for ClearBrowserCookiesParams {
4579    const METHOD: &'static str = "Network.clearBrowserCookies";
4580    type Response = crate::EmptyReturns;
4581}
4582
4583/// Response to Network.requestIntercepted which either modifies the request to continue with any
4584/// modifications, or blocks it, or completes it with the provided response bytes. If a network
4585/// fetch occurs as a result which encounters a redirect an additional Network.requestIntercepted
4586/// event will be sent with the same InterceptionId.
4587/// Deprecated, use Fetch.continueRequest, Fetch.fulfillRequest and Fetch.failRequest instead.
4588
4589#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4590#[serde(rename_all = "camelCase")]
4591pub struct ContinueInterceptedRequestParams<'a> {
4592    interceptionId: InterceptionId<'a>,
4593    /// If set this causes the request to fail with the given reason. Passing 'Aborted' for requests
4594    /// marked with 'isNavigationRequest' also cancels the navigation. Must not be set in response
4595    /// to an authChallenge.
4596    #[serde(skip_serializing_if = "Option::is_none")]
4597    errorReason: Option<ErrorReason>,
4598    /// If set the requests completes using with the provided base64 encoded raw response, including
4599    /// HTTP status line and headers etc... Must not be set in response to an authChallenge. (Encoded as a base64 string when passed over JSON)
4600    #[serde(skip_serializing_if = "Option::is_none")]
4601    rawResponse: Option<Cow<'a, str>>,
4602    /// If set the request url will be modified in a way that's not observable by page. Must not be
4603    /// set in response to an authChallenge.
4604    #[serde(skip_serializing_if = "Option::is_none")]
4605    url: Option<Cow<'a, str>>,
4606    /// If set this allows the request method to be overridden. Must not be set in response to an
4607    /// authChallenge.
4608    #[serde(skip_serializing_if = "Option::is_none")]
4609    method: Option<Cow<'a, str>>,
4610    /// If set this allows postData to be set. Must not be set in response to an authChallenge.
4611    #[serde(skip_serializing_if = "Option::is_none")]
4612    postData: Option<Cow<'a, str>>,
4613    /// If set this allows the request headers to be changed. Must not be set in response to an
4614    /// authChallenge.
4615    #[serde(skip_serializing_if = "Option::is_none")]
4616    headers: Option<Headers>,
4617    /// Response to a requestIntercepted with an authChallenge. Must not be set otherwise.
4618    #[serde(skip_serializing_if = "Option::is_none")]
4619    authChallengeResponse: Option<AuthChallengeResponse<'a>>,
4620}
4621
4622impl<'a> ContinueInterceptedRequestParams<'a> {
4623    pub fn builder(interceptionId: InterceptionId<'a>) -> ContinueInterceptedRequestParamsBuilder<'a> {
4624        ContinueInterceptedRequestParamsBuilder {
4625            interceptionId: interceptionId,
4626            errorReason: None,
4627            rawResponse: None,
4628            url: None,
4629            method: None,
4630            postData: None,
4631            headers: None,
4632            authChallengeResponse: None,
4633        }
4634    }
4635    pub fn interceptionId(&self) -> &InterceptionId<'a> { &self.interceptionId }
4636    pub fn errorReason(&self) -> Option<&ErrorReason> { self.errorReason.as_ref() }
4637    pub fn rawResponse(&self) -> Option<&str> { self.rawResponse.as_deref() }
4638    pub fn url(&self) -> Option<&str> { self.url.as_deref() }
4639    pub fn method(&self) -> Option<&str> { self.method.as_deref() }
4640    pub fn postData(&self) -> Option<&str> { self.postData.as_deref() }
4641    pub fn headers(&self) -> Option<&Headers> { self.headers.as_ref() }
4642    pub fn authChallengeResponse(&self) -> Option<&AuthChallengeResponse<'a>> { self.authChallengeResponse.as_ref() }
4643}
4644
4645
4646pub struct ContinueInterceptedRequestParamsBuilder<'a> {
4647    interceptionId: InterceptionId<'a>,
4648    errorReason: Option<ErrorReason>,
4649    rawResponse: Option<Cow<'a, str>>,
4650    url: Option<Cow<'a, str>>,
4651    method: Option<Cow<'a, str>>,
4652    postData: Option<Cow<'a, str>>,
4653    headers: Option<Headers>,
4654    authChallengeResponse: Option<AuthChallengeResponse<'a>>,
4655}
4656
4657impl<'a> ContinueInterceptedRequestParamsBuilder<'a> {
4658    /// If set this causes the request to fail with the given reason. Passing 'Aborted' for requests
4659    /// marked with 'isNavigationRequest' also cancels the navigation. Must not be set in response
4660    /// to an authChallenge.
4661    pub fn errorReason(mut self, errorReason: ErrorReason) -> Self { self.errorReason = Some(errorReason); self }
4662    /// If set the requests completes using with the provided base64 encoded raw response, including
4663    /// HTTP status line and headers etc... Must not be set in response to an authChallenge. (Encoded as a base64 string when passed over JSON)
4664    pub fn rawResponse(mut self, rawResponse: impl Into<Cow<'a, str>>) -> Self { self.rawResponse = Some(rawResponse.into()); self }
4665    /// If set the request url will be modified in a way that's not observable by page. Must not be
4666    /// set in response to an authChallenge.
4667    pub fn url(mut self, url: impl Into<Cow<'a, str>>) -> Self { self.url = Some(url.into()); self }
4668    /// If set this allows the request method to be overridden. Must not be set in response to an
4669    /// authChallenge.
4670    pub fn method(mut self, method: impl Into<Cow<'a, str>>) -> Self { self.method = Some(method.into()); self }
4671    /// If set this allows postData to be set. Must not be set in response to an authChallenge.
4672    pub fn postData(mut self, postData: impl Into<Cow<'a, str>>) -> Self { self.postData = Some(postData.into()); self }
4673    /// If set this allows the request headers to be changed. Must not be set in response to an
4674    /// authChallenge.
4675    pub fn headers(mut self, headers: Headers) -> Self { self.headers = Some(headers); self }
4676    /// Response to a requestIntercepted with an authChallenge. Must not be set otherwise.
4677    pub fn authChallengeResponse(mut self, authChallengeResponse: AuthChallengeResponse<'a>) -> Self { self.authChallengeResponse = Some(authChallengeResponse); self }
4678    pub fn build(self) -> ContinueInterceptedRequestParams<'a> {
4679        ContinueInterceptedRequestParams {
4680            interceptionId: self.interceptionId,
4681            errorReason: self.errorReason,
4682            rawResponse: self.rawResponse,
4683            url: self.url,
4684            method: self.method,
4685            postData: self.postData,
4686            headers: self.headers,
4687            authChallengeResponse: self.authChallengeResponse,
4688        }
4689    }
4690}
4691
4692impl<'a> ContinueInterceptedRequestParams<'a> { pub const METHOD: &'static str = "Network.continueInterceptedRequest"; }
4693
4694impl<'a> crate::CdpCommand<'a> for ContinueInterceptedRequestParams<'a> {
4695    const METHOD: &'static str = "Network.continueInterceptedRequest";
4696    type Response = crate::EmptyReturns;
4697}
4698
4699/// Deletes browser cookies with matching name and url or domain/path/partitionKey pair.
4700
4701#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4702#[serde(rename_all = "camelCase")]
4703pub struct DeleteCookiesParams<'a> {
4704    /// Name of the cookies to remove.
4705    name: Cow<'a, str>,
4706    /// If specified, deletes all the cookies with the given name where domain and path match
4707    /// provided URL.
4708    #[serde(skip_serializing_if = "Option::is_none")]
4709    url: Option<Cow<'a, str>>,
4710    /// If specified, deletes only cookies with the exact domain.
4711    #[serde(skip_serializing_if = "Option::is_none")]
4712    domain: Option<Cow<'a, str>>,
4713    /// If specified, deletes only cookies with the exact path.
4714    #[serde(skip_serializing_if = "Option::is_none")]
4715    path: Option<Cow<'a, str>>,
4716    /// If specified, deletes only cookies with the the given name and partitionKey where
4717    /// all partition key attributes match the cookie partition key attribute.
4718    #[serde(skip_serializing_if = "Option::is_none")]
4719    partitionKey: Option<CookiePartitionKey<'a>>,
4720}
4721
4722impl<'a> DeleteCookiesParams<'a> {
4723    pub fn builder(name: impl Into<Cow<'a, str>>) -> DeleteCookiesParamsBuilder<'a> {
4724        DeleteCookiesParamsBuilder {
4725            name: name.into(),
4726            url: None,
4727            domain: None,
4728            path: None,
4729            partitionKey: None,
4730        }
4731    }
4732    pub fn name(&self) -> &str { self.name.as_ref() }
4733    pub fn url(&self) -> Option<&str> { self.url.as_deref() }
4734    pub fn domain(&self) -> Option<&str> { self.domain.as_deref() }
4735    pub fn path(&self) -> Option<&str> { self.path.as_deref() }
4736    pub fn partitionKey(&self) -> Option<&CookiePartitionKey<'a>> { self.partitionKey.as_ref() }
4737}
4738
4739
4740pub struct DeleteCookiesParamsBuilder<'a> {
4741    name: Cow<'a, str>,
4742    url: Option<Cow<'a, str>>,
4743    domain: Option<Cow<'a, str>>,
4744    path: Option<Cow<'a, str>>,
4745    partitionKey: Option<CookiePartitionKey<'a>>,
4746}
4747
4748impl<'a> DeleteCookiesParamsBuilder<'a> {
4749    /// If specified, deletes all the cookies with the given name where domain and path match
4750    /// provided URL.
4751    pub fn url(mut self, url: impl Into<Cow<'a, str>>) -> Self { self.url = Some(url.into()); self }
4752    /// If specified, deletes only cookies with the exact domain.
4753    pub fn domain(mut self, domain: impl Into<Cow<'a, str>>) -> Self { self.domain = Some(domain.into()); self }
4754    /// If specified, deletes only cookies with the exact path.
4755    pub fn path(mut self, path: impl Into<Cow<'a, str>>) -> Self { self.path = Some(path.into()); self }
4756    /// If specified, deletes only cookies with the the given name and partitionKey where
4757    /// all partition key attributes match the cookie partition key attribute.
4758    pub fn partitionKey(mut self, partitionKey: CookiePartitionKey<'a>) -> Self { self.partitionKey = Some(partitionKey); self }
4759    pub fn build(self) -> DeleteCookiesParams<'a> {
4760        DeleteCookiesParams {
4761            name: self.name,
4762            url: self.url,
4763            domain: self.domain,
4764            path: self.path,
4765            partitionKey: self.partitionKey,
4766        }
4767    }
4768}
4769
4770impl<'a> DeleteCookiesParams<'a> { pub const METHOD: &'static str = "Network.deleteCookies"; }
4771
4772impl<'a> crate::CdpCommand<'a> for DeleteCookiesParams<'a> {
4773    const METHOD: &'static str = "Network.deleteCookies";
4774    type Response = crate::EmptyReturns;
4775}
4776
4777#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4778pub struct DisableParams {}
4779
4780impl DisableParams { pub const METHOD: &'static str = "Network.disable"; }
4781
4782impl<'a> crate::CdpCommand<'a> for DisableParams {
4783    const METHOD: &'static str = "Network.disable";
4784    type Response = crate::EmptyReturns;
4785}
4786
4787/// Activates emulation of network conditions. This command is deprecated in favor of the emulateNetworkConditionsByRule
4788/// and overrideNetworkState commands, which can be used together to the same effect.
4789
4790#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4791#[serde(rename_all = "camelCase")]
4792pub struct EmulateNetworkConditionsParams {
4793    /// True to emulate internet disconnection.
4794    offline: bool,
4795    /// Minimum latency from request sent to response headers received (ms).
4796    latency: f64,
4797    /// Maximal aggregated download throughput (bytes/sec). -1 disables download throttling.
4798    downloadThroughput: f64,
4799    /// Maximal aggregated upload throughput (bytes/sec).  -1 disables upload throttling.
4800    uploadThroughput: f64,
4801    /// Connection type if known.
4802    #[serde(skip_serializing_if = "Option::is_none")]
4803    connectionType: Option<ConnectionType>,
4804    /// WebRTC packet loss (percent, 0-100). 0 disables packet loss emulation, 100 drops all the packets.
4805    #[serde(skip_serializing_if = "Option::is_none")]
4806    packetLoss: Option<f64>,
4807    /// WebRTC packet queue length (packet). 0 removes any queue length limitations.
4808    #[serde(skip_serializing_if = "Option::is_none")]
4809    packetQueueLength: Option<u64>,
4810    /// WebRTC packetReordering feature.
4811    #[serde(skip_serializing_if = "Option::is_none")]
4812    packetReordering: Option<bool>,
4813}
4814
4815impl EmulateNetworkConditionsParams {
4816    pub fn builder(offline: bool, latency: f64, downloadThroughput: f64, uploadThroughput: f64) -> EmulateNetworkConditionsParamsBuilder {
4817        EmulateNetworkConditionsParamsBuilder {
4818            offline: offline,
4819            latency: latency,
4820            downloadThroughput: downloadThroughput,
4821            uploadThroughput: uploadThroughput,
4822            connectionType: None,
4823            packetLoss: None,
4824            packetQueueLength: None,
4825            packetReordering: None,
4826        }
4827    }
4828    pub fn offline(&self) -> bool { self.offline }
4829    pub fn latency(&self) -> f64 { self.latency }
4830    pub fn downloadThroughput(&self) -> f64 { self.downloadThroughput }
4831    pub fn uploadThroughput(&self) -> f64 { self.uploadThroughput }
4832    pub fn connectionType(&self) -> Option<&ConnectionType> { self.connectionType.as_ref() }
4833    pub fn packetLoss(&self) -> Option<f64> { self.packetLoss }
4834    pub fn packetQueueLength(&self) -> Option<u64> { self.packetQueueLength }
4835    pub fn packetReordering(&self) -> Option<bool> { self.packetReordering }
4836}
4837
4838
4839pub struct EmulateNetworkConditionsParamsBuilder {
4840    offline: bool,
4841    latency: f64,
4842    downloadThroughput: f64,
4843    uploadThroughput: f64,
4844    connectionType: Option<ConnectionType>,
4845    packetLoss: Option<f64>,
4846    packetQueueLength: Option<u64>,
4847    packetReordering: Option<bool>,
4848}
4849
4850impl EmulateNetworkConditionsParamsBuilder {
4851    /// Connection type if known.
4852    pub fn connectionType(mut self, connectionType: ConnectionType) -> Self { self.connectionType = Some(connectionType); self }
4853    /// WebRTC packet loss (percent, 0-100). 0 disables packet loss emulation, 100 drops all the packets.
4854    pub fn packetLoss(mut self, packetLoss: f64) -> Self { self.packetLoss = Some(packetLoss); self }
4855    /// WebRTC packet queue length (packet). 0 removes any queue length limitations.
4856    pub fn packetQueueLength(mut self, packetQueueLength: u64) -> Self { self.packetQueueLength = Some(packetQueueLength); self }
4857    /// WebRTC packetReordering feature.
4858    pub fn packetReordering(mut self, packetReordering: bool) -> Self { self.packetReordering = Some(packetReordering); self }
4859    pub fn build(self) -> EmulateNetworkConditionsParams {
4860        EmulateNetworkConditionsParams {
4861            offline: self.offline,
4862            latency: self.latency,
4863            downloadThroughput: self.downloadThroughput,
4864            uploadThroughput: self.uploadThroughput,
4865            connectionType: self.connectionType,
4866            packetLoss: self.packetLoss,
4867            packetQueueLength: self.packetQueueLength,
4868            packetReordering: self.packetReordering,
4869        }
4870    }
4871}
4872
4873impl EmulateNetworkConditionsParams { pub const METHOD: &'static str = "Network.emulateNetworkConditions"; }
4874
4875impl<'a> crate::CdpCommand<'a> for EmulateNetworkConditionsParams {
4876    const METHOD: &'static str = "Network.emulateNetworkConditions";
4877    type Response = crate::EmptyReturns;
4878}
4879
4880/// Activates emulation of network conditions for individual requests using URL match patterns. Unlike the deprecated
4881/// Network.emulateNetworkConditions this method does not affect 'navigator' state. Use Network.overrideNetworkState to
4882/// explicitly modify 'navigator' behavior.
4883
4884#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4885#[serde(rename_all = "camelCase")]
4886pub struct EmulateNetworkConditionsByRuleParams<'a> {
4887    /// True to emulate internet disconnection. Deprecated, use the offline property in matchedNetworkConditions
4888    /// or emulateOfflineServiceWorker instead.
4889    #[serde(skip_serializing_if = "Option::is_none")]
4890    offline: Option<bool>,
4891    /// True to emulate offline service worker.
4892    #[serde(skip_serializing_if = "Option::is_none")]
4893    emulateOfflineServiceWorker: Option<bool>,
4894    /// Configure conditions for matching requests. If multiple entries match a request, the first entry wins.  Global
4895    /// conditions can be configured by leaving the urlPattern for the conditions empty. These global conditions are
4896    /// also applied for throttling of p2p connections.
4897    matchedNetworkConditions: Vec<NetworkConditions<'a>>,
4898}
4899
4900impl<'a> EmulateNetworkConditionsByRuleParams<'a> {
4901    pub fn builder(matchedNetworkConditions: Vec<NetworkConditions<'a>>) -> EmulateNetworkConditionsByRuleParamsBuilder<'a> {
4902        EmulateNetworkConditionsByRuleParamsBuilder {
4903            offline: None,
4904            emulateOfflineServiceWorker: None,
4905            matchedNetworkConditions: matchedNetworkConditions,
4906        }
4907    }
4908    pub fn offline(&self) -> Option<bool> { self.offline }
4909    pub fn emulateOfflineServiceWorker(&self) -> Option<bool> { self.emulateOfflineServiceWorker }
4910    pub fn matchedNetworkConditions(&self) -> &[NetworkConditions<'a>] { &self.matchedNetworkConditions }
4911}
4912
4913
4914pub struct EmulateNetworkConditionsByRuleParamsBuilder<'a> {
4915    offline: Option<bool>,
4916    emulateOfflineServiceWorker: Option<bool>,
4917    matchedNetworkConditions: Vec<NetworkConditions<'a>>,
4918}
4919
4920impl<'a> EmulateNetworkConditionsByRuleParamsBuilder<'a> {
4921    /// True to emulate internet disconnection. Deprecated, use the offline property in matchedNetworkConditions
4922    /// or emulateOfflineServiceWorker instead.
4923    pub fn offline(mut self, offline: bool) -> Self { self.offline = Some(offline); self }
4924    /// True to emulate offline service worker.
4925    pub fn emulateOfflineServiceWorker(mut self, emulateOfflineServiceWorker: bool) -> Self { self.emulateOfflineServiceWorker = Some(emulateOfflineServiceWorker); self }
4926    pub fn build(self) -> EmulateNetworkConditionsByRuleParams<'a> {
4927        EmulateNetworkConditionsByRuleParams {
4928            offline: self.offline,
4929            emulateOfflineServiceWorker: self.emulateOfflineServiceWorker,
4930            matchedNetworkConditions: self.matchedNetworkConditions,
4931        }
4932    }
4933}
4934
4935/// Activates emulation of network conditions for individual requests using URL match patterns. Unlike the deprecated
4936/// Network.emulateNetworkConditions this method does not affect 'navigator' state. Use Network.overrideNetworkState to
4937/// explicitly modify 'navigator' behavior.
4938
4939#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4940#[serde(rename_all = "camelCase")]
4941pub struct EmulateNetworkConditionsByRuleReturns<'a> {
4942    /// An id for each entry in matchedNetworkConditions. The id will be included in the requestWillBeSentExtraInfo for
4943    /// requests affected by a rule.
4944    ruleIds: Vec<Cow<'a, str>>,
4945}
4946
4947impl<'a> EmulateNetworkConditionsByRuleReturns<'a> {
4948    pub fn builder(ruleIds: Vec<Cow<'a, str>>) -> EmulateNetworkConditionsByRuleReturnsBuilder<'a> {
4949        EmulateNetworkConditionsByRuleReturnsBuilder {
4950            ruleIds: ruleIds,
4951        }
4952    }
4953    pub fn ruleIds(&self) -> &[Cow<'a, str>] { &self.ruleIds }
4954}
4955
4956
4957pub struct EmulateNetworkConditionsByRuleReturnsBuilder<'a> {
4958    ruleIds: Vec<Cow<'a, str>>,
4959}
4960
4961impl<'a> EmulateNetworkConditionsByRuleReturnsBuilder<'a> {
4962    pub fn build(self) -> EmulateNetworkConditionsByRuleReturns<'a> {
4963        EmulateNetworkConditionsByRuleReturns {
4964            ruleIds: self.ruleIds,
4965        }
4966    }
4967}
4968
4969impl<'a> EmulateNetworkConditionsByRuleParams<'a> { pub const METHOD: &'static str = "Network.emulateNetworkConditionsByRule"; }
4970
4971impl<'a> crate::CdpCommand<'a> for EmulateNetworkConditionsByRuleParams<'a> {
4972    const METHOD: &'static str = "Network.emulateNetworkConditionsByRule";
4973    type Response = EmulateNetworkConditionsByRuleReturns<'a>;
4974}
4975
4976/// Override the state of navigator.onLine and navigator.connection.
4977
4978#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4979#[serde(rename_all = "camelCase")]
4980pub struct OverrideNetworkStateParams {
4981    /// True to emulate internet disconnection.
4982    offline: bool,
4983    /// Minimum latency from request sent to response headers received (ms).
4984    latency: f64,
4985    /// Maximal aggregated download throughput (bytes/sec). -1 disables download throttling.
4986    downloadThroughput: f64,
4987    /// Maximal aggregated upload throughput (bytes/sec).  -1 disables upload throttling.
4988    uploadThroughput: f64,
4989    /// Connection type if known.
4990    #[serde(skip_serializing_if = "Option::is_none")]
4991    connectionType: Option<ConnectionType>,
4992}
4993
4994impl OverrideNetworkStateParams {
4995    pub fn builder(offline: bool, latency: f64, downloadThroughput: f64, uploadThroughput: f64) -> OverrideNetworkStateParamsBuilder {
4996        OverrideNetworkStateParamsBuilder {
4997            offline: offline,
4998            latency: latency,
4999            downloadThroughput: downloadThroughput,
5000            uploadThroughput: uploadThroughput,
5001            connectionType: None,
5002        }
5003    }
5004    pub fn offline(&self) -> bool { self.offline }
5005    pub fn latency(&self) -> f64 { self.latency }
5006    pub fn downloadThroughput(&self) -> f64 { self.downloadThroughput }
5007    pub fn uploadThroughput(&self) -> f64 { self.uploadThroughput }
5008    pub fn connectionType(&self) -> Option<&ConnectionType> { self.connectionType.as_ref() }
5009}
5010
5011
5012pub struct OverrideNetworkStateParamsBuilder {
5013    offline: bool,
5014    latency: f64,
5015    downloadThroughput: f64,
5016    uploadThroughput: f64,
5017    connectionType: Option<ConnectionType>,
5018}
5019
5020impl OverrideNetworkStateParamsBuilder {
5021    /// Connection type if known.
5022    pub fn connectionType(mut self, connectionType: ConnectionType) -> Self { self.connectionType = Some(connectionType); self }
5023    pub fn build(self) -> OverrideNetworkStateParams {
5024        OverrideNetworkStateParams {
5025            offline: self.offline,
5026            latency: self.latency,
5027            downloadThroughput: self.downloadThroughput,
5028            uploadThroughput: self.uploadThroughput,
5029            connectionType: self.connectionType,
5030        }
5031    }
5032}
5033
5034impl OverrideNetworkStateParams { pub const METHOD: &'static str = "Network.overrideNetworkState"; }
5035
5036impl<'a> crate::CdpCommand<'a> for OverrideNetworkStateParams {
5037    const METHOD: &'static str = "Network.overrideNetworkState";
5038    type Response = crate::EmptyReturns;
5039}
5040
5041/// Enables network tracking, network events will now be delivered to the client.
5042
5043#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5044#[serde(rename_all = "camelCase")]
5045pub struct EnableParams {
5046    /// Buffer size in bytes to use when preserving network payloads (XHRs, etc).
5047    /// This is the maximum number of bytes that will be collected by this
5048    /// DevTools session.
5049    #[serde(skip_serializing_if = "Option::is_none")]
5050    maxTotalBufferSize: Option<u64>,
5051    /// Per-resource buffer size in bytes to use when preserving network payloads (XHRs, etc).
5052    #[serde(skip_serializing_if = "Option::is_none")]
5053    maxResourceBufferSize: Option<u64>,
5054    /// Longest post body size (in bytes) that would be included in requestWillBeSent notification
5055    #[serde(skip_serializing_if = "Option::is_none")]
5056    maxPostDataSize: Option<u64>,
5057    /// Whether DirectSocket chunk send/receive events should be reported.
5058    #[serde(skip_serializing_if = "Option::is_none")]
5059    reportDirectSocketTraffic: Option<bool>,
5060    /// Enable storing response bodies outside of renderer, so that these survive
5061    /// a cross-process navigation. Requires maxTotalBufferSize to be set.
5062    /// Currently defaults to false. This field is being deprecated in favor of the dedicated
5063    /// configureDurableMessages command, due to the possibility of deadlocks when awaiting
5064    /// Network.enable before issuing Runtime.runIfWaitingForDebugger.
5065    #[serde(skip_serializing_if = "Option::is_none")]
5066    enableDurableMessages: Option<bool>,
5067}
5068
5069impl EnableParams {
5070    pub fn builder() -> EnableParamsBuilder {
5071        EnableParamsBuilder {
5072            maxTotalBufferSize: None,
5073            maxResourceBufferSize: None,
5074            maxPostDataSize: None,
5075            reportDirectSocketTraffic: None,
5076            enableDurableMessages: None,
5077        }
5078    }
5079    pub fn maxTotalBufferSize(&self) -> Option<u64> { self.maxTotalBufferSize }
5080    pub fn maxResourceBufferSize(&self) -> Option<u64> { self.maxResourceBufferSize }
5081    pub fn maxPostDataSize(&self) -> Option<u64> { self.maxPostDataSize }
5082    pub fn reportDirectSocketTraffic(&self) -> Option<bool> { self.reportDirectSocketTraffic }
5083    pub fn enableDurableMessages(&self) -> Option<bool> { self.enableDurableMessages }
5084}
5085
5086#[derive(Default)]
5087pub struct EnableParamsBuilder {
5088    maxTotalBufferSize: Option<u64>,
5089    maxResourceBufferSize: Option<u64>,
5090    maxPostDataSize: Option<u64>,
5091    reportDirectSocketTraffic: Option<bool>,
5092    enableDurableMessages: Option<bool>,
5093}
5094
5095impl EnableParamsBuilder {
5096    /// Buffer size in bytes to use when preserving network payloads (XHRs, etc).
5097    /// This is the maximum number of bytes that will be collected by this
5098    /// DevTools session.
5099    pub fn maxTotalBufferSize(mut self, maxTotalBufferSize: u64) -> Self { self.maxTotalBufferSize = Some(maxTotalBufferSize); self }
5100    /// Per-resource buffer size in bytes to use when preserving network payloads (XHRs, etc).
5101    pub fn maxResourceBufferSize(mut self, maxResourceBufferSize: u64) -> Self { self.maxResourceBufferSize = Some(maxResourceBufferSize); self }
5102    /// Longest post body size (in bytes) that would be included in requestWillBeSent notification
5103    pub fn maxPostDataSize(mut self, maxPostDataSize: u64) -> Self { self.maxPostDataSize = Some(maxPostDataSize); self }
5104    /// Whether DirectSocket chunk send/receive events should be reported.
5105    pub fn reportDirectSocketTraffic(mut self, reportDirectSocketTraffic: bool) -> Self { self.reportDirectSocketTraffic = Some(reportDirectSocketTraffic); self }
5106    /// Enable storing response bodies outside of renderer, so that these survive
5107    /// a cross-process navigation. Requires maxTotalBufferSize to be set.
5108    /// Currently defaults to false. This field is being deprecated in favor of the dedicated
5109    /// configureDurableMessages command, due to the possibility of deadlocks when awaiting
5110    /// Network.enable before issuing Runtime.runIfWaitingForDebugger.
5111    pub fn enableDurableMessages(mut self, enableDurableMessages: bool) -> Self { self.enableDurableMessages = Some(enableDurableMessages); self }
5112    pub fn build(self) -> EnableParams {
5113        EnableParams {
5114            maxTotalBufferSize: self.maxTotalBufferSize,
5115            maxResourceBufferSize: self.maxResourceBufferSize,
5116            maxPostDataSize: self.maxPostDataSize,
5117            reportDirectSocketTraffic: self.reportDirectSocketTraffic,
5118            enableDurableMessages: self.enableDurableMessages,
5119        }
5120    }
5121}
5122
5123impl EnableParams { pub const METHOD: &'static str = "Network.enable"; }
5124
5125impl<'a> crate::CdpCommand<'a> for EnableParams {
5126    const METHOD: &'static str = "Network.enable";
5127    type Response = crate::EmptyReturns;
5128}
5129
5130/// Configures storing response bodies outside of renderer, so that these survive
5131/// a cross-process navigation.
5132/// If maxTotalBufferSize is not set, durable messages are disabled.
5133
5134#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5135#[serde(rename_all = "camelCase")]
5136pub struct ConfigureDurableMessagesParams {
5137    /// Buffer size in bytes to use when preserving network payloads (XHRs, etc).
5138    #[serde(skip_serializing_if = "Option::is_none")]
5139    maxTotalBufferSize: Option<u64>,
5140    /// Per-resource buffer size in bytes to use when preserving network payloads (XHRs, etc).
5141    #[serde(skip_serializing_if = "Option::is_none")]
5142    maxResourceBufferSize: Option<u64>,
5143}
5144
5145impl ConfigureDurableMessagesParams {
5146    pub fn builder() -> ConfigureDurableMessagesParamsBuilder {
5147        ConfigureDurableMessagesParamsBuilder {
5148            maxTotalBufferSize: None,
5149            maxResourceBufferSize: None,
5150        }
5151    }
5152    pub fn maxTotalBufferSize(&self) -> Option<u64> { self.maxTotalBufferSize }
5153    pub fn maxResourceBufferSize(&self) -> Option<u64> { self.maxResourceBufferSize }
5154}
5155
5156#[derive(Default)]
5157pub struct ConfigureDurableMessagesParamsBuilder {
5158    maxTotalBufferSize: Option<u64>,
5159    maxResourceBufferSize: Option<u64>,
5160}
5161
5162impl ConfigureDurableMessagesParamsBuilder {
5163    /// Buffer size in bytes to use when preserving network payloads (XHRs, etc).
5164    pub fn maxTotalBufferSize(mut self, maxTotalBufferSize: u64) -> Self { self.maxTotalBufferSize = Some(maxTotalBufferSize); self }
5165    /// Per-resource buffer size in bytes to use when preserving network payloads (XHRs, etc).
5166    pub fn maxResourceBufferSize(mut self, maxResourceBufferSize: u64) -> Self { self.maxResourceBufferSize = Some(maxResourceBufferSize); self }
5167    pub fn build(self) -> ConfigureDurableMessagesParams {
5168        ConfigureDurableMessagesParams {
5169            maxTotalBufferSize: self.maxTotalBufferSize,
5170            maxResourceBufferSize: self.maxResourceBufferSize,
5171        }
5172    }
5173}
5174
5175impl ConfigureDurableMessagesParams { pub const METHOD: &'static str = "Network.configureDurableMessages"; }
5176
5177impl<'a> crate::CdpCommand<'a> for ConfigureDurableMessagesParams {
5178    const METHOD: &'static str = "Network.configureDurableMessages";
5179    type Response = crate::EmptyReturns;
5180}
5181
5182/// Returns all browser cookies. Depending on the backend support, will return detailed cookie
5183/// information in the 'cookies' field.
5184/// Deprecated. Use Storage.getCookies instead.
5185
5186#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5187#[serde(rename_all = "camelCase")]
5188pub struct GetAllCookiesReturns<'a> {
5189    /// Array of cookie objects.
5190    cookies: Vec<Cookie<'a>>,
5191}
5192
5193impl<'a> GetAllCookiesReturns<'a> {
5194    pub fn builder(cookies: Vec<Cookie<'a>>) -> GetAllCookiesReturnsBuilder<'a> {
5195        GetAllCookiesReturnsBuilder {
5196            cookies: cookies,
5197        }
5198    }
5199    pub fn cookies(&self) -> &[Cookie<'a>] { &self.cookies }
5200}
5201
5202
5203pub struct GetAllCookiesReturnsBuilder<'a> {
5204    cookies: Vec<Cookie<'a>>,
5205}
5206
5207impl<'a> GetAllCookiesReturnsBuilder<'a> {
5208    pub fn build(self) -> GetAllCookiesReturns<'a> {
5209        GetAllCookiesReturns {
5210            cookies: self.cookies,
5211        }
5212    }
5213}
5214
5215#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5216pub struct GetAllCookiesParams {}
5217
5218impl GetAllCookiesParams { pub const METHOD: &'static str = "Network.getAllCookies"; }
5219
5220impl<'a> crate::CdpCommand<'a> for GetAllCookiesParams {
5221    const METHOD: &'static str = "Network.getAllCookies";
5222    type Response = GetAllCookiesReturns<'a>;
5223}
5224
5225/// Returns the DER-encoded certificate.
5226
5227#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5228#[serde(rename_all = "camelCase")]
5229pub struct GetCertificateParams<'a> {
5230    /// Origin to get certificate for.
5231    origin: Cow<'a, str>,
5232}
5233
5234impl<'a> GetCertificateParams<'a> {
5235    pub fn builder(origin: impl Into<Cow<'a, str>>) -> GetCertificateParamsBuilder<'a> {
5236        GetCertificateParamsBuilder {
5237            origin: origin.into(),
5238        }
5239    }
5240    pub fn origin(&self) -> &str { self.origin.as_ref() }
5241}
5242
5243
5244pub struct GetCertificateParamsBuilder<'a> {
5245    origin: Cow<'a, str>,
5246}
5247
5248impl<'a> GetCertificateParamsBuilder<'a> {
5249    pub fn build(self) -> GetCertificateParams<'a> {
5250        GetCertificateParams {
5251            origin: self.origin,
5252        }
5253    }
5254}
5255
5256/// Returns the DER-encoded certificate.
5257
5258#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5259#[serde(rename_all = "camelCase")]
5260pub struct GetCertificateReturns<'a> {
5261    tableNames: Vec<Cow<'a, str>>,
5262}
5263
5264impl<'a> GetCertificateReturns<'a> {
5265    pub fn builder(tableNames: Vec<Cow<'a, str>>) -> GetCertificateReturnsBuilder<'a> {
5266        GetCertificateReturnsBuilder {
5267            tableNames: tableNames,
5268        }
5269    }
5270    pub fn tableNames(&self) -> &[Cow<'a, str>] { &self.tableNames }
5271}
5272
5273
5274pub struct GetCertificateReturnsBuilder<'a> {
5275    tableNames: Vec<Cow<'a, str>>,
5276}
5277
5278impl<'a> GetCertificateReturnsBuilder<'a> {
5279    pub fn build(self) -> GetCertificateReturns<'a> {
5280        GetCertificateReturns {
5281            tableNames: self.tableNames,
5282        }
5283    }
5284}
5285
5286impl<'a> GetCertificateParams<'a> { pub const METHOD: &'static str = "Network.getCertificate"; }
5287
5288impl<'a> crate::CdpCommand<'a> for GetCertificateParams<'a> {
5289    const METHOD: &'static str = "Network.getCertificate";
5290    type Response = GetCertificateReturns<'a>;
5291}
5292
5293/// Returns all browser cookies for the current URL. Depending on the backend support, will return
5294/// detailed cookie information in the 'cookies' field.
5295
5296#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5297#[serde(rename_all = "camelCase")]
5298pub struct GetCookiesParams<'a> {
5299    /// The list of URLs for which applicable cookies will be fetched.
5300    /// If not specified, it's assumed to be set to the list containing
5301    /// the URLs of the page and all of its subframes.
5302    #[serde(skip_serializing_if = "Option::is_none")]
5303    urls: Option<Vec<Cow<'a, str>>>,
5304}
5305
5306impl<'a> GetCookiesParams<'a> {
5307    pub fn builder() -> GetCookiesParamsBuilder<'a> {
5308        GetCookiesParamsBuilder {
5309            urls: None,
5310        }
5311    }
5312    pub fn urls(&self) -> Option<&[Cow<'a, str>]> { self.urls.as_deref() }
5313}
5314
5315#[derive(Default)]
5316pub struct GetCookiesParamsBuilder<'a> {
5317    urls: Option<Vec<Cow<'a, str>>>,
5318}
5319
5320impl<'a> GetCookiesParamsBuilder<'a> {
5321    /// The list of URLs for which applicable cookies will be fetched.
5322    /// If not specified, it's assumed to be set to the list containing
5323    /// the URLs of the page and all of its subframes.
5324    pub fn urls(mut self, urls: Vec<Cow<'a, str>>) -> Self { self.urls = Some(urls); self }
5325    pub fn build(self) -> GetCookiesParams<'a> {
5326        GetCookiesParams {
5327            urls: self.urls,
5328        }
5329    }
5330}
5331
5332/// Returns all browser cookies for the current URL. Depending on the backend support, will return
5333/// detailed cookie information in the 'cookies' field.
5334
5335#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5336#[serde(rename_all = "camelCase")]
5337pub struct GetCookiesReturns<'a> {
5338    /// Array of cookie objects.
5339    cookies: Vec<Cookie<'a>>,
5340}
5341
5342impl<'a> GetCookiesReturns<'a> {
5343    pub fn builder(cookies: Vec<Cookie<'a>>) -> GetCookiesReturnsBuilder<'a> {
5344        GetCookiesReturnsBuilder {
5345            cookies: cookies,
5346        }
5347    }
5348    pub fn cookies(&self) -> &[Cookie<'a>] { &self.cookies }
5349}
5350
5351
5352pub struct GetCookiesReturnsBuilder<'a> {
5353    cookies: Vec<Cookie<'a>>,
5354}
5355
5356impl<'a> GetCookiesReturnsBuilder<'a> {
5357    pub fn build(self) -> GetCookiesReturns<'a> {
5358        GetCookiesReturns {
5359            cookies: self.cookies,
5360        }
5361    }
5362}
5363
5364impl<'a> GetCookiesParams<'a> { pub const METHOD: &'static str = "Network.getCookies"; }
5365
5366impl<'a> crate::CdpCommand<'a> for GetCookiesParams<'a> {
5367    const METHOD: &'static str = "Network.getCookies";
5368    type Response = GetCookiesReturns<'a>;
5369}
5370
5371/// Returns content served for the given request.
5372
5373#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5374#[serde(rename_all = "camelCase")]
5375pub struct GetResponseBodyParams<'a> {
5376    /// Identifier of the network request to get content for.
5377    requestId: RequestId<'a>,
5378}
5379
5380impl<'a> GetResponseBodyParams<'a> {
5381    pub fn builder(requestId: RequestId<'a>) -> GetResponseBodyParamsBuilder<'a> {
5382        GetResponseBodyParamsBuilder {
5383            requestId: requestId,
5384        }
5385    }
5386    pub fn requestId(&self) -> &RequestId<'a> { &self.requestId }
5387}
5388
5389
5390pub struct GetResponseBodyParamsBuilder<'a> {
5391    requestId: RequestId<'a>,
5392}
5393
5394impl<'a> GetResponseBodyParamsBuilder<'a> {
5395    pub fn build(self) -> GetResponseBodyParams<'a> {
5396        GetResponseBodyParams {
5397            requestId: self.requestId,
5398        }
5399    }
5400}
5401
5402/// Returns content served for the given request.
5403
5404#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5405#[serde(rename_all = "camelCase")]
5406pub struct GetResponseBodyReturns<'a> {
5407    /// Response body.
5408    body: Cow<'a, str>,
5409    /// True, if content was sent as base64.
5410    base64Encoded: bool,
5411}
5412
5413impl<'a> GetResponseBodyReturns<'a> {
5414    pub fn builder(body: impl Into<Cow<'a, str>>, base64Encoded: bool) -> GetResponseBodyReturnsBuilder<'a> {
5415        GetResponseBodyReturnsBuilder {
5416            body: body.into(),
5417            base64Encoded: base64Encoded,
5418        }
5419    }
5420    pub fn body(&self) -> &str { self.body.as_ref() }
5421    pub fn base64Encoded(&self) -> bool { self.base64Encoded }
5422}
5423
5424
5425pub struct GetResponseBodyReturnsBuilder<'a> {
5426    body: Cow<'a, str>,
5427    base64Encoded: bool,
5428}
5429
5430impl<'a> GetResponseBodyReturnsBuilder<'a> {
5431    pub fn build(self) -> GetResponseBodyReturns<'a> {
5432        GetResponseBodyReturns {
5433            body: self.body,
5434            base64Encoded: self.base64Encoded,
5435        }
5436    }
5437}
5438
5439impl<'a> GetResponseBodyParams<'a> { pub const METHOD: &'static str = "Network.getResponseBody"; }
5440
5441impl<'a> crate::CdpCommand<'a> for GetResponseBodyParams<'a> {
5442    const METHOD: &'static str = "Network.getResponseBody";
5443    type Response = GetResponseBodyReturns<'a>;
5444}
5445
5446/// Returns post data sent with the request. Returns an error when no data was sent with the request.
5447
5448#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5449#[serde(rename_all = "camelCase")]
5450pub struct GetRequestPostDataParams<'a> {
5451    /// Identifier of the network request to get content for.
5452    requestId: RequestId<'a>,
5453}
5454
5455impl<'a> GetRequestPostDataParams<'a> {
5456    pub fn builder(requestId: RequestId<'a>) -> GetRequestPostDataParamsBuilder<'a> {
5457        GetRequestPostDataParamsBuilder {
5458            requestId: requestId,
5459        }
5460    }
5461    pub fn requestId(&self) -> &RequestId<'a> { &self.requestId }
5462}
5463
5464
5465pub struct GetRequestPostDataParamsBuilder<'a> {
5466    requestId: RequestId<'a>,
5467}
5468
5469impl<'a> GetRequestPostDataParamsBuilder<'a> {
5470    pub fn build(self) -> GetRequestPostDataParams<'a> {
5471        GetRequestPostDataParams {
5472            requestId: self.requestId,
5473        }
5474    }
5475}
5476
5477/// Returns post data sent with the request. Returns an error when no data was sent with the request.
5478
5479#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5480#[serde(rename_all = "camelCase")]
5481pub struct GetRequestPostDataReturns<'a> {
5482    /// Request body string, omitting files from multipart requests
5483    postData: Cow<'a, str>,
5484    /// True, if content was sent as base64.
5485    base64Encoded: bool,
5486}
5487
5488impl<'a> GetRequestPostDataReturns<'a> {
5489    pub fn builder(postData: impl Into<Cow<'a, str>>, base64Encoded: bool) -> GetRequestPostDataReturnsBuilder<'a> {
5490        GetRequestPostDataReturnsBuilder {
5491            postData: postData.into(),
5492            base64Encoded: base64Encoded,
5493        }
5494    }
5495    pub fn postData(&self) -> &str { self.postData.as_ref() }
5496    pub fn base64Encoded(&self) -> bool { self.base64Encoded }
5497}
5498
5499
5500pub struct GetRequestPostDataReturnsBuilder<'a> {
5501    postData: Cow<'a, str>,
5502    base64Encoded: bool,
5503}
5504
5505impl<'a> GetRequestPostDataReturnsBuilder<'a> {
5506    pub fn build(self) -> GetRequestPostDataReturns<'a> {
5507        GetRequestPostDataReturns {
5508            postData: self.postData,
5509            base64Encoded: self.base64Encoded,
5510        }
5511    }
5512}
5513
5514impl<'a> GetRequestPostDataParams<'a> { pub const METHOD: &'static str = "Network.getRequestPostData"; }
5515
5516impl<'a> crate::CdpCommand<'a> for GetRequestPostDataParams<'a> {
5517    const METHOD: &'static str = "Network.getRequestPostData";
5518    type Response = GetRequestPostDataReturns<'a>;
5519}
5520
5521/// Returns content served for the given currently intercepted request.
5522
5523#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5524#[serde(rename_all = "camelCase")]
5525pub struct GetResponseBodyForInterceptionParams<'a> {
5526    /// Identifier for the intercepted request to get body for.
5527    interceptionId: InterceptionId<'a>,
5528}
5529
5530impl<'a> GetResponseBodyForInterceptionParams<'a> {
5531    pub fn builder(interceptionId: InterceptionId<'a>) -> GetResponseBodyForInterceptionParamsBuilder<'a> {
5532        GetResponseBodyForInterceptionParamsBuilder {
5533            interceptionId: interceptionId,
5534        }
5535    }
5536    pub fn interceptionId(&self) -> &InterceptionId<'a> { &self.interceptionId }
5537}
5538
5539
5540pub struct GetResponseBodyForInterceptionParamsBuilder<'a> {
5541    interceptionId: InterceptionId<'a>,
5542}
5543
5544impl<'a> GetResponseBodyForInterceptionParamsBuilder<'a> {
5545    pub fn build(self) -> GetResponseBodyForInterceptionParams<'a> {
5546        GetResponseBodyForInterceptionParams {
5547            interceptionId: self.interceptionId,
5548        }
5549    }
5550}
5551
5552/// Returns content served for the given currently intercepted request.
5553
5554#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5555#[serde(rename_all = "camelCase")]
5556pub struct GetResponseBodyForInterceptionReturns<'a> {
5557    /// Response body.
5558    body: Cow<'a, str>,
5559    /// True, if content was sent as base64.
5560    base64Encoded: bool,
5561}
5562
5563impl<'a> GetResponseBodyForInterceptionReturns<'a> {
5564    pub fn builder(body: impl Into<Cow<'a, str>>, base64Encoded: bool) -> GetResponseBodyForInterceptionReturnsBuilder<'a> {
5565        GetResponseBodyForInterceptionReturnsBuilder {
5566            body: body.into(),
5567            base64Encoded: base64Encoded,
5568        }
5569    }
5570    pub fn body(&self) -> &str { self.body.as_ref() }
5571    pub fn base64Encoded(&self) -> bool { self.base64Encoded }
5572}
5573
5574
5575pub struct GetResponseBodyForInterceptionReturnsBuilder<'a> {
5576    body: Cow<'a, str>,
5577    base64Encoded: bool,
5578}
5579
5580impl<'a> GetResponseBodyForInterceptionReturnsBuilder<'a> {
5581    pub fn build(self) -> GetResponseBodyForInterceptionReturns<'a> {
5582        GetResponseBodyForInterceptionReturns {
5583            body: self.body,
5584            base64Encoded: self.base64Encoded,
5585        }
5586    }
5587}
5588
5589impl<'a> GetResponseBodyForInterceptionParams<'a> { pub const METHOD: &'static str = "Network.getResponseBodyForInterception"; }
5590
5591impl<'a> crate::CdpCommand<'a> for GetResponseBodyForInterceptionParams<'a> {
5592    const METHOD: &'static str = "Network.getResponseBodyForInterception";
5593    type Response = GetResponseBodyForInterceptionReturns<'a>;
5594}
5595
5596/// Returns a handle to the stream representing the response body. Note that after this command,
5597/// the intercepted request can't be continued as is -- you either need to cancel it or to provide
5598/// the response body. The stream only supports sequential read, IO.read will fail if the position
5599/// is specified.
5600
5601#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5602#[serde(rename_all = "camelCase")]
5603pub struct TakeResponseBodyForInterceptionAsStreamParams<'a> {
5604    interceptionId: InterceptionId<'a>,
5605}
5606
5607impl<'a> TakeResponseBodyForInterceptionAsStreamParams<'a> {
5608    pub fn builder(interceptionId: InterceptionId<'a>) -> TakeResponseBodyForInterceptionAsStreamParamsBuilder<'a> {
5609        TakeResponseBodyForInterceptionAsStreamParamsBuilder {
5610            interceptionId: interceptionId,
5611        }
5612    }
5613    pub fn interceptionId(&self) -> &InterceptionId<'a> { &self.interceptionId }
5614}
5615
5616
5617pub struct TakeResponseBodyForInterceptionAsStreamParamsBuilder<'a> {
5618    interceptionId: InterceptionId<'a>,
5619}
5620
5621impl<'a> TakeResponseBodyForInterceptionAsStreamParamsBuilder<'a> {
5622    pub fn build(self) -> TakeResponseBodyForInterceptionAsStreamParams<'a> {
5623        TakeResponseBodyForInterceptionAsStreamParams {
5624            interceptionId: self.interceptionId,
5625        }
5626    }
5627}
5628
5629/// Returns a handle to the stream representing the response body. Note that after this command,
5630/// the intercepted request can't be continued as is -- you either need to cancel it or to provide
5631/// the response body. The stream only supports sequential read, IO.read will fail if the position
5632/// is specified.
5633
5634#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5635#[serde(rename_all = "camelCase")]
5636pub struct TakeResponseBodyForInterceptionAsStreamReturns<'a> {
5637    stream: crate::io::StreamHandle<'a>,
5638}
5639
5640impl<'a> TakeResponseBodyForInterceptionAsStreamReturns<'a> {
5641    pub fn builder(stream: crate::io::StreamHandle<'a>) -> TakeResponseBodyForInterceptionAsStreamReturnsBuilder<'a> {
5642        TakeResponseBodyForInterceptionAsStreamReturnsBuilder {
5643            stream: stream,
5644        }
5645    }
5646    pub fn stream(&self) -> &crate::io::StreamHandle<'a> { &self.stream }
5647}
5648
5649
5650pub struct TakeResponseBodyForInterceptionAsStreamReturnsBuilder<'a> {
5651    stream: crate::io::StreamHandle<'a>,
5652}
5653
5654impl<'a> TakeResponseBodyForInterceptionAsStreamReturnsBuilder<'a> {
5655    pub fn build(self) -> TakeResponseBodyForInterceptionAsStreamReturns<'a> {
5656        TakeResponseBodyForInterceptionAsStreamReturns {
5657            stream: self.stream,
5658        }
5659    }
5660}
5661
5662impl<'a> TakeResponseBodyForInterceptionAsStreamParams<'a> { pub const METHOD: &'static str = "Network.takeResponseBodyForInterceptionAsStream"; }
5663
5664impl<'a> crate::CdpCommand<'a> for TakeResponseBodyForInterceptionAsStreamParams<'a> {
5665    const METHOD: &'static str = "Network.takeResponseBodyForInterceptionAsStream";
5666    type Response = TakeResponseBodyForInterceptionAsStreamReturns<'a>;
5667}
5668
5669/// This method sends a new XMLHttpRequest which is identical to the original one. The following
5670/// parameters should be identical: method, url, async, request body, extra headers, withCredentials
5671/// attribute, user, password.
5672
5673#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5674#[serde(rename_all = "camelCase")]
5675pub struct ReplayXHRParams<'a> {
5676    /// Identifier of XHR to replay.
5677    requestId: RequestId<'a>,
5678}
5679
5680impl<'a> ReplayXHRParams<'a> {
5681    pub fn builder(requestId: RequestId<'a>) -> ReplayXHRParamsBuilder<'a> {
5682        ReplayXHRParamsBuilder {
5683            requestId: requestId,
5684        }
5685    }
5686    pub fn requestId(&self) -> &RequestId<'a> { &self.requestId }
5687}
5688
5689
5690pub struct ReplayXHRParamsBuilder<'a> {
5691    requestId: RequestId<'a>,
5692}
5693
5694impl<'a> ReplayXHRParamsBuilder<'a> {
5695    pub fn build(self) -> ReplayXHRParams<'a> {
5696        ReplayXHRParams {
5697            requestId: self.requestId,
5698        }
5699    }
5700}
5701
5702impl<'a> ReplayXHRParams<'a> { pub const METHOD: &'static str = "Network.replayXHR"; }
5703
5704impl<'a> crate::CdpCommand<'a> for ReplayXHRParams<'a> {
5705    const METHOD: &'static str = "Network.replayXHR";
5706    type Response = crate::EmptyReturns;
5707}
5708
5709/// Searches for given string in response content.
5710
5711#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5712#[serde(rename_all = "camelCase")]
5713pub struct SearchInResponseBodyParams<'a> {
5714    /// Identifier of the network response to search.
5715    requestId: RequestId<'a>,
5716    /// String to search for.
5717    query: Cow<'a, str>,
5718    /// If true, search is case sensitive.
5719    #[serde(skip_serializing_if = "Option::is_none")]
5720    caseSensitive: Option<bool>,
5721    /// If true, treats string parameter as regex.
5722    #[serde(skip_serializing_if = "Option::is_none")]
5723    isRegex: Option<bool>,
5724}
5725
5726impl<'a> SearchInResponseBodyParams<'a> {
5727    pub fn builder(requestId: RequestId<'a>, query: impl Into<Cow<'a, str>>) -> SearchInResponseBodyParamsBuilder<'a> {
5728        SearchInResponseBodyParamsBuilder {
5729            requestId: requestId,
5730            query: query.into(),
5731            caseSensitive: None,
5732            isRegex: None,
5733        }
5734    }
5735    pub fn requestId(&self) -> &RequestId<'a> { &self.requestId }
5736    pub fn query(&self) -> &str { self.query.as_ref() }
5737    pub fn caseSensitive(&self) -> Option<bool> { self.caseSensitive }
5738    pub fn isRegex(&self) -> Option<bool> { self.isRegex }
5739}
5740
5741
5742pub struct SearchInResponseBodyParamsBuilder<'a> {
5743    requestId: RequestId<'a>,
5744    query: Cow<'a, str>,
5745    caseSensitive: Option<bool>,
5746    isRegex: Option<bool>,
5747}
5748
5749impl<'a> SearchInResponseBodyParamsBuilder<'a> {
5750    /// If true, search is case sensitive.
5751    pub fn caseSensitive(mut self, caseSensitive: bool) -> Self { self.caseSensitive = Some(caseSensitive); self }
5752    /// If true, treats string parameter as regex.
5753    pub fn isRegex(mut self, isRegex: bool) -> Self { self.isRegex = Some(isRegex); self }
5754    pub fn build(self) -> SearchInResponseBodyParams<'a> {
5755        SearchInResponseBodyParams {
5756            requestId: self.requestId,
5757            query: self.query,
5758            caseSensitive: self.caseSensitive,
5759            isRegex: self.isRegex,
5760        }
5761    }
5762}
5763
5764/// Searches for given string in response content.
5765
5766#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5767#[serde(rename_all = "camelCase")]
5768pub struct SearchInResponseBodyReturns {
5769    /// List of search matches.
5770    result: Vec<crate::debugger::SearchMatch>,
5771}
5772
5773impl SearchInResponseBodyReturns {
5774    pub fn builder(result: Vec<crate::debugger::SearchMatch>) -> SearchInResponseBodyReturnsBuilder {
5775        SearchInResponseBodyReturnsBuilder {
5776            result: result,
5777        }
5778    }
5779    pub fn result(&self) -> &[crate::debugger::SearchMatch] { &self.result }
5780}
5781
5782
5783pub struct SearchInResponseBodyReturnsBuilder {
5784    result: Vec<crate::debugger::SearchMatch>,
5785}
5786
5787impl SearchInResponseBodyReturnsBuilder {
5788    pub fn build(self) -> SearchInResponseBodyReturns {
5789        SearchInResponseBodyReturns {
5790            result: self.result,
5791        }
5792    }
5793}
5794
5795impl<'a> SearchInResponseBodyParams<'a> { pub const METHOD: &'static str = "Network.searchInResponseBody"; }
5796
5797impl<'a> crate::CdpCommand<'a> for SearchInResponseBodyParams<'a> {
5798    const METHOD: &'static str = "Network.searchInResponseBody";
5799    type Response = SearchInResponseBodyReturns;
5800}
5801
5802/// Blocks URLs from loading.
5803
5804#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5805#[serde(rename_all = "camelCase")]
5806pub struct SetBlockedURLsParams<'a> {
5807    /// Patterns to match in the order in which they are given. These patterns
5808    /// also take precedence over any wildcard patterns defined in 'urls'.
5809    #[serde(skip_serializing_if = "Option::is_none")]
5810    urlPatterns: Option<Vec<BlockPattern<'a>>>,
5811    /// URL patterns to block. Wildcards ('*') are allowed.
5812    #[serde(skip_serializing_if = "Option::is_none")]
5813    urls: Option<Vec<Cow<'a, str>>>,
5814}
5815
5816impl<'a> SetBlockedURLsParams<'a> {
5817    pub fn builder() -> SetBlockedURLsParamsBuilder<'a> {
5818        SetBlockedURLsParamsBuilder {
5819            urlPatterns: None,
5820            urls: None,
5821        }
5822    }
5823    pub fn urlPatterns(&self) -> Option<&[BlockPattern<'a>]> { self.urlPatterns.as_deref() }
5824    pub fn urls(&self) -> Option<&[Cow<'a, str>]> { self.urls.as_deref() }
5825}
5826
5827#[derive(Default)]
5828pub struct SetBlockedURLsParamsBuilder<'a> {
5829    urlPatterns: Option<Vec<BlockPattern<'a>>>,
5830    urls: Option<Vec<Cow<'a, str>>>,
5831}
5832
5833impl<'a> SetBlockedURLsParamsBuilder<'a> {
5834    /// Patterns to match in the order in which they are given. These patterns
5835    /// also take precedence over any wildcard patterns defined in 'urls'.
5836    pub fn urlPatterns(mut self, urlPatterns: Vec<BlockPattern<'a>>) -> Self { self.urlPatterns = Some(urlPatterns); self }
5837    /// URL patterns to block. Wildcards ('*') are allowed.
5838    pub fn urls(mut self, urls: Vec<Cow<'a, str>>) -> Self { self.urls = Some(urls); self }
5839    pub fn build(self) -> SetBlockedURLsParams<'a> {
5840        SetBlockedURLsParams {
5841            urlPatterns: self.urlPatterns,
5842            urls: self.urls,
5843        }
5844    }
5845}
5846
5847impl<'a> SetBlockedURLsParams<'a> { pub const METHOD: &'static str = "Network.setBlockedURLs"; }
5848
5849impl<'a> crate::CdpCommand<'a> for SetBlockedURLsParams<'a> {
5850    const METHOD: &'static str = "Network.setBlockedURLs";
5851    type Response = crate::EmptyReturns;
5852}
5853
5854/// Toggles ignoring of service worker for each request.
5855
5856#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5857#[serde(rename_all = "camelCase")]
5858pub struct SetBypassServiceWorkerParams {
5859    /// Bypass service worker and load from network.
5860    bypass: bool,
5861}
5862
5863impl SetBypassServiceWorkerParams {
5864    pub fn builder(bypass: bool) -> SetBypassServiceWorkerParamsBuilder {
5865        SetBypassServiceWorkerParamsBuilder {
5866            bypass: bypass,
5867        }
5868    }
5869    pub fn bypass(&self) -> bool { self.bypass }
5870}
5871
5872
5873pub struct SetBypassServiceWorkerParamsBuilder {
5874    bypass: bool,
5875}
5876
5877impl SetBypassServiceWorkerParamsBuilder {
5878    pub fn build(self) -> SetBypassServiceWorkerParams {
5879        SetBypassServiceWorkerParams {
5880            bypass: self.bypass,
5881        }
5882    }
5883}
5884
5885impl SetBypassServiceWorkerParams { pub const METHOD: &'static str = "Network.setBypassServiceWorker"; }
5886
5887impl<'a> crate::CdpCommand<'a> for SetBypassServiceWorkerParams {
5888    const METHOD: &'static str = "Network.setBypassServiceWorker";
5889    type Response = crate::EmptyReturns;
5890}
5891
5892/// Toggles ignoring cache for each request. If 'true', cache will not be used.
5893
5894#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5895#[serde(rename_all = "camelCase")]
5896pub struct SetCacheDisabledParams {
5897    /// Cache disabled state.
5898    cacheDisabled: bool,
5899}
5900
5901impl SetCacheDisabledParams {
5902    pub fn builder(cacheDisabled: bool) -> SetCacheDisabledParamsBuilder {
5903        SetCacheDisabledParamsBuilder {
5904            cacheDisabled: cacheDisabled,
5905        }
5906    }
5907    pub fn cacheDisabled(&self) -> bool { self.cacheDisabled }
5908}
5909
5910
5911pub struct SetCacheDisabledParamsBuilder {
5912    cacheDisabled: bool,
5913}
5914
5915impl SetCacheDisabledParamsBuilder {
5916    pub fn build(self) -> SetCacheDisabledParams {
5917        SetCacheDisabledParams {
5918            cacheDisabled: self.cacheDisabled,
5919        }
5920    }
5921}
5922
5923impl SetCacheDisabledParams { pub const METHOD: &'static str = "Network.setCacheDisabled"; }
5924
5925impl<'a> crate::CdpCommand<'a> for SetCacheDisabledParams {
5926    const METHOD: &'static str = "Network.setCacheDisabled";
5927    type Response = crate::EmptyReturns;
5928}
5929
5930/// Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
5931
5932#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5933#[serde(rename_all = "camelCase")]
5934pub struct SetCookieParams<'a> {
5935    /// Cookie name.
5936    name: Cow<'a, str>,
5937    /// Cookie value.
5938    value: Cow<'a, str>,
5939    /// The request-URI to associate with the setting of the cookie. This value can affect the
5940    /// default domain, path, source port, and source scheme values of the created cookie.
5941    #[serde(skip_serializing_if = "Option::is_none")]
5942    url: Option<Cow<'a, str>>,
5943    /// Cookie domain.
5944    #[serde(skip_serializing_if = "Option::is_none")]
5945    domain: Option<Cow<'a, str>>,
5946    /// Cookie path.
5947    #[serde(skip_serializing_if = "Option::is_none")]
5948    path: Option<Cow<'a, str>>,
5949    /// True if cookie is secure.
5950    #[serde(skip_serializing_if = "Option::is_none")]
5951    secure: Option<bool>,
5952    /// True if cookie is http-only.
5953    #[serde(skip_serializing_if = "Option::is_none")]
5954    httpOnly: Option<bool>,
5955    /// Cookie SameSite type.
5956    #[serde(skip_serializing_if = "Option::is_none")]
5957    sameSite: Option<CookieSameSite>,
5958    /// Cookie expiration date, session cookie if not set
5959    #[serde(skip_serializing_if = "Option::is_none")]
5960    expires: Option<TimeSinceEpoch>,
5961    /// Cookie Priority type.
5962    #[serde(skip_serializing_if = "Option::is_none")]
5963    priority: Option<CookiePriority>,
5964    /// Cookie source scheme type.
5965    #[serde(skip_serializing_if = "Option::is_none")]
5966    sourceScheme: Option<CookieSourceScheme>,
5967    /// Cookie source port. Valid values are {-1, [1, 65535]}, -1 indicates an unspecified port.
5968    /// An unspecified port value allows protocol clients to emulate legacy cookie scope for the port.
5969    /// This is a temporary ability and it will be removed in the future.
5970    #[serde(skip_serializing_if = "Option::is_none")]
5971    sourcePort: Option<i64>,
5972    /// Cookie partition key. If not set, the cookie will be set as not partitioned.
5973    #[serde(skip_serializing_if = "Option::is_none")]
5974    partitionKey: Option<CookiePartitionKey<'a>>,
5975}
5976
5977impl<'a> SetCookieParams<'a> {
5978    pub fn builder(name: impl Into<Cow<'a, str>>, value: impl Into<Cow<'a, str>>) -> SetCookieParamsBuilder<'a> {
5979        SetCookieParamsBuilder {
5980            name: name.into(),
5981            value: value.into(),
5982            url: None,
5983            domain: None,
5984            path: None,
5985            secure: None,
5986            httpOnly: None,
5987            sameSite: None,
5988            expires: None,
5989            priority: None,
5990            sourceScheme: None,
5991            sourcePort: None,
5992            partitionKey: None,
5993        }
5994    }
5995    pub fn name(&self) -> &str { self.name.as_ref() }
5996    pub fn value(&self) -> &str { self.value.as_ref() }
5997    pub fn url(&self) -> Option<&str> { self.url.as_deref() }
5998    pub fn domain(&self) -> Option<&str> { self.domain.as_deref() }
5999    pub fn path(&self) -> Option<&str> { self.path.as_deref() }
6000    pub fn secure(&self) -> Option<bool> { self.secure }
6001    pub fn httpOnly(&self) -> Option<bool> { self.httpOnly }
6002    pub fn sameSite(&self) -> Option<&CookieSameSite> { self.sameSite.as_ref() }
6003    pub fn expires(&self) -> Option<&TimeSinceEpoch> { self.expires.as_ref() }
6004    pub fn priority(&self) -> Option<&CookiePriority> { self.priority.as_ref() }
6005    pub fn sourceScheme(&self) -> Option<&CookieSourceScheme> { self.sourceScheme.as_ref() }
6006    pub fn sourcePort(&self) -> Option<i64> { self.sourcePort }
6007    pub fn partitionKey(&self) -> Option<&CookiePartitionKey<'a>> { self.partitionKey.as_ref() }
6008}
6009
6010
6011pub struct SetCookieParamsBuilder<'a> {
6012    name: Cow<'a, str>,
6013    value: Cow<'a, str>,
6014    url: Option<Cow<'a, str>>,
6015    domain: Option<Cow<'a, str>>,
6016    path: Option<Cow<'a, str>>,
6017    secure: Option<bool>,
6018    httpOnly: Option<bool>,
6019    sameSite: Option<CookieSameSite>,
6020    expires: Option<TimeSinceEpoch>,
6021    priority: Option<CookiePriority>,
6022    sourceScheme: Option<CookieSourceScheme>,
6023    sourcePort: Option<i64>,
6024    partitionKey: Option<CookiePartitionKey<'a>>,
6025}
6026
6027impl<'a> SetCookieParamsBuilder<'a> {
6028    /// The request-URI to associate with the setting of the cookie. This value can affect the
6029    /// default domain, path, source port, and source scheme values of the created cookie.
6030    pub fn url(mut self, url: impl Into<Cow<'a, str>>) -> Self { self.url = Some(url.into()); self }
6031    /// Cookie domain.
6032    pub fn domain(mut self, domain: impl Into<Cow<'a, str>>) -> Self { self.domain = Some(domain.into()); self }
6033    /// Cookie path.
6034    pub fn path(mut self, path: impl Into<Cow<'a, str>>) -> Self { self.path = Some(path.into()); self }
6035    /// True if cookie is secure.
6036    pub fn secure(mut self, secure: bool) -> Self { self.secure = Some(secure); self }
6037    /// True if cookie is http-only.
6038    pub fn httpOnly(mut self, httpOnly: bool) -> Self { self.httpOnly = Some(httpOnly); self }
6039    /// Cookie SameSite type.
6040    pub fn sameSite(mut self, sameSite: CookieSameSite) -> Self { self.sameSite = Some(sameSite); self }
6041    /// Cookie expiration date, session cookie if not set
6042    pub fn expires(mut self, expires: TimeSinceEpoch) -> Self { self.expires = Some(expires); self }
6043    /// Cookie Priority type.
6044    pub fn priority(mut self, priority: CookiePriority) -> Self { self.priority = Some(priority); self }
6045    /// Cookie source scheme type.
6046    pub fn sourceScheme(mut self, sourceScheme: CookieSourceScheme) -> Self { self.sourceScheme = Some(sourceScheme); self }
6047    /// Cookie source port. Valid values are {-1, [1, 65535]}, -1 indicates an unspecified port.
6048    /// An unspecified port value allows protocol clients to emulate legacy cookie scope for the port.
6049    /// This is a temporary ability and it will be removed in the future.
6050    pub fn sourcePort(mut self, sourcePort: i64) -> Self { self.sourcePort = Some(sourcePort); self }
6051    /// Cookie partition key. If not set, the cookie will be set as not partitioned.
6052    pub fn partitionKey(mut self, partitionKey: CookiePartitionKey<'a>) -> Self { self.partitionKey = Some(partitionKey); self }
6053    pub fn build(self) -> SetCookieParams<'a> {
6054        SetCookieParams {
6055            name: self.name,
6056            value: self.value,
6057            url: self.url,
6058            domain: self.domain,
6059            path: self.path,
6060            secure: self.secure,
6061            httpOnly: self.httpOnly,
6062            sameSite: self.sameSite,
6063            expires: self.expires,
6064            priority: self.priority,
6065            sourceScheme: self.sourceScheme,
6066            sourcePort: self.sourcePort,
6067            partitionKey: self.partitionKey,
6068        }
6069    }
6070}
6071
6072/// Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
6073
6074#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6075#[serde(rename_all = "camelCase")]
6076pub struct SetCookieReturns {
6077    /// Always set to true. If an error occurs, the response indicates protocol error.
6078    success: bool,
6079}
6080
6081impl SetCookieReturns {
6082    pub fn builder(success: bool) -> SetCookieReturnsBuilder {
6083        SetCookieReturnsBuilder {
6084            success: success,
6085        }
6086    }
6087    pub fn success(&self) -> bool { self.success }
6088}
6089
6090
6091pub struct SetCookieReturnsBuilder {
6092    success: bool,
6093}
6094
6095impl SetCookieReturnsBuilder {
6096    pub fn build(self) -> SetCookieReturns {
6097        SetCookieReturns {
6098            success: self.success,
6099        }
6100    }
6101}
6102
6103impl<'a> SetCookieParams<'a> { pub const METHOD: &'static str = "Network.setCookie"; }
6104
6105impl<'a> crate::CdpCommand<'a> for SetCookieParams<'a> {
6106    const METHOD: &'static str = "Network.setCookie";
6107    type Response = SetCookieReturns;
6108}
6109
6110/// Sets given cookies.
6111
6112#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6113#[serde(rename_all = "camelCase")]
6114pub struct SetCookiesParams<'a> {
6115    /// Cookies to be set.
6116    cookies: Vec<CookieParam<'a>>,
6117}
6118
6119impl<'a> SetCookiesParams<'a> {
6120    pub fn builder(cookies: Vec<CookieParam<'a>>) -> SetCookiesParamsBuilder<'a> {
6121        SetCookiesParamsBuilder {
6122            cookies: cookies,
6123        }
6124    }
6125    pub fn cookies(&self) -> &[CookieParam<'a>] { &self.cookies }
6126}
6127
6128
6129pub struct SetCookiesParamsBuilder<'a> {
6130    cookies: Vec<CookieParam<'a>>,
6131}
6132
6133impl<'a> SetCookiesParamsBuilder<'a> {
6134    pub fn build(self) -> SetCookiesParams<'a> {
6135        SetCookiesParams {
6136            cookies: self.cookies,
6137        }
6138    }
6139}
6140
6141impl<'a> SetCookiesParams<'a> { pub const METHOD: &'static str = "Network.setCookies"; }
6142
6143impl<'a> crate::CdpCommand<'a> for SetCookiesParams<'a> {
6144    const METHOD: &'static str = "Network.setCookies";
6145    type Response = crate::EmptyReturns;
6146}
6147
6148/// Specifies whether to always send extra HTTP headers with the requests from this page.
6149
6150#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6151#[serde(rename_all = "camelCase")]
6152pub struct SetExtraHTTPHeadersParams {
6153    /// Map with extra HTTP headers.
6154    headers: Headers,
6155}
6156
6157impl SetExtraHTTPHeadersParams {
6158    pub fn builder(headers: Headers) -> SetExtraHTTPHeadersParamsBuilder {
6159        SetExtraHTTPHeadersParamsBuilder {
6160            headers: headers,
6161        }
6162    }
6163    pub fn headers(&self) -> &Headers { &self.headers }
6164}
6165
6166
6167pub struct SetExtraHTTPHeadersParamsBuilder {
6168    headers: Headers,
6169}
6170
6171impl SetExtraHTTPHeadersParamsBuilder {
6172    pub fn build(self) -> SetExtraHTTPHeadersParams {
6173        SetExtraHTTPHeadersParams {
6174            headers: self.headers,
6175        }
6176    }
6177}
6178
6179impl SetExtraHTTPHeadersParams { pub const METHOD: &'static str = "Network.setExtraHTTPHeaders"; }
6180
6181impl<'a> crate::CdpCommand<'a> for SetExtraHTTPHeadersParams {
6182    const METHOD: &'static str = "Network.setExtraHTTPHeaders";
6183    type Response = crate::EmptyReturns;
6184}
6185
6186/// Specifies whether to attach a page script stack id in requests
6187
6188#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6189#[serde(rename_all = "camelCase")]
6190pub struct SetAttachDebugStackParams {
6191    /// Whether to attach a page script stack for debugging purpose.
6192    enabled: bool,
6193}
6194
6195impl SetAttachDebugStackParams {
6196    pub fn builder(enabled: bool) -> SetAttachDebugStackParamsBuilder {
6197        SetAttachDebugStackParamsBuilder {
6198            enabled: enabled,
6199        }
6200    }
6201    pub fn enabled(&self) -> bool { self.enabled }
6202}
6203
6204
6205pub struct SetAttachDebugStackParamsBuilder {
6206    enabled: bool,
6207}
6208
6209impl SetAttachDebugStackParamsBuilder {
6210    pub fn build(self) -> SetAttachDebugStackParams {
6211        SetAttachDebugStackParams {
6212            enabled: self.enabled,
6213        }
6214    }
6215}
6216
6217impl SetAttachDebugStackParams { pub const METHOD: &'static str = "Network.setAttachDebugStack"; }
6218
6219impl<'a> crate::CdpCommand<'a> for SetAttachDebugStackParams {
6220    const METHOD: &'static str = "Network.setAttachDebugStack";
6221    type Response = crate::EmptyReturns;
6222}
6223
6224/// Sets the requests to intercept that match the provided patterns and optionally resource types.
6225/// Deprecated, please use Fetch.enable instead.
6226
6227#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6228#[serde(rename_all = "camelCase")]
6229pub struct SetRequestInterceptionParams<'a> {
6230    /// Requests matching any of these patterns will be forwarded and wait for the corresponding
6231    /// continueInterceptedRequest call.
6232    patterns: Vec<RequestPattern<'a>>,
6233}
6234
6235impl<'a> SetRequestInterceptionParams<'a> {
6236    pub fn builder(patterns: Vec<RequestPattern<'a>>) -> SetRequestInterceptionParamsBuilder<'a> {
6237        SetRequestInterceptionParamsBuilder {
6238            patterns: patterns,
6239        }
6240    }
6241    pub fn patterns(&self) -> &[RequestPattern<'a>] { &self.patterns }
6242}
6243
6244
6245pub struct SetRequestInterceptionParamsBuilder<'a> {
6246    patterns: Vec<RequestPattern<'a>>,
6247}
6248
6249impl<'a> SetRequestInterceptionParamsBuilder<'a> {
6250    pub fn build(self) -> SetRequestInterceptionParams<'a> {
6251        SetRequestInterceptionParams {
6252            patterns: self.patterns,
6253        }
6254    }
6255}
6256
6257impl<'a> SetRequestInterceptionParams<'a> { pub const METHOD: &'static str = "Network.setRequestInterception"; }
6258
6259impl<'a> crate::CdpCommand<'a> for SetRequestInterceptionParams<'a> {
6260    const METHOD: &'static str = "Network.setRequestInterception";
6261    type Response = crate::EmptyReturns;
6262}
6263
6264/// Allows overriding user agent with the given string.
6265
6266#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6267#[serde(rename_all = "camelCase")]
6268pub struct SetUserAgentOverrideParams<'a> {
6269    /// User agent to use.
6270    userAgent: Cow<'a, str>,
6271    /// Browser language to emulate.
6272    #[serde(skip_serializing_if = "Option::is_none")]
6273    acceptLanguage: Option<Cow<'a, str>>,
6274    /// The platform navigator.platform should return.
6275    #[serde(skip_serializing_if = "Option::is_none")]
6276    platform: Option<Cow<'a, str>>,
6277    /// To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
6278    #[serde(skip_serializing_if = "Option::is_none")]
6279    userAgentMetadata: Option<crate::emulation::UserAgentMetadata<'a>>,
6280}
6281
6282impl<'a> SetUserAgentOverrideParams<'a> {
6283    pub fn builder(userAgent: impl Into<Cow<'a, str>>) -> SetUserAgentOverrideParamsBuilder<'a> {
6284        SetUserAgentOverrideParamsBuilder {
6285            userAgent: userAgent.into(),
6286            acceptLanguage: None,
6287            platform: None,
6288            userAgentMetadata: None,
6289        }
6290    }
6291    pub fn userAgent(&self) -> &str { self.userAgent.as_ref() }
6292    pub fn acceptLanguage(&self) -> Option<&str> { self.acceptLanguage.as_deref() }
6293    pub fn platform(&self) -> Option<&str> { self.platform.as_deref() }
6294    pub fn userAgentMetadata(&self) -> Option<&crate::emulation::UserAgentMetadata<'a>> { self.userAgentMetadata.as_ref() }
6295}
6296
6297
6298pub struct SetUserAgentOverrideParamsBuilder<'a> {
6299    userAgent: Cow<'a, str>,
6300    acceptLanguage: Option<Cow<'a, str>>,
6301    platform: Option<Cow<'a, str>>,
6302    userAgentMetadata: Option<crate::emulation::UserAgentMetadata<'a>>,
6303}
6304
6305impl<'a> SetUserAgentOverrideParamsBuilder<'a> {
6306    /// Browser language to emulate.
6307    pub fn acceptLanguage(mut self, acceptLanguage: impl Into<Cow<'a, str>>) -> Self { self.acceptLanguage = Some(acceptLanguage.into()); self }
6308    /// The platform navigator.platform should return.
6309    pub fn platform(mut self, platform: impl Into<Cow<'a, str>>) -> Self { self.platform = Some(platform.into()); self }
6310    /// To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
6311    pub fn userAgentMetadata(mut self, userAgentMetadata: crate::emulation::UserAgentMetadata<'a>) -> Self { self.userAgentMetadata = Some(userAgentMetadata); self }
6312    pub fn build(self) -> SetUserAgentOverrideParams<'a> {
6313        SetUserAgentOverrideParams {
6314            userAgent: self.userAgent,
6315            acceptLanguage: self.acceptLanguage,
6316            platform: self.platform,
6317            userAgentMetadata: self.userAgentMetadata,
6318        }
6319    }
6320}
6321
6322impl<'a> SetUserAgentOverrideParams<'a> { pub const METHOD: &'static str = "Network.setUserAgentOverride"; }
6323
6324impl<'a> crate::CdpCommand<'a> for SetUserAgentOverrideParams<'a> {
6325    const METHOD: &'static str = "Network.setUserAgentOverride";
6326    type Response = crate::EmptyReturns;
6327}
6328
6329/// Enables streaming of the response for the given requestId.
6330/// If enabled, the dataReceived event contains the data that was received during streaming.
6331
6332#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6333#[serde(rename_all = "camelCase")]
6334pub struct StreamResourceContentParams<'a> {
6335    /// Identifier of the request to stream.
6336    requestId: RequestId<'a>,
6337}
6338
6339impl<'a> StreamResourceContentParams<'a> {
6340    pub fn builder(requestId: RequestId<'a>) -> StreamResourceContentParamsBuilder<'a> {
6341        StreamResourceContentParamsBuilder {
6342            requestId: requestId,
6343        }
6344    }
6345    pub fn requestId(&self) -> &RequestId<'a> { &self.requestId }
6346}
6347
6348
6349pub struct StreamResourceContentParamsBuilder<'a> {
6350    requestId: RequestId<'a>,
6351}
6352
6353impl<'a> StreamResourceContentParamsBuilder<'a> {
6354    pub fn build(self) -> StreamResourceContentParams<'a> {
6355        StreamResourceContentParams {
6356            requestId: self.requestId,
6357        }
6358    }
6359}
6360
6361/// Enables streaming of the response for the given requestId.
6362/// If enabled, the dataReceived event contains the data that was received during streaming.
6363
6364#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6365#[serde(rename_all = "camelCase")]
6366pub struct StreamResourceContentReturns<'a> {
6367    /// Data that has been buffered until streaming is enabled. (Encoded as a base64 string when passed over JSON)
6368    bufferedData: Cow<'a, str>,
6369}
6370
6371impl<'a> StreamResourceContentReturns<'a> {
6372    pub fn builder(bufferedData: impl Into<Cow<'a, str>>) -> StreamResourceContentReturnsBuilder<'a> {
6373        StreamResourceContentReturnsBuilder {
6374            bufferedData: bufferedData.into(),
6375        }
6376    }
6377    pub fn bufferedData(&self) -> &str { self.bufferedData.as_ref() }
6378}
6379
6380
6381pub struct StreamResourceContentReturnsBuilder<'a> {
6382    bufferedData: Cow<'a, str>,
6383}
6384
6385impl<'a> StreamResourceContentReturnsBuilder<'a> {
6386    pub fn build(self) -> StreamResourceContentReturns<'a> {
6387        StreamResourceContentReturns {
6388            bufferedData: self.bufferedData,
6389        }
6390    }
6391}
6392
6393impl<'a> StreamResourceContentParams<'a> { pub const METHOD: &'static str = "Network.streamResourceContent"; }
6394
6395impl<'a> crate::CdpCommand<'a> for StreamResourceContentParams<'a> {
6396    const METHOD: &'static str = "Network.streamResourceContent";
6397    type Response = StreamResourceContentReturns<'a>;
6398}
6399
6400/// Returns information about the COEP/COOP isolation status.
6401
6402#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6403#[serde(rename_all = "camelCase")]
6404pub struct GetSecurityIsolationStatusParams<'a> {
6405    /// If no frameId is provided, the status of the target is provided.
6406    #[serde(skip_serializing_if = "Option::is_none")]
6407    frameId: Option<crate::page::FrameId<'a>>,
6408}
6409
6410impl<'a> GetSecurityIsolationStatusParams<'a> {
6411    pub fn builder() -> GetSecurityIsolationStatusParamsBuilder<'a> {
6412        GetSecurityIsolationStatusParamsBuilder {
6413            frameId: None,
6414        }
6415    }
6416    pub fn frameId(&self) -> Option<&crate::page::FrameId<'a>> { self.frameId.as_ref() }
6417}
6418
6419#[derive(Default)]
6420pub struct GetSecurityIsolationStatusParamsBuilder<'a> {
6421    frameId: Option<crate::page::FrameId<'a>>,
6422}
6423
6424impl<'a> GetSecurityIsolationStatusParamsBuilder<'a> {
6425    /// If no frameId is provided, the status of the target is provided.
6426    pub fn frameId(mut self, frameId: crate::page::FrameId<'a>) -> Self { self.frameId = Some(frameId); self }
6427    pub fn build(self) -> GetSecurityIsolationStatusParams<'a> {
6428        GetSecurityIsolationStatusParams {
6429            frameId: self.frameId,
6430        }
6431    }
6432}
6433
6434/// Returns information about the COEP/COOP isolation status.
6435
6436#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6437#[serde(rename_all = "camelCase")]
6438pub struct GetSecurityIsolationStatusReturns<'a> {
6439    status: SecurityIsolationStatus<'a>,
6440}
6441
6442impl<'a> GetSecurityIsolationStatusReturns<'a> {
6443    pub fn builder(status: SecurityIsolationStatus<'a>) -> GetSecurityIsolationStatusReturnsBuilder<'a> {
6444        GetSecurityIsolationStatusReturnsBuilder {
6445            status: status,
6446        }
6447    }
6448    pub fn status(&self) -> &SecurityIsolationStatus<'a> { &self.status }
6449}
6450
6451
6452pub struct GetSecurityIsolationStatusReturnsBuilder<'a> {
6453    status: SecurityIsolationStatus<'a>,
6454}
6455
6456impl<'a> GetSecurityIsolationStatusReturnsBuilder<'a> {
6457    pub fn build(self) -> GetSecurityIsolationStatusReturns<'a> {
6458        GetSecurityIsolationStatusReturns {
6459            status: self.status,
6460        }
6461    }
6462}
6463
6464impl<'a> GetSecurityIsolationStatusParams<'a> { pub const METHOD: &'static str = "Network.getSecurityIsolationStatus"; }
6465
6466impl<'a> crate::CdpCommand<'a> for GetSecurityIsolationStatusParams<'a> {
6467    const METHOD: &'static str = "Network.getSecurityIsolationStatus";
6468    type Response = GetSecurityIsolationStatusReturns<'a>;
6469}
6470
6471/// Enables tracking for the Reporting API, events generated by the Reporting API will now be delivered to the client.
6472/// Enabling triggers 'reportingApiReportAdded' for all existing reports.
6473
6474#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6475#[serde(rename_all = "camelCase")]
6476pub struct EnableReportingApiParams {
6477    /// Whether to enable or disable events for the Reporting API
6478    enable: bool,
6479}
6480
6481impl EnableReportingApiParams {
6482    pub fn builder(enable: bool) -> EnableReportingApiParamsBuilder {
6483        EnableReportingApiParamsBuilder {
6484            enable: enable,
6485        }
6486    }
6487    pub fn enable(&self) -> bool { self.enable }
6488}
6489
6490
6491pub struct EnableReportingApiParamsBuilder {
6492    enable: bool,
6493}
6494
6495impl EnableReportingApiParamsBuilder {
6496    pub fn build(self) -> EnableReportingApiParams {
6497        EnableReportingApiParams {
6498            enable: self.enable,
6499        }
6500    }
6501}
6502
6503impl EnableReportingApiParams { pub const METHOD: &'static str = "Network.enableReportingApi"; }
6504
6505impl<'a> crate::CdpCommand<'a> for EnableReportingApiParams {
6506    const METHOD: &'static str = "Network.enableReportingApi";
6507    type Response = crate::EmptyReturns;
6508}
6509
6510/// Sets up tracking device bound sessions and fetching of initial set of sessions.
6511
6512#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6513#[serde(rename_all = "camelCase")]
6514pub struct EnableDeviceBoundSessionsParams {
6515    /// Whether to enable or disable events.
6516    enable: bool,
6517}
6518
6519impl EnableDeviceBoundSessionsParams {
6520    pub fn builder(enable: bool) -> EnableDeviceBoundSessionsParamsBuilder {
6521        EnableDeviceBoundSessionsParamsBuilder {
6522            enable: enable,
6523        }
6524    }
6525    pub fn enable(&self) -> bool { self.enable }
6526}
6527
6528
6529pub struct EnableDeviceBoundSessionsParamsBuilder {
6530    enable: bool,
6531}
6532
6533impl EnableDeviceBoundSessionsParamsBuilder {
6534    pub fn build(self) -> EnableDeviceBoundSessionsParams {
6535        EnableDeviceBoundSessionsParams {
6536            enable: self.enable,
6537        }
6538    }
6539}
6540
6541impl EnableDeviceBoundSessionsParams { pub const METHOD: &'static str = "Network.enableDeviceBoundSessions"; }
6542
6543impl<'a> crate::CdpCommand<'a> for EnableDeviceBoundSessionsParams {
6544    const METHOD: &'static str = "Network.enableDeviceBoundSessions";
6545    type Response = crate::EmptyReturns;
6546}
6547
6548/// Deletes a device bound session.
6549
6550#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6551#[serde(rename_all = "camelCase")]
6552pub struct DeleteDeviceBoundSessionParams<'a> {
6553    key: DeviceBoundSessionKey<'a>,
6554}
6555
6556impl<'a> DeleteDeviceBoundSessionParams<'a> {
6557    pub fn builder(key: DeviceBoundSessionKey<'a>) -> DeleteDeviceBoundSessionParamsBuilder<'a> {
6558        DeleteDeviceBoundSessionParamsBuilder {
6559            key: key,
6560        }
6561    }
6562    pub fn key(&self) -> &DeviceBoundSessionKey<'a> { &self.key }
6563}
6564
6565
6566pub struct DeleteDeviceBoundSessionParamsBuilder<'a> {
6567    key: DeviceBoundSessionKey<'a>,
6568}
6569
6570impl<'a> DeleteDeviceBoundSessionParamsBuilder<'a> {
6571    pub fn build(self) -> DeleteDeviceBoundSessionParams<'a> {
6572        DeleteDeviceBoundSessionParams {
6573            key: self.key,
6574        }
6575    }
6576}
6577
6578impl<'a> DeleteDeviceBoundSessionParams<'a> { pub const METHOD: &'static str = "Network.deleteDeviceBoundSession"; }
6579
6580impl<'a> crate::CdpCommand<'a> for DeleteDeviceBoundSessionParams<'a> {
6581    const METHOD: &'static str = "Network.deleteDeviceBoundSession";
6582    type Response = crate::EmptyReturns;
6583}
6584
6585/// Fetches the schemeful site for a specific origin.
6586
6587#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6588#[serde(rename_all = "camelCase")]
6589pub struct FetchSchemefulSiteParams<'a> {
6590    /// The URL origin.
6591    origin: Cow<'a, str>,
6592}
6593
6594impl<'a> FetchSchemefulSiteParams<'a> {
6595    pub fn builder(origin: impl Into<Cow<'a, str>>) -> FetchSchemefulSiteParamsBuilder<'a> {
6596        FetchSchemefulSiteParamsBuilder {
6597            origin: origin.into(),
6598        }
6599    }
6600    pub fn origin(&self) -> &str { self.origin.as_ref() }
6601}
6602
6603
6604pub struct FetchSchemefulSiteParamsBuilder<'a> {
6605    origin: Cow<'a, str>,
6606}
6607
6608impl<'a> FetchSchemefulSiteParamsBuilder<'a> {
6609    pub fn build(self) -> FetchSchemefulSiteParams<'a> {
6610        FetchSchemefulSiteParams {
6611            origin: self.origin,
6612        }
6613    }
6614}
6615
6616/// Fetches the schemeful site for a specific origin.
6617
6618#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6619#[serde(rename_all = "camelCase")]
6620pub struct FetchSchemefulSiteReturns<'a> {
6621    /// The corresponding schemeful site.
6622    schemefulSite: Cow<'a, str>,
6623}
6624
6625impl<'a> FetchSchemefulSiteReturns<'a> {
6626    pub fn builder(schemefulSite: impl Into<Cow<'a, str>>) -> FetchSchemefulSiteReturnsBuilder<'a> {
6627        FetchSchemefulSiteReturnsBuilder {
6628            schemefulSite: schemefulSite.into(),
6629        }
6630    }
6631    pub fn schemefulSite(&self) -> &str { self.schemefulSite.as_ref() }
6632}
6633
6634
6635pub struct FetchSchemefulSiteReturnsBuilder<'a> {
6636    schemefulSite: Cow<'a, str>,
6637}
6638
6639impl<'a> FetchSchemefulSiteReturnsBuilder<'a> {
6640    pub fn build(self) -> FetchSchemefulSiteReturns<'a> {
6641        FetchSchemefulSiteReturns {
6642            schemefulSite: self.schemefulSite,
6643        }
6644    }
6645}
6646
6647impl<'a> FetchSchemefulSiteParams<'a> { pub const METHOD: &'static str = "Network.fetchSchemefulSite"; }
6648
6649impl<'a> crate::CdpCommand<'a> for FetchSchemefulSiteParams<'a> {
6650    const METHOD: &'static str = "Network.fetchSchemefulSite";
6651    type Response = FetchSchemefulSiteReturns<'a>;
6652}
6653
6654/// Fetches the resource and returns the content.
6655
6656#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6657#[serde(rename_all = "camelCase")]
6658pub struct LoadNetworkResourceParams<'a> {
6659    /// Frame id to get the resource for. Mandatory for frame targets, and
6660    /// should be omitted for worker targets.
6661    #[serde(skip_serializing_if = "Option::is_none")]
6662    frameId: Option<crate::page::FrameId<'a>>,
6663    /// URL of the resource to get content for.
6664    url: Cow<'a, str>,
6665    /// Options for the request.
6666    options: LoadNetworkResourceOptions,
6667}
6668
6669impl<'a> LoadNetworkResourceParams<'a> {
6670    pub fn builder(url: impl Into<Cow<'a, str>>, options: LoadNetworkResourceOptions) -> LoadNetworkResourceParamsBuilder<'a> {
6671        LoadNetworkResourceParamsBuilder {
6672            frameId: None,
6673            url: url.into(),
6674            options: options,
6675        }
6676    }
6677    pub fn frameId(&self) -> Option<&crate::page::FrameId<'a>> { self.frameId.as_ref() }
6678    pub fn url(&self) -> &str { self.url.as_ref() }
6679    pub fn options(&self) -> &LoadNetworkResourceOptions { &self.options }
6680}
6681
6682
6683pub struct LoadNetworkResourceParamsBuilder<'a> {
6684    frameId: Option<crate::page::FrameId<'a>>,
6685    url: Cow<'a, str>,
6686    options: LoadNetworkResourceOptions,
6687}
6688
6689impl<'a> LoadNetworkResourceParamsBuilder<'a> {
6690    /// Frame id to get the resource for. Mandatory for frame targets, and
6691    /// should be omitted for worker targets.
6692    pub fn frameId(mut self, frameId: crate::page::FrameId<'a>) -> Self { self.frameId = Some(frameId); self }
6693    pub fn build(self) -> LoadNetworkResourceParams<'a> {
6694        LoadNetworkResourceParams {
6695            frameId: self.frameId,
6696            url: self.url,
6697            options: self.options,
6698        }
6699    }
6700}
6701
6702/// Fetches the resource and returns the content.
6703
6704#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6705#[serde(rename_all = "camelCase")]
6706pub struct LoadNetworkResourceReturns<'a> {
6707    resource: LoadNetworkResourcePageResult<'a>,
6708}
6709
6710impl<'a> LoadNetworkResourceReturns<'a> {
6711    pub fn builder(resource: LoadNetworkResourcePageResult<'a>) -> LoadNetworkResourceReturnsBuilder<'a> {
6712        LoadNetworkResourceReturnsBuilder {
6713            resource: resource,
6714        }
6715    }
6716    pub fn resource(&self) -> &LoadNetworkResourcePageResult<'a> { &self.resource }
6717}
6718
6719
6720pub struct LoadNetworkResourceReturnsBuilder<'a> {
6721    resource: LoadNetworkResourcePageResult<'a>,
6722}
6723
6724impl<'a> LoadNetworkResourceReturnsBuilder<'a> {
6725    pub fn build(self) -> LoadNetworkResourceReturns<'a> {
6726        LoadNetworkResourceReturns {
6727            resource: self.resource,
6728        }
6729    }
6730}
6731
6732impl<'a> LoadNetworkResourceParams<'a> { pub const METHOD: &'static str = "Network.loadNetworkResource"; }
6733
6734impl<'a> crate::CdpCommand<'a> for LoadNetworkResourceParams<'a> {
6735    const METHOD: &'static str = "Network.loadNetworkResource";
6736    type Response = LoadNetworkResourceReturns<'a>;
6737}
6738
6739/// Sets Controls for third-party cookie access
6740/// Page reload is required before the new cookie behavior will be observed
6741
6742#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6743#[serde(rename_all = "camelCase")]
6744pub struct SetCookieControlsParams {
6745    /// Whether 3pc restriction is enabled.
6746    enableThirdPartyCookieRestriction: bool,
6747}
6748
6749impl SetCookieControlsParams {
6750    pub fn builder(enableThirdPartyCookieRestriction: bool) -> SetCookieControlsParamsBuilder {
6751        SetCookieControlsParamsBuilder {
6752            enableThirdPartyCookieRestriction: enableThirdPartyCookieRestriction,
6753        }
6754    }
6755    pub fn enableThirdPartyCookieRestriction(&self) -> bool { self.enableThirdPartyCookieRestriction }
6756}
6757
6758
6759pub struct SetCookieControlsParamsBuilder {
6760    enableThirdPartyCookieRestriction: bool,
6761}
6762
6763impl SetCookieControlsParamsBuilder {
6764    pub fn build(self) -> SetCookieControlsParams {
6765        SetCookieControlsParams {
6766            enableThirdPartyCookieRestriction: self.enableThirdPartyCookieRestriction,
6767        }
6768    }
6769}
6770
6771impl SetCookieControlsParams { pub const METHOD: &'static str = "Network.setCookieControls"; }
6772
6773impl<'a> crate::CdpCommand<'a> for SetCookieControlsParams {
6774    const METHOD: &'static str = "Network.setCookieControls";
6775    type Response = crate::EmptyReturns;
6776}