Skip to main content

rustenium_cdp_definitions/browser_protocol/network/
command_builders.rs

1use super::commands::*;
2impl SetAcceptedEncodings {
3    pub fn builder() -> SetAcceptedEncodingsBuilder {
4        <SetAcceptedEncodingsBuilder as Default>::default()
5    }
6}
7#[derive(Default, Clone)]
8pub struct SetAcceptedEncodingsBuilder {
9    encodings: Option<Vec<super::types::ContentEncoding>>,
10}
11impl SetAcceptedEncodingsBuilder {
12    pub fn encoding(mut self, encoding: impl Into<super::types::ContentEncoding>) -> Self {
13        let v = self.encodings.get_or_insert(Vec::new());
14        v.push(encoding.into());
15        self
16    }
17    pub fn encodings<I, S>(mut self, encodings: I) -> Self
18    where
19        I: IntoIterator<Item = S>,
20        S: Into<super::types::ContentEncoding>,
21    {
22        let v = self.encodings.get_or_insert(Vec::new());
23        for val in encodings {
24            v.push(val.into());
25        }
26        self
27    }
28    pub fn build(self) -> Result<SetAcceptedEncodings, String> {
29        Ok(SetAcceptedEncodings {
30            method: SetAcceptedEncodingsMethod::SetAcceptedEncodings,
31            params: SetAcceptedEncodingsParams {
32                encodings: self.encodings.ok_or_else(|| {
33                    format!("Field `{}` is mandatory.", std::stringify!(encodings))
34                })?,
35            },
36        })
37    }
38}
39#[derive(Debug, Clone, Default)]
40pub struct ClearAcceptedEncodingsOverrideBuilder;
41impl ClearAcceptedEncodingsOverrideBuilder {
42    pub fn new() -> Self {
43        Self
44    }
45    pub fn build(self) -> ClearAcceptedEncodingsOverride {
46        ClearAcceptedEncodingsOverride {
47            method: ClearAcceptedEncodingsOverrideMethod::ClearAcceptedEncodingsOverride,
48            params: ClearAcceptedEncodingsOverrideParams {},
49        }
50    }
51}
52impl ClearAcceptedEncodingsOverride {
53    pub fn builder() -> ClearAcceptedEncodingsOverrideBuilder {
54        ClearAcceptedEncodingsOverrideBuilder
55    }
56}
57#[derive(Debug, Clone, Default)]
58pub struct ClearBrowserCacheBuilder;
59impl ClearBrowserCacheBuilder {
60    pub fn new() -> Self {
61        Self
62    }
63    pub fn build(self) -> ClearBrowserCache {
64        ClearBrowserCache {
65            method: ClearBrowserCacheMethod::ClearBrowserCache,
66            params: ClearBrowserCacheParams {},
67        }
68    }
69}
70impl ClearBrowserCache {
71    pub fn builder() -> ClearBrowserCacheBuilder {
72        ClearBrowserCacheBuilder
73    }
74}
75#[derive(Debug, Clone, Default)]
76pub struct ClearBrowserCookiesBuilder;
77impl ClearBrowserCookiesBuilder {
78    pub fn new() -> Self {
79        Self
80    }
81    pub fn build(self) -> ClearBrowserCookies {
82        ClearBrowserCookies {
83            method: ClearBrowserCookiesMethod::ClearBrowserCookies,
84            params: ClearBrowserCookiesParams {},
85        }
86    }
87}
88impl ClearBrowserCookies {
89    pub fn builder() -> ClearBrowserCookiesBuilder {
90        ClearBrowserCookiesBuilder
91    }
92}
93impl DeleteCookies {
94    pub fn builder() -> DeleteCookiesBuilder {
95        <DeleteCookiesBuilder as Default>::default()
96    }
97}
98#[derive(Default, Clone)]
99pub struct DeleteCookiesBuilder {
100    name: Option<String>,
101    url: Option<String>,
102    domain: Option<String>,
103    path: Option<String>,
104    partition_key: Option<super::types::CookiePartitionKey>,
105}
106impl DeleteCookiesBuilder {
107    pub fn name(mut self, name: impl Into<String>) -> Self {
108        self.name = Some(name.into());
109        self
110    }
111    pub fn url(mut self, url: impl Into<String>) -> Self {
112        self.url = Some(url.into());
113        self
114    }
115    pub fn domain(mut self, domain: impl Into<String>) -> Self {
116        self.domain = Some(domain.into());
117        self
118    }
119    pub fn path(mut self, path: impl Into<String>) -> Self {
120        self.path = Some(path.into());
121        self
122    }
123    pub fn partition_key(
124        mut self,
125        partition_key: impl Into<super::types::CookiePartitionKey>,
126    ) -> Self {
127        self.partition_key = Some(partition_key.into());
128        self
129    }
130    pub fn build(self) -> Result<DeleteCookies, String> {
131        Ok(DeleteCookies {
132            method: DeleteCookiesMethod::DeleteCookies,
133            params: DeleteCookiesParams {
134                name: self
135                    .name
136                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(name)))?,
137                url: self.url,
138                domain: self.domain,
139                path: self.path,
140                partition_key: self.partition_key,
141            },
142        })
143    }
144}
145#[derive(Debug, Clone, Default)]
146pub struct DisableBuilder;
147impl DisableBuilder {
148    pub fn new() -> Self {
149        Self
150    }
151    pub fn build(self) -> Disable {
152        Disable {
153            method: DisableMethod::Disable,
154            params: DisableParams {},
155        }
156    }
157}
158impl Disable {
159    pub fn builder() -> DisableBuilder {
160        DisableBuilder
161    }
162}
163impl EmulateNetworkConditionsByRule {
164    pub fn builder() -> EmulateNetworkConditionsByRuleBuilder {
165        <EmulateNetworkConditionsByRuleBuilder as Default>::default()
166    }
167}
168#[derive(Default, Clone)]
169pub struct EmulateNetworkConditionsByRuleBuilder {
170    offline: Option<bool>,
171    matched_network_conditions: Option<Vec<super::types::NetworkConditions>>,
172}
173impl EmulateNetworkConditionsByRuleBuilder {
174    pub fn offline(mut self, offline: impl Into<bool>) -> Self {
175        self.offline = Some(offline.into());
176        self
177    }
178    pub fn matched_network_condition(
179        mut self,
180        matched_network_condition: impl Into<super::types::NetworkConditions>,
181    ) -> Self {
182        let v = self.matched_network_conditions.get_or_insert(Vec::new());
183        v.push(matched_network_condition.into());
184        self
185    }
186    pub fn matched_network_conditions<I, S>(mut self, matched_network_conditions: I) -> Self
187    where
188        I: IntoIterator<Item = S>,
189        S: Into<super::types::NetworkConditions>,
190    {
191        let v = self.matched_network_conditions.get_or_insert(Vec::new());
192        for val in matched_network_conditions {
193            v.push(val.into());
194        }
195        self
196    }
197    pub fn build(self) -> Result<EmulateNetworkConditionsByRule, String> {
198        Ok(EmulateNetworkConditionsByRule {
199            method: EmulateNetworkConditionsByRuleMethod::EmulateNetworkConditionsByRule,
200            params: EmulateNetworkConditionsByRuleParams {
201                offline: self
202                    .offline
203                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(offline)))?,
204                matched_network_conditions: self.matched_network_conditions.ok_or_else(|| {
205                    format!(
206                        "Field `{}` is mandatory.",
207                        std::stringify!(matched_network_conditions)
208                    )
209                })?,
210            },
211        })
212    }
213}
214impl OverrideNetworkState {
215    pub fn builder() -> OverrideNetworkStateBuilder {
216        <OverrideNetworkStateBuilder as Default>::default()
217    }
218}
219#[derive(Default, Clone)]
220pub struct OverrideNetworkStateBuilder {
221    offline: Option<bool>,
222    latency: Option<f64>,
223    download_throughput: Option<f64>,
224    upload_throughput: Option<f64>,
225    connection_type: Option<super::types::ConnectionType>,
226}
227impl OverrideNetworkStateBuilder {
228    pub fn offline(mut self, offline: impl Into<bool>) -> Self {
229        self.offline = Some(offline.into());
230        self
231    }
232    pub fn latency(mut self, latency: impl Into<f64>) -> Self {
233        self.latency = Some(latency.into());
234        self
235    }
236    pub fn download_throughput(mut self, download_throughput: impl Into<f64>) -> Self {
237        self.download_throughput = Some(download_throughput.into());
238        self
239    }
240    pub fn upload_throughput(mut self, upload_throughput: impl Into<f64>) -> Self {
241        self.upload_throughput = Some(upload_throughput.into());
242        self
243    }
244    pub fn connection_type(
245        mut self,
246        connection_type: impl Into<super::types::ConnectionType>,
247    ) -> Self {
248        self.connection_type = Some(connection_type.into());
249        self
250    }
251    pub fn build(self) -> Result<OverrideNetworkState, String> {
252        Ok(OverrideNetworkState {
253            method: OverrideNetworkStateMethod::OverrideNetworkState,
254            params: OverrideNetworkStateParams {
255                offline: self
256                    .offline
257                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(offline)))?,
258                latency: self
259                    .latency
260                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(latency)))?,
261                download_throughput: self.download_throughput.ok_or_else(|| {
262                    format!(
263                        "Field `{}` is mandatory.",
264                        std::stringify!(download_throughput)
265                    )
266                })?,
267                upload_throughput: self.upload_throughput.ok_or_else(|| {
268                    format!(
269                        "Field `{}` is mandatory.",
270                        std::stringify!(upload_throughput)
271                    )
272                })?,
273                connection_type: self.connection_type,
274            },
275        })
276    }
277}
278impl Enable {
279    pub fn builder() -> EnableBuilder {
280        <EnableBuilder as Default>::default()
281    }
282}
283#[derive(Default, Clone)]
284pub struct EnableBuilder {
285    max_total_buffer_size: Option<i64>,
286    max_resource_buffer_size: Option<i64>,
287    max_post_data_size: Option<i64>,
288    report_direct_socket_traffic: Option<bool>,
289    enable_durable_messages: Option<bool>,
290}
291impl EnableBuilder {
292    pub fn max_total_buffer_size(mut self, max_total_buffer_size: impl Into<i64>) -> Self {
293        self.max_total_buffer_size = Some(max_total_buffer_size.into());
294        self
295    }
296    pub fn max_resource_buffer_size(mut self, max_resource_buffer_size: impl Into<i64>) -> Self {
297        self.max_resource_buffer_size = Some(max_resource_buffer_size.into());
298        self
299    }
300    pub fn max_post_data_size(mut self, max_post_data_size: impl Into<i64>) -> Self {
301        self.max_post_data_size = Some(max_post_data_size.into());
302        self
303    }
304    pub fn report_direct_socket_traffic(
305        mut self,
306        report_direct_socket_traffic: impl Into<bool>,
307    ) -> Self {
308        self.report_direct_socket_traffic = Some(report_direct_socket_traffic.into());
309        self
310    }
311    pub fn enable_durable_messages(mut self, enable_durable_messages: impl Into<bool>) -> Self {
312        self.enable_durable_messages = Some(enable_durable_messages.into());
313        self
314    }
315    pub fn build(self) -> Enable {
316        Enable {
317            method: EnableMethod::Enable,
318            params: EnableParams {
319                max_total_buffer_size: self.max_total_buffer_size,
320                max_resource_buffer_size: self.max_resource_buffer_size,
321                max_post_data_size: self.max_post_data_size,
322                report_direct_socket_traffic: self.report_direct_socket_traffic,
323                enable_durable_messages: self.enable_durable_messages,
324            },
325        }
326    }
327}
328impl ConfigureDurableMessages {
329    pub fn builder() -> ConfigureDurableMessagesBuilder {
330        <ConfigureDurableMessagesBuilder as Default>::default()
331    }
332}
333#[derive(Default, Clone)]
334pub struct ConfigureDurableMessagesBuilder {
335    max_total_buffer_size: Option<i64>,
336    max_resource_buffer_size: Option<i64>,
337}
338impl ConfigureDurableMessagesBuilder {
339    pub fn max_total_buffer_size(mut self, max_total_buffer_size: impl Into<i64>) -> Self {
340        self.max_total_buffer_size = Some(max_total_buffer_size.into());
341        self
342    }
343    pub fn max_resource_buffer_size(mut self, max_resource_buffer_size: impl Into<i64>) -> Self {
344        self.max_resource_buffer_size = Some(max_resource_buffer_size.into());
345        self
346    }
347    pub fn build(self) -> ConfigureDurableMessages {
348        ConfigureDurableMessages {
349            method: ConfigureDurableMessagesMethod::ConfigureDurableMessages,
350            params: ConfigureDurableMessagesParams {
351                max_total_buffer_size: self.max_total_buffer_size,
352                max_resource_buffer_size: self.max_resource_buffer_size,
353            },
354        }
355    }
356}
357impl GetCertificate {
358    pub fn builder() -> GetCertificateBuilder {
359        <GetCertificateBuilder as Default>::default()
360    }
361}
362#[derive(Default, Clone)]
363pub struct GetCertificateBuilder {
364    origin: Option<String>,
365}
366impl GetCertificateBuilder {
367    pub fn origin(mut self, origin: impl Into<String>) -> Self {
368        self.origin = Some(origin.into());
369        self
370    }
371    pub fn build(self) -> Result<GetCertificate, String> {
372        Ok(GetCertificate {
373            method: GetCertificateMethod::GetCertificate,
374            params: GetCertificateParams {
375                origin: self
376                    .origin
377                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(origin)))?,
378            },
379        })
380    }
381}
382impl GetCookies {
383    pub fn builder() -> GetCookiesBuilder {
384        <GetCookiesBuilder as Default>::default()
385    }
386}
387#[derive(Default, Clone)]
388pub struct GetCookiesBuilder {
389    urls: Option<Vec<String>>,
390}
391impl GetCookiesBuilder {
392    pub fn url(mut self, url: impl Into<String>) -> Self {
393        let v = self.urls.get_or_insert(Vec::new());
394        v.push(url.into());
395        self
396    }
397    pub fn urls<I, S>(mut self, urls: I) -> Self
398    where
399        I: IntoIterator<Item = S>,
400        S: Into<String>,
401    {
402        let v = self.urls.get_or_insert(Vec::new());
403        for val in urls {
404            v.push(val.into());
405        }
406        self
407    }
408    pub fn build(self) -> GetCookies {
409        GetCookies {
410            method: GetCookiesMethod::GetCookies,
411            params: GetCookiesParams { urls: self.urls },
412        }
413    }
414}
415impl GetResponseBody {
416    pub fn builder() -> GetResponseBodyBuilder {
417        <GetResponseBodyBuilder as Default>::default()
418    }
419}
420#[derive(Default, Clone)]
421pub struct GetResponseBodyBuilder {
422    request_id: Option<super::types::RequestId>,
423}
424impl GetResponseBodyBuilder {
425    pub fn request_id(mut self, request_id: impl Into<super::types::RequestId>) -> Self {
426        self.request_id = Some(request_id.into());
427        self
428    }
429    pub fn build(self) -> Result<GetResponseBody, String> {
430        Ok(GetResponseBody {
431            method: GetResponseBodyMethod::GetResponseBody,
432            params: GetResponseBodyParams {
433                request_id: self.request_id.ok_or_else(|| {
434                    format!("Field `{}` is mandatory.", std::stringify!(request_id))
435                })?,
436            },
437        })
438    }
439}
440impl GetRequestPostData {
441    pub fn builder() -> GetRequestPostDataBuilder {
442        <GetRequestPostDataBuilder as Default>::default()
443    }
444}
445#[derive(Default, Clone)]
446pub struct GetRequestPostDataBuilder {
447    request_id: Option<super::types::RequestId>,
448}
449impl GetRequestPostDataBuilder {
450    pub fn request_id(mut self, request_id: impl Into<super::types::RequestId>) -> Self {
451        self.request_id = Some(request_id.into());
452        self
453    }
454    pub fn build(self) -> Result<GetRequestPostData, String> {
455        Ok(GetRequestPostData {
456            method: GetRequestPostDataMethod::GetRequestPostData,
457            params: GetRequestPostDataParams {
458                request_id: self.request_id.ok_or_else(|| {
459                    format!("Field `{}` is mandatory.", std::stringify!(request_id))
460                })?,
461            },
462        })
463    }
464}
465impl GetResponseBodyForInterception {
466    pub fn builder() -> GetResponseBodyForInterceptionBuilder {
467        <GetResponseBodyForInterceptionBuilder as Default>::default()
468    }
469}
470#[derive(Default, Clone)]
471pub struct GetResponseBodyForInterceptionBuilder {
472    interception_id: Option<super::types::InterceptionId>,
473}
474impl GetResponseBodyForInterceptionBuilder {
475    pub fn interception_id(
476        mut self,
477        interception_id: impl Into<super::types::InterceptionId>,
478    ) -> Self {
479        self.interception_id = Some(interception_id.into());
480        self
481    }
482    pub fn build(self) -> Result<GetResponseBodyForInterception, String> {
483        Ok(GetResponseBodyForInterception {
484            method: GetResponseBodyForInterceptionMethod::GetResponseBodyForInterception,
485            params: GetResponseBodyForInterceptionParams {
486                interception_id: self.interception_id.ok_or_else(|| {
487                    format!("Field `{}` is mandatory.", std::stringify!(interception_id))
488                })?,
489            },
490        })
491    }
492}
493impl TakeResponseBodyForInterceptionAsStream {
494    pub fn builder() -> TakeResponseBodyForInterceptionAsStreamBuilder {
495        <TakeResponseBodyForInterceptionAsStreamBuilder as Default>::default()
496    }
497}
498#[derive(Default, Clone)]
499pub struct TakeResponseBodyForInterceptionAsStreamBuilder {
500    interception_id: Option<super::types::InterceptionId>,
501}
502impl TakeResponseBodyForInterceptionAsStreamBuilder {
503    pub fn interception_id(
504        mut self,
505        interception_id: impl Into<super::types::InterceptionId>,
506    ) -> Self {
507        self.interception_id = Some(interception_id.into());
508        self
509    }
510    pub fn build(self) -> Result<TakeResponseBodyForInterceptionAsStream, String> {
511        Ok (TakeResponseBodyForInterceptionAsStream { method : TakeResponseBodyForInterceptionAsStreamMethod :: TakeResponseBodyForInterceptionAsStream , params : TakeResponseBodyForInterceptionAsStreamParams { interception_id : self . interception_id . ok_or_else (|| format ! ("Field `{}` is mandatory." , std :: stringify ! (interception_id))) ? , } , })
512    }
513}
514impl ReplayXhr {
515    pub fn builder() -> ReplayXhrBuilder {
516        <ReplayXhrBuilder as Default>::default()
517    }
518}
519#[derive(Default, Clone)]
520pub struct ReplayXhrBuilder {
521    request_id: Option<super::types::RequestId>,
522}
523impl ReplayXhrBuilder {
524    pub fn request_id(mut self, request_id: impl Into<super::types::RequestId>) -> Self {
525        self.request_id = Some(request_id.into());
526        self
527    }
528    pub fn build(self) -> Result<ReplayXhr, String> {
529        Ok(ReplayXhr {
530            method: ReplayXhrMethod::ReplayXhr,
531            params: ReplayXhrParams {
532                request_id: self.request_id.ok_or_else(|| {
533                    format!("Field `{}` is mandatory.", std::stringify!(request_id))
534                })?,
535            },
536        })
537    }
538}
539impl SearchInResponseBody {
540    pub fn builder() -> SearchInResponseBodyBuilder {
541        <SearchInResponseBodyBuilder as Default>::default()
542    }
543}
544#[derive(Default, Clone)]
545pub struct SearchInResponseBodyBuilder {
546    request_id: Option<super::types::RequestId>,
547    query: Option<String>,
548    case_sensitive: Option<bool>,
549    is_regex: Option<bool>,
550}
551impl SearchInResponseBodyBuilder {
552    pub fn request_id(mut self, request_id: impl Into<super::types::RequestId>) -> Self {
553        self.request_id = Some(request_id.into());
554        self
555    }
556    pub fn query(mut self, query: impl Into<String>) -> Self {
557        self.query = Some(query.into());
558        self
559    }
560    pub fn case_sensitive(mut self, case_sensitive: impl Into<bool>) -> Self {
561        self.case_sensitive = Some(case_sensitive.into());
562        self
563    }
564    pub fn is_regex(mut self, is_regex: impl Into<bool>) -> Self {
565        self.is_regex = Some(is_regex.into());
566        self
567    }
568    pub fn build(self) -> Result<SearchInResponseBody, String> {
569        Ok(SearchInResponseBody {
570            method: SearchInResponseBodyMethod::SearchInResponseBody,
571            params: SearchInResponseBodyParams {
572                request_id: self.request_id.ok_or_else(|| {
573                    format!("Field `{}` is mandatory.", std::stringify!(request_id))
574                })?,
575                query: self
576                    .query
577                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(query)))?,
578                case_sensitive: self.case_sensitive,
579                is_regex: self.is_regex,
580            },
581        })
582    }
583}
584impl SetBlockedUrLs {
585    pub fn builder() -> SetBlockedUrLsBuilder {
586        <SetBlockedUrLsBuilder as Default>::default()
587    }
588}
589#[derive(Default, Clone)]
590pub struct SetBlockedUrLsBuilder {
591    url_patterns: Option<Vec<super::types::BlockPattern>>,
592}
593impl SetBlockedUrLsBuilder {
594    pub fn url_pattern(mut self, url_pattern: impl Into<super::types::BlockPattern>) -> Self {
595        let v = self.url_patterns.get_or_insert(Vec::new());
596        v.push(url_pattern.into());
597        self
598    }
599    pub fn url_patterns<I, S>(mut self, url_patterns: I) -> Self
600    where
601        I: IntoIterator<Item = S>,
602        S: Into<super::types::BlockPattern>,
603    {
604        let v = self.url_patterns.get_or_insert(Vec::new());
605        for val in url_patterns {
606            v.push(val.into());
607        }
608        self
609    }
610    pub fn build(self) -> SetBlockedUrLs {
611        SetBlockedUrLs {
612            method: SetBlockedUrLsMethod::SetBlockedUrLs,
613            params: SetBlockedUrLsParams {
614                url_patterns: self.url_patterns,
615            },
616        }
617    }
618}
619impl SetBypassServiceWorker {
620    pub fn builder() -> SetBypassServiceWorkerBuilder {
621        <SetBypassServiceWorkerBuilder as Default>::default()
622    }
623}
624#[derive(Default, Clone)]
625pub struct SetBypassServiceWorkerBuilder {
626    bypass: Option<bool>,
627}
628impl SetBypassServiceWorkerBuilder {
629    pub fn bypass(mut self, bypass: impl Into<bool>) -> Self {
630        self.bypass = Some(bypass.into());
631        self
632    }
633    pub fn build(self) -> Result<SetBypassServiceWorker, String> {
634        Ok(SetBypassServiceWorker {
635            method: SetBypassServiceWorkerMethod::SetBypassServiceWorker,
636            params: SetBypassServiceWorkerParams {
637                bypass: self
638                    .bypass
639                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(bypass)))?,
640            },
641        })
642    }
643}
644impl SetCacheDisabled {
645    pub fn builder() -> SetCacheDisabledBuilder {
646        <SetCacheDisabledBuilder as Default>::default()
647    }
648}
649#[derive(Default, Clone)]
650pub struct SetCacheDisabledBuilder {
651    cache_disabled: Option<bool>,
652}
653impl SetCacheDisabledBuilder {
654    pub fn cache_disabled(mut self, cache_disabled: impl Into<bool>) -> Self {
655        self.cache_disabled = Some(cache_disabled.into());
656        self
657    }
658    pub fn build(self) -> Result<SetCacheDisabled, String> {
659        Ok(SetCacheDisabled {
660            method: SetCacheDisabledMethod::SetCacheDisabled,
661            params: SetCacheDisabledParams {
662                cache_disabled: self.cache_disabled.ok_or_else(|| {
663                    format!("Field `{}` is mandatory.", std::stringify!(cache_disabled))
664                })?,
665            },
666        })
667    }
668}
669impl SetCookie {
670    pub fn builder() -> SetCookieBuilder {
671        <SetCookieBuilder as Default>::default()
672    }
673}
674#[derive(Default, Clone)]
675pub struct SetCookieBuilder {
676    name: Option<String>,
677    value: Option<String>,
678    url: Option<String>,
679    domain: Option<String>,
680    path: Option<String>,
681    secure: Option<bool>,
682    http_only: Option<bool>,
683    same_site: Option<super::types::CookieSameSite>,
684    expires: Option<super::types::TimeSinceEpoch>,
685    priority: Option<super::types::CookiePriority>,
686    source_scheme: Option<super::types::CookieSourceScheme>,
687    source_port: Option<i64>,
688    partition_key: Option<super::types::CookiePartitionKey>,
689}
690impl SetCookieBuilder {
691    pub fn name(mut self, name: impl Into<String>) -> Self {
692        self.name = Some(name.into());
693        self
694    }
695    pub fn value(mut self, value: impl Into<String>) -> Self {
696        self.value = Some(value.into());
697        self
698    }
699    pub fn url(mut self, url: impl Into<String>) -> Self {
700        self.url = Some(url.into());
701        self
702    }
703    pub fn domain(mut self, domain: impl Into<String>) -> Self {
704        self.domain = Some(domain.into());
705        self
706    }
707    pub fn path(mut self, path: impl Into<String>) -> Self {
708        self.path = Some(path.into());
709        self
710    }
711    pub fn secure(mut self, secure: impl Into<bool>) -> Self {
712        self.secure = Some(secure.into());
713        self
714    }
715    pub fn http_only(mut self, http_only: impl Into<bool>) -> Self {
716        self.http_only = Some(http_only.into());
717        self
718    }
719    pub fn same_site(mut self, same_site: impl Into<super::types::CookieSameSite>) -> Self {
720        self.same_site = Some(same_site.into());
721        self
722    }
723    pub fn expires(mut self, expires: impl Into<super::types::TimeSinceEpoch>) -> Self {
724        self.expires = Some(expires.into());
725        self
726    }
727    pub fn priority(mut self, priority: impl Into<super::types::CookiePriority>) -> Self {
728        self.priority = Some(priority.into());
729        self
730    }
731    pub fn source_scheme(
732        mut self,
733        source_scheme: impl Into<super::types::CookieSourceScheme>,
734    ) -> Self {
735        self.source_scheme = Some(source_scheme.into());
736        self
737    }
738    pub fn source_port(mut self, source_port: impl Into<i64>) -> Self {
739        self.source_port = Some(source_port.into());
740        self
741    }
742    pub fn partition_key(
743        mut self,
744        partition_key: impl Into<super::types::CookiePartitionKey>,
745    ) -> Self {
746        self.partition_key = Some(partition_key.into());
747        self
748    }
749    pub fn build(self) -> Result<SetCookie, String> {
750        Ok(SetCookie {
751            method: SetCookieMethod::SetCookie,
752            params: SetCookieParams {
753                name: self
754                    .name
755                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(name)))?,
756                value: self
757                    .value
758                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(value)))?,
759                url: self.url,
760                domain: self.domain,
761                path: self.path,
762                secure: self.secure,
763                http_only: self.http_only,
764                same_site: self.same_site,
765                expires: self.expires,
766                priority: self.priority,
767                source_scheme: self.source_scheme,
768                source_port: self.source_port,
769                partition_key: self.partition_key,
770            },
771        })
772    }
773}
774impl SetCookies {
775    pub fn builder() -> SetCookiesBuilder {
776        <SetCookiesBuilder as Default>::default()
777    }
778}
779#[derive(Default, Clone)]
780pub struct SetCookiesBuilder {
781    cookies: Option<Vec<super::types::CookieParam>>,
782}
783impl SetCookiesBuilder {
784    pub fn cookie(mut self, cookie: impl Into<super::types::CookieParam>) -> Self {
785        let v = self.cookies.get_or_insert(Vec::new());
786        v.push(cookie.into());
787        self
788    }
789    pub fn cookies<I, S>(mut self, cookies: I) -> Self
790    where
791        I: IntoIterator<Item = S>,
792        S: Into<super::types::CookieParam>,
793    {
794        let v = self.cookies.get_or_insert(Vec::new());
795        for val in cookies {
796            v.push(val.into());
797        }
798        self
799    }
800    pub fn build(self) -> Result<SetCookies, String> {
801        Ok(SetCookies {
802            method: SetCookiesMethod::SetCookies,
803            params: SetCookiesParams {
804                cookies: self
805                    .cookies
806                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(cookies)))?,
807            },
808        })
809    }
810}
811impl SetExtraHttpHeaders {
812    pub fn builder() -> SetExtraHttpHeadersBuilder {
813        <SetExtraHttpHeadersBuilder as Default>::default()
814    }
815}
816#[derive(Default, Clone)]
817pub struct SetExtraHttpHeadersBuilder {
818    headers: Option<super::types::Headers>,
819}
820impl SetExtraHttpHeadersBuilder {
821    pub fn headers(mut self, headers: impl Into<super::types::Headers>) -> Self {
822        self.headers = Some(headers.into());
823        self
824    }
825    pub fn build(self) -> Result<SetExtraHttpHeaders, String> {
826        Ok(SetExtraHttpHeaders {
827            method: SetExtraHttpHeadersMethod::SetExtraHttpHeaders,
828            params: SetExtraHttpHeadersParams {
829                headers: self
830                    .headers
831                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(headers)))?,
832            },
833        })
834    }
835}
836impl SetAttachDebugStack {
837    pub fn builder() -> SetAttachDebugStackBuilder {
838        <SetAttachDebugStackBuilder as Default>::default()
839    }
840}
841#[derive(Default, Clone)]
842pub struct SetAttachDebugStackBuilder {
843    enabled: Option<bool>,
844}
845impl SetAttachDebugStackBuilder {
846    pub fn enabled(mut self, enabled: impl Into<bool>) -> Self {
847        self.enabled = Some(enabled.into());
848        self
849    }
850    pub fn build(self) -> Result<SetAttachDebugStack, String> {
851        Ok(SetAttachDebugStack {
852            method: SetAttachDebugStackMethod::SetAttachDebugStack,
853            params: SetAttachDebugStackParams {
854                enabled: self
855                    .enabled
856                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(enabled)))?,
857            },
858        })
859    }
860}
861impl SetUserAgentOverride {
862    pub fn builder() -> SetUserAgentOverrideBuilder {
863        <SetUserAgentOverrideBuilder as Default>::default()
864    }
865}
866#[derive(Default, Clone)]
867pub struct SetUserAgentOverrideBuilder {
868    user_agent: Option<String>,
869    accept_language: Option<String>,
870    platform: Option<String>,
871    user_agent_metadata: Option<crate::browser_protocol::emulation::types::UserAgentMetadata>,
872}
873impl SetUserAgentOverrideBuilder {
874    pub fn user_agent(mut self, user_agent: impl Into<String>) -> Self {
875        self.user_agent = Some(user_agent.into());
876        self
877    }
878    pub fn accept_language(mut self, accept_language: impl Into<String>) -> Self {
879        self.accept_language = Some(accept_language.into());
880        self
881    }
882    pub fn platform(mut self, platform: impl Into<String>) -> Self {
883        self.platform = Some(platform.into());
884        self
885    }
886    pub fn user_agent_metadata(
887        mut self,
888        user_agent_metadata: impl Into<crate::browser_protocol::emulation::types::UserAgentMetadata>,
889    ) -> Self {
890        self.user_agent_metadata = Some(user_agent_metadata.into());
891        self
892    }
893    pub fn build(self) -> Result<SetUserAgentOverride, String> {
894        Ok(SetUserAgentOverride {
895            method: SetUserAgentOverrideMethod::SetUserAgentOverride,
896            params: SetUserAgentOverrideParams {
897                user_agent: self.user_agent.ok_or_else(|| {
898                    format!("Field `{}` is mandatory.", std::stringify!(user_agent))
899                })?,
900                accept_language: self.accept_language,
901                platform: self.platform,
902                user_agent_metadata: self.user_agent_metadata,
903            },
904        })
905    }
906}
907impl StreamResourceContent {
908    pub fn builder() -> StreamResourceContentBuilder {
909        <StreamResourceContentBuilder as Default>::default()
910    }
911}
912#[derive(Default, Clone)]
913pub struct StreamResourceContentBuilder {
914    request_id: Option<super::types::RequestId>,
915}
916impl StreamResourceContentBuilder {
917    pub fn request_id(mut self, request_id: impl Into<super::types::RequestId>) -> Self {
918        self.request_id = Some(request_id.into());
919        self
920    }
921    pub fn build(self) -> Result<StreamResourceContent, String> {
922        Ok(StreamResourceContent {
923            method: StreamResourceContentMethod::StreamResourceContent,
924            params: StreamResourceContentParams {
925                request_id: self.request_id.ok_or_else(|| {
926                    format!("Field `{}` is mandatory.", std::stringify!(request_id))
927                })?,
928            },
929        })
930    }
931}
932impl GetSecurityIsolationStatus {
933    pub fn builder() -> GetSecurityIsolationStatusBuilder {
934        <GetSecurityIsolationStatusBuilder as Default>::default()
935    }
936}
937#[derive(Default, Clone)]
938pub struct GetSecurityIsolationStatusBuilder {
939    frame_id: Option<crate::browser_protocol::page::types::FrameId>,
940}
941impl GetSecurityIsolationStatusBuilder {
942    pub fn frame_id(
943        mut self,
944        frame_id: impl Into<crate::browser_protocol::page::types::FrameId>,
945    ) -> Self {
946        self.frame_id = Some(frame_id.into());
947        self
948    }
949    pub fn build(self) -> GetSecurityIsolationStatus {
950        GetSecurityIsolationStatus {
951            method: GetSecurityIsolationStatusMethod::GetSecurityIsolationStatus,
952            params: GetSecurityIsolationStatusParams {
953                frame_id: self.frame_id,
954            },
955        }
956    }
957}
958impl EnableReportingApi {
959    pub fn builder() -> EnableReportingApiBuilder {
960        <EnableReportingApiBuilder as Default>::default()
961    }
962}
963#[derive(Default, Clone)]
964pub struct EnableReportingApiBuilder {
965    enable: Option<bool>,
966}
967impl EnableReportingApiBuilder {
968    pub fn enable(mut self, enable: impl Into<bool>) -> Self {
969        self.enable = Some(enable.into());
970        self
971    }
972    pub fn build(self) -> Result<EnableReportingApi, String> {
973        Ok(EnableReportingApi {
974            method: EnableReportingApiMethod::EnableReportingApi,
975            params: EnableReportingApiParams {
976                enable: self
977                    .enable
978                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(enable)))?,
979            },
980        })
981    }
982}
983impl EnableDeviceBoundSessions {
984    pub fn builder() -> EnableDeviceBoundSessionsBuilder {
985        <EnableDeviceBoundSessionsBuilder as Default>::default()
986    }
987}
988#[derive(Default, Clone)]
989pub struct EnableDeviceBoundSessionsBuilder {
990    enable: Option<bool>,
991}
992impl EnableDeviceBoundSessionsBuilder {
993    pub fn enable(mut self, enable: impl Into<bool>) -> Self {
994        self.enable = Some(enable.into());
995        self
996    }
997    pub fn build(self) -> Result<EnableDeviceBoundSessions, String> {
998        Ok(EnableDeviceBoundSessions {
999            method: EnableDeviceBoundSessionsMethod::EnableDeviceBoundSessions,
1000            params: EnableDeviceBoundSessionsParams {
1001                enable: self
1002                    .enable
1003                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(enable)))?,
1004            },
1005        })
1006    }
1007}
1008impl FetchSchemefulSite {
1009    pub fn builder() -> FetchSchemefulSiteBuilder {
1010        <FetchSchemefulSiteBuilder as Default>::default()
1011    }
1012}
1013#[derive(Default, Clone)]
1014pub struct FetchSchemefulSiteBuilder {
1015    origin: Option<String>,
1016}
1017impl FetchSchemefulSiteBuilder {
1018    pub fn origin(mut self, origin: impl Into<String>) -> Self {
1019        self.origin = Some(origin.into());
1020        self
1021    }
1022    pub fn build(self) -> Result<FetchSchemefulSite, String> {
1023        Ok(FetchSchemefulSite {
1024            method: FetchSchemefulSiteMethod::FetchSchemefulSite,
1025            params: FetchSchemefulSiteParams {
1026                origin: self
1027                    .origin
1028                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(origin)))?,
1029            },
1030        })
1031    }
1032}
1033impl LoadNetworkResource {
1034    pub fn builder() -> LoadNetworkResourceBuilder {
1035        <LoadNetworkResourceBuilder as Default>::default()
1036    }
1037}
1038#[derive(Default, Clone)]
1039pub struct LoadNetworkResourceBuilder {
1040    frame_id: Option<crate::browser_protocol::page::types::FrameId>,
1041    url: Option<String>,
1042    options: Option<super::types::LoadNetworkResourceOptions>,
1043}
1044impl LoadNetworkResourceBuilder {
1045    pub fn frame_id(
1046        mut self,
1047        frame_id: impl Into<crate::browser_protocol::page::types::FrameId>,
1048    ) -> Self {
1049        self.frame_id = Some(frame_id.into());
1050        self
1051    }
1052    pub fn url(mut self, url: impl Into<String>) -> Self {
1053        self.url = Some(url.into());
1054        self
1055    }
1056    pub fn options(mut self, options: impl Into<super::types::LoadNetworkResourceOptions>) -> Self {
1057        self.options = Some(options.into());
1058        self
1059    }
1060    pub fn build(self) -> Result<LoadNetworkResource, String> {
1061        Ok(LoadNetworkResource {
1062            method: LoadNetworkResourceMethod::LoadNetworkResource,
1063            params: LoadNetworkResourceParams {
1064                frame_id: self.frame_id,
1065                url: self
1066                    .url
1067                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(url)))?,
1068                options: self
1069                    .options
1070                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(options)))?,
1071            },
1072        })
1073    }
1074}
1075impl SetCookieControls {
1076    pub fn builder() -> SetCookieControlsBuilder {
1077        <SetCookieControlsBuilder as Default>::default()
1078    }
1079}
1080#[derive(Default, Clone)]
1081pub struct SetCookieControlsBuilder {
1082    enable_third_party_cookie_restriction: Option<bool>,
1083    disable_third_party_cookie_metadata: Option<bool>,
1084    disable_third_party_cookie_heuristics: Option<bool>,
1085}
1086impl SetCookieControlsBuilder {
1087    pub fn enable_third_party_cookie_restriction(
1088        mut self,
1089        enable_third_party_cookie_restriction: impl Into<bool>,
1090    ) -> Self {
1091        self.enable_third_party_cookie_restriction =
1092            Some(enable_third_party_cookie_restriction.into());
1093        self
1094    }
1095    pub fn disable_third_party_cookie_metadata(
1096        mut self,
1097        disable_third_party_cookie_metadata: impl Into<bool>,
1098    ) -> Self {
1099        self.disable_third_party_cookie_metadata = Some(disable_third_party_cookie_metadata.into());
1100        self
1101    }
1102    pub fn disable_third_party_cookie_heuristics(
1103        mut self,
1104        disable_third_party_cookie_heuristics: impl Into<bool>,
1105    ) -> Self {
1106        self.disable_third_party_cookie_heuristics =
1107            Some(disable_third_party_cookie_heuristics.into());
1108        self
1109    }
1110    pub fn build(self) -> Result<SetCookieControls, String> {
1111        Ok(SetCookieControls {
1112            method: SetCookieControlsMethod::SetCookieControls,
1113            params: SetCookieControlsParams {
1114                enable_third_party_cookie_restriction: self
1115                    .enable_third_party_cookie_restriction
1116                    .ok_or_else(|| {
1117                    format!(
1118                        "Field `{}` is mandatory.",
1119                        std::stringify!(enable_third_party_cookie_restriction)
1120                    )
1121                })?,
1122                disable_third_party_cookie_metadata: self
1123                    .disable_third_party_cookie_metadata
1124                    .ok_or_else(|| {
1125                        format!(
1126                            "Field `{}` is mandatory.",
1127                            std::stringify!(disable_third_party_cookie_metadata)
1128                        )
1129                    })?,
1130                disable_third_party_cookie_heuristics: self
1131                    .disable_third_party_cookie_heuristics
1132                    .ok_or_else(|| {
1133                    format!(
1134                        "Field `{}` is mandatory.",
1135                        std::stringify!(disable_third_party_cookie_heuristics)
1136                    )
1137                })?,
1138            },
1139        })
1140    }
1141}