1use super::commands::*;
2impl AddDataCollector {
3 pub fn builder() -> AddDataCollectorBuilder {
4 <AddDataCollectorBuilder as Default>::default()
5 }
6}
7#[derive(Default, Clone)]
8pub struct AddDataCollectorBuilder {
9 data_types: Option<Vec<super::types::DataType>>,
10 max_encoded_data_size: Option<u64>,
11 collector_type: Option<super::types::CollectorType>,
12 contexts: Option<Vec<crate::browsing_context::types::BrowsingContext>>,
13 user_contexts: Option<Vec<crate::browser::types::UserContext>>,
14}
15impl AddDataCollectorBuilder {
16 pub fn data_type(mut self, data_type: impl Into<super::types::DataType>) -> Self {
17 let v = self.data_types.get_or_insert(Vec::new());
18 v.push(data_type.into());
19 self
20 }
21 pub fn data_types<I, S>(mut self, data_types: I) -> Self
22 where
23 I: IntoIterator<Item = S>,
24 S: Into<super::types::DataType>,
25 {
26 let v = self.data_types.get_or_insert(Vec::new());
27 for val in data_types {
28 v.push(val.into());
29 }
30 self
31 }
32 pub fn max_encoded_data_size(mut self, max_encoded_data_size: impl Into<u64>) -> Self {
33 self.max_encoded_data_size = Some(max_encoded_data_size.into());
34 self
35 }
36 pub fn collector_type(
37 mut self,
38 collector_type: impl Into<super::types::CollectorType>,
39 ) -> Self {
40 self.collector_type = Some(collector_type.into());
41 self
42 }
43 pub fn context(
44 mut self,
45 context: impl Into<crate::browsing_context::types::BrowsingContext>,
46 ) -> Self {
47 let v = self.contexts.get_or_insert(Vec::new());
48 v.push(context.into());
49 self
50 }
51 pub fn contexts<I, S>(mut self, contexts: I) -> Self
52 where
53 I: IntoIterator<Item = S>,
54 S: Into<crate::browsing_context::types::BrowsingContext>,
55 {
56 let v = self.contexts.get_or_insert(Vec::new());
57 for val in contexts {
58 v.push(val.into());
59 }
60 self
61 }
62 pub fn user_context(
63 mut self,
64 user_context: impl Into<crate::browser::types::UserContext>,
65 ) -> Self {
66 let v = self.user_contexts.get_or_insert(Vec::new());
67 v.push(user_context.into());
68 self
69 }
70 pub fn user_contexts<I, S>(mut self, user_contexts: I) -> Self
71 where
72 I: IntoIterator<Item = S>,
73 S: Into<crate::browser::types::UserContext>,
74 {
75 let v = self.user_contexts.get_or_insert(Vec::new());
76 for val in user_contexts {
77 v.push(val.into());
78 }
79 self
80 }
81 pub fn build(self) -> Result<AddDataCollector, String> {
82 Ok(AddDataCollector {
83 method: AddDataCollectorMethod::AddDataCollector,
84 params: AddDataCollectorParams {
85 data_types: self.data_types.ok_or_else(|| {
86 format!("Field `{}` is mandatory.", std::stringify!(data_types))
87 })?,
88 max_encoded_data_size: self.max_encoded_data_size.ok_or_else(|| {
89 format!(
90 "Field `{}` is mandatory.",
91 std::stringify!(max_encoded_data_size)
92 )
93 })?,
94 collector_type: self.collector_type,
95 contexts: self.contexts,
96 user_contexts: self.user_contexts,
97 },
98 })
99 }
100}
101impl AddIntercept {
102 pub fn builder() -> AddInterceptBuilder {
103 <AddInterceptBuilder as Default>::default()
104 }
105}
106#[derive(Default, Clone)]
107pub struct AddInterceptBuilder {
108 phases: Option<Vec<super::types::InterceptPhase>>,
109 contexts: Option<Vec<crate::browsing_context::types::BrowsingContext>>,
110 url_patterns: Option<Vec<super::types::UrlPattern>>,
111}
112impl AddInterceptBuilder {
113 pub fn phase(mut self, phase: impl Into<super::types::InterceptPhase>) -> Self {
114 let v = self.phases.get_or_insert(Vec::new());
115 v.push(phase.into());
116 self
117 }
118 pub fn phases<I, S>(mut self, phases: I) -> Self
119 where
120 I: IntoIterator<Item = S>,
121 S: Into<super::types::InterceptPhase>,
122 {
123 let v = self.phases.get_or_insert(Vec::new());
124 for val in phases {
125 v.push(val.into());
126 }
127 self
128 }
129 pub fn context(
130 mut self,
131 context: impl Into<crate::browsing_context::types::BrowsingContext>,
132 ) -> Self {
133 let v = self.contexts.get_or_insert(Vec::new());
134 v.push(context.into());
135 self
136 }
137 pub fn contexts<I, S>(mut self, contexts: I) -> Self
138 where
139 I: IntoIterator<Item = S>,
140 S: Into<crate::browsing_context::types::BrowsingContext>,
141 {
142 let v = self.contexts.get_or_insert(Vec::new());
143 for val in contexts {
144 v.push(val.into());
145 }
146 self
147 }
148 pub fn url_pattern(mut self, url_pattern: impl Into<super::types::UrlPattern>) -> Self {
149 let v = self.url_patterns.get_or_insert(Vec::new());
150 v.push(url_pattern.into());
151 self
152 }
153 pub fn url_patterns<I, S>(mut self, url_patterns: I) -> Self
154 where
155 I: IntoIterator<Item = S>,
156 S: Into<super::types::UrlPattern>,
157 {
158 let v = self.url_patterns.get_or_insert(Vec::new());
159 for val in url_patterns {
160 v.push(val.into());
161 }
162 self
163 }
164 pub fn build(self) -> Result<AddIntercept, String> {
165 Ok(AddIntercept {
166 method: AddInterceptMethod::AddIntercept,
167 params: AddInterceptParams {
168 phases: self
169 .phases
170 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(phases)))?,
171 contexts: self.contexts,
172 url_patterns: self.url_patterns,
173 },
174 })
175 }
176}
177impl ContinueRequest {
178 pub fn builder() -> ContinueRequestBuilder {
179 <ContinueRequestBuilder as Default>::default()
180 }
181}
182#[derive(Default, Clone)]
183pub struct ContinueRequestBuilder {
184 request: Option<super::types::Request>,
185 body: Option<super::types::BytesValue>,
186 cookies: Option<Vec<super::types::CookieHeader>>,
187 headers: Option<Vec<super::types::Header>>,
188 method: Option<String>,
189 url: Option<String>,
190}
191impl ContinueRequestBuilder {
192 pub fn request(mut self, request: impl Into<super::types::Request>) -> Self {
193 self.request = Some(request.into());
194 self
195 }
196 pub fn body(mut self, body: impl Into<super::types::BytesValue>) -> Self {
197 self.body = Some(body.into());
198 self
199 }
200 pub fn cookie(mut self, cookie: impl Into<super::types::CookieHeader>) -> Self {
201 let v = self.cookies.get_or_insert(Vec::new());
202 v.push(cookie.into());
203 self
204 }
205 pub fn cookies<I, S>(mut self, cookies: I) -> Self
206 where
207 I: IntoIterator<Item = S>,
208 S: Into<super::types::CookieHeader>,
209 {
210 let v = self.cookies.get_or_insert(Vec::new());
211 for val in cookies {
212 v.push(val.into());
213 }
214 self
215 }
216 pub fn header(mut self, header: impl Into<super::types::Header>) -> Self {
217 let v = self.headers.get_or_insert(Vec::new());
218 v.push(header.into());
219 self
220 }
221 pub fn headers<I, S>(mut self, headers: I) -> Self
222 where
223 I: IntoIterator<Item = S>,
224 S: Into<super::types::Header>,
225 {
226 let v = self.headers.get_or_insert(Vec::new());
227 for val in headers {
228 v.push(val.into());
229 }
230 self
231 }
232 pub fn method(mut self, method: impl Into<String>) -> Self {
233 self.method = Some(method.into());
234 self
235 }
236 pub fn url(mut self, url: impl Into<String>) -> Self {
237 self.url = Some(url.into());
238 self
239 }
240 pub fn build(self) -> Result<ContinueRequest, String> {
241 Ok(ContinueRequest {
242 method: ContinueRequestMethod::ContinueRequest,
243 params: ContinueRequestParams {
244 request: self
245 .request
246 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(request)))?,
247 body: self.body,
248 cookies: self.cookies,
249 headers: self.headers,
250 method: self.method,
251 url: self.url,
252 },
253 })
254 }
255}
256impl ContinueResponse {
257 pub fn builder() -> ContinueResponseBuilder {
258 <ContinueResponseBuilder as Default>::default()
259 }
260}
261#[derive(Default, Clone)]
262pub struct ContinueResponseBuilder {
263 request: Option<super::types::Request>,
264 cookies: Option<Vec<super::types::SetCookieHeader>>,
265 credentials: Option<super::types::AuthCredentials>,
266 headers: Option<Vec<super::types::Header>>,
267 reason_phrase: Option<String>,
268 status_code: Option<u64>,
269}
270impl ContinueResponseBuilder {
271 pub fn request(mut self, request: impl Into<super::types::Request>) -> Self {
272 self.request = Some(request.into());
273 self
274 }
275 pub fn cookie(mut self, cookie: impl Into<super::types::SetCookieHeader>) -> Self {
276 let v = self.cookies.get_or_insert(Vec::new());
277 v.push(cookie.into());
278 self
279 }
280 pub fn cookies<I, S>(mut self, cookies: I) -> Self
281 where
282 I: IntoIterator<Item = S>,
283 S: Into<super::types::SetCookieHeader>,
284 {
285 let v = self.cookies.get_or_insert(Vec::new());
286 for val in cookies {
287 v.push(val.into());
288 }
289 self
290 }
291 pub fn credentials(mut self, credentials: impl Into<super::types::AuthCredentials>) -> Self {
292 self.credentials = Some(credentials.into());
293 self
294 }
295 pub fn header(mut self, header: impl Into<super::types::Header>) -> Self {
296 let v = self.headers.get_or_insert(Vec::new());
297 v.push(header.into());
298 self
299 }
300 pub fn headers<I, S>(mut self, headers: I) -> Self
301 where
302 I: IntoIterator<Item = S>,
303 S: Into<super::types::Header>,
304 {
305 let v = self.headers.get_or_insert(Vec::new());
306 for val in headers {
307 v.push(val.into());
308 }
309 self
310 }
311 pub fn reason_phrase(mut self, reason_phrase: impl Into<String>) -> Self {
312 self.reason_phrase = Some(reason_phrase.into());
313 self
314 }
315 pub fn status_code(mut self, status_code: impl Into<u64>) -> Self {
316 self.status_code = Some(status_code.into());
317 self
318 }
319 pub fn build(self) -> Result<ContinueResponse, String> {
320 Ok(ContinueResponse {
321 method: ContinueResponseMethod::ContinueResponse,
322 params: ContinueResponseParams {
323 request: self
324 .request
325 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(request)))?,
326 cookies: self.cookies,
327 credentials: self.credentials,
328 headers: self.headers,
329 reason_phrase: self.reason_phrase,
330 status_code: self.status_code,
331 },
332 })
333 }
334}
335impl ContinueWithAuth {
336 pub fn builder() -> ContinueWithAuthBuilder {
337 <ContinueWithAuthBuilder as Default>::default()
338 }
339}
340#[derive(Default, Clone)]
341pub struct ContinueWithAuthBuilder {
342 request: Option<super::types::Request>,
343 continue_with_auth_credentials_continue_with_auth_no_credentials_union:
344 Option<super::types::ContinueWithAuthCredentialsContinueWithAuthNoCredentialsUnion>,
345}
346impl ContinueWithAuthBuilder {
347 pub fn request(mut self, request: impl Into<super::types::Request>) -> Self {
348 self.request = Some(request.into());
349 self
350 }
351 pub fn continue_with_auth_credentials_continue_with_auth_no_credentials_union(
352 mut self,
353 continue_with_auth_credentials_continue_with_auth_no_credentials_union: impl Into<
354 super::types::ContinueWithAuthCredentialsContinueWithAuthNoCredentialsUnion,
355 >,
356 ) -> Self {
357 self.continue_with_auth_credentials_continue_with_auth_no_credentials_union =
358 Some(continue_with_auth_credentials_continue_with_auth_no_credentials_union.into());
359 self
360 }
361 pub fn build(self) -> Result<ContinueWithAuth, String> {
362 Ok (ContinueWithAuth { method : ContinueWithAuthMethod :: ContinueWithAuth , params : ContinueWithAuthParams { request : self . request . ok_or_else (|| format ! ("Field `{}` is mandatory." , std :: stringify ! (request))) ? , continue_with_auth_credentials_continue_with_auth_no_credentials_union : self . continue_with_auth_credentials_continue_with_auth_no_credentials_union . ok_or_else (|| format ! ("Field `{}` is mandatory." , std :: stringify ! (continue_with_auth_credentials_continue_with_auth_no_credentials_union))) ? , } , })
363 }
364}
365impl DisownData {
366 pub fn builder() -> DisownDataBuilder {
367 <DisownDataBuilder as Default>::default()
368 }
369}
370#[derive(Default, Clone)]
371pub struct DisownDataBuilder {
372 data_type: Option<super::types::DataType>,
373 collector: Option<super::types::Collector>,
374 request: Option<super::types::Request>,
375}
376impl DisownDataBuilder {
377 pub fn data_type(mut self, data_type: impl Into<super::types::DataType>) -> Self {
378 self.data_type = Some(data_type.into());
379 self
380 }
381 pub fn collector(mut self, collector: impl Into<super::types::Collector>) -> Self {
382 self.collector = Some(collector.into());
383 self
384 }
385 pub fn request(mut self, request: impl Into<super::types::Request>) -> Self {
386 self.request = Some(request.into());
387 self
388 }
389 pub fn build(self) -> Result<DisownData, String> {
390 Ok(DisownData {
391 method: DisownDataMethod::DisownData,
392 params: DisownDataParams {
393 data_type: self.data_type.ok_or_else(|| {
394 format!("Field `{}` is mandatory.", std::stringify!(data_type))
395 })?,
396 collector: self.collector.ok_or_else(|| {
397 format!("Field `{}` is mandatory.", std::stringify!(collector))
398 })?,
399 request: self
400 .request
401 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(request)))?,
402 },
403 })
404 }
405}
406impl FailRequest {
407 pub fn builder() -> FailRequestBuilder {
408 <FailRequestBuilder as Default>::default()
409 }
410}
411#[derive(Default, Clone)]
412pub struct FailRequestBuilder {
413 request: Option<super::types::Request>,
414}
415impl FailRequestBuilder {
416 pub fn request(mut self, request: impl Into<super::types::Request>) -> Self {
417 self.request = Some(request.into());
418 self
419 }
420 pub fn build(self) -> Result<FailRequest, String> {
421 Ok(FailRequest {
422 method: FailRequestMethod::FailRequest,
423 params: FailRequestParams {
424 request: self
425 .request
426 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(request)))?,
427 },
428 })
429 }
430}
431impl GetData {
432 pub fn builder() -> GetDataBuilder {
433 <GetDataBuilder as Default>::default()
434 }
435}
436#[derive(Default, Clone)]
437pub struct GetDataBuilder {
438 data_type: Option<super::types::DataType>,
439 collector: Option<super::types::Collector>,
440 disown: Option<bool>,
441 request: Option<super::types::Request>,
442}
443impl GetDataBuilder {
444 pub fn data_type(mut self, data_type: impl Into<super::types::DataType>) -> Self {
445 self.data_type = Some(data_type.into());
446 self
447 }
448 pub fn collector(mut self, collector: impl Into<super::types::Collector>) -> Self {
449 self.collector = Some(collector.into());
450 self
451 }
452 pub fn disown(mut self, disown: impl Into<bool>) -> Self {
453 self.disown = Some(disown.into());
454 self
455 }
456 pub fn request(mut self, request: impl Into<super::types::Request>) -> Self {
457 self.request = Some(request.into());
458 self
459 }
460 pub fn build(self) -> Result<GetData, String> {
461 Ok(GetData {
462 method: GetDataMethod::GetData,
463 params: GetDataParams {
464 data_type: self.data_type.ok_or_else(|| {
465 format!("Field `{}` is mandatory.", std::stringify!(data_type))
466 })?,
467 collector: self.collector,
468 disown: self.disown,
469 request: self
470 .request
471 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(request)))?,
472 },
473 })
474 }
475}
476impl ProvideResponse {
477 pub fn builder() -> ProvideResponseBuilder {
478 <ProvideResponseBuilder as Default>::default()
479 }
480}
481#[derive(Default, Clone)]
482pub struct ProvideResponseBuilder {
483 request: Option<super::types::Request>,
484 body: Option<super::types::BytesValue>,
485 cookies: Option<Vec<super::types::SetCookieHeader>>,
486 headers: Option<Vec<super::types::Header>>,
487 reason_phrase: Option<String>,
488 status_code: Option<u64>,
489}
490impl ProvideResponseBuilder {
491 pub fn request(mut self, request: impl Into<super::types::Request>) -> Self {
492 self.request = Some(request.into());
493 self
494 }
495 pub fn body(mut self, body: impl Into<super::types::BytesValue>) -> Self {
496 self.body = Some(body.into());
497 self
498 }
499 pub fn cookie(mut self, cookie: impl Into<super::types::SetCookieHeader>) -> Self {
500 let v = self.cookies.get_or_insert(Vec::new());
501 v.push(cookie.into());
502 self
503 }
504 pub fn cookies<I, S>(mut self, cookies: I) -> Self
505 where
506 I: IntoIterator<Item = S>,
507 S: Into<super::types::SetCookieHeader>,
508 {
509 let v = self.cookies.get_or_insert(Vec::new());
510 for val in cookies {
511 v.push(val.into());
512 }
513 self
514 }
515 pub fn header(mut self, header: impl Into<super::types::Header>) -> Self {
516 let v = self.headers.get_or_insert(Vec::new());
517 v.push(header.into());
518 self
519 }
520 pub fn headers<I, S>(mut self, headers: I) -> Self
521 where
522 I: IntoIterator<Item = S>,
523 S: Into<super::types::Header>,
524 {
525 let v = self.headers.get_or_insert(Vec::new());
526 for val in headers {
527 v.push(val.into());
528 }
529 self
530 }
531 pub fn reason_phrase(mut self, reason_phrase: impl Into<String>) -> Self {
532 self.reason_phrase = Some(reason_phrase.into());
533 self
534 }
535 pub fn status_code(mut self, status_code: impl Into<u64>) -> Self {
536 self.status_code = Some(status_code.into());
537 self
538 }
539 pub fn build(self) -> Result<ProvideResponse, String> {
540 Ok(ProvideResponse {
541 method: ProvideResponseMethod::ProvideResponse,
542 params: ProvideResponseParams {
543 request: self
544 .request
545 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(request)))?,
546 body: self.body,
547 cookies: self.cookies,
548 headers: self.headers,
549 reason_phrase: self.reason_phrase,
550 status_code: self.status_code,
551 },
552 })
553 }
554}
555impl RemoveDataCollector {
556 pub fn builder() -> RemoveDataCollectorBuilder {
557 <RemoveDataCollectorBuilder as Default>::default()
558 }
559}
560#[derive(Default, Clone)]
561pub struct RemoveDataCollectorBuilder {
562 collector: Option<super::types::Collector>,
563}
564impl RemoveDataCollectorBuilder {
565 pub fn collector(mut self, collector: impl Into<super::types::Collector>) -> Self {
566 self.collector = Some(collector.into());
567 self
568 }
569 pub fn build(self) -> Result<RemoveDataCollector, String> {
570 Ok(RemoveDataCollector {
571 method: RemoveDataCollectorMethod::RemoveDataCollector,
572 params: RemoveDataCollectorParams {
573 collector: self.collector.ok_or_else(|| {
574 format!("Field `{}` is mandatory.", std::stringify!(collector))
575 })?,
576 },
577 })
578 }
579}
580impl RemoveIntercept {
581 pub fn builder() -> RemoveInterceptBuilder {
582 <RemoveInterceptBuilder as Default>::default()
583 }
584}
585#[derive(Default, Clone)]
586pub struct RemoveInterceptBuilder {
587 intercept: Option<super::types::Intercept>,
588}
589impl RemoveInterceptBuilder {
590 pub fn intercept(mut self, intercept: impl Into<super::types::Intercept>) -> Self {
591 self.intercept = Some(intercept.into());
592 self
593 }
594 pub fn build(self) -> Result<RemoveIntercept, String> {
595 Ok(RemoveIntercept {
596 method: RemoveInterceptMethod::RemoveIntercept,
597 params: RemoveInterceptParams {
598 intercept: self.intercept.ok_or_else(|| {
599 format!("Field `{}` is mandatory.", std::stringify!(intercept))
600 })?,
601 },
602 })
603 }
604}
605impl SetCacheBehavior {
606 pub fn builder() -> SetCacheBehaviorBuilder {
607 <SetCacheBehaviorBuilder as Default>::default()
608 }
609}
610#[derive(Default, Clone)]
611pub struct SetCacheBehaviorBuilder {
612 cache_behavior: Option<SetCacheBehaviorCacheBehavior>,
613 contexts: Option<Vec<crate::browsing_context::types::BrowsingContext>>,
614}
615impl SetCacheBehaviorBuilder {
616 pub fn cache_behavior(
617 mut self,
618 cache_behavior: impl Into<SetCacheBehaviorCacheBehavior>,
619 ) -> Self {
620 self.cache_behavior = Some(cache_behavior.into());
621 self
622 }
623 pub fn context(
624 mut self,
625 context: impl Into<crate::browsing_context::types::BrowsingContext>,
626 ) -> Self {
627 let v = self.contexts.get_or_insert(Vec::new());
628 v.push(context.into());
629 self
630 }
631 pub fn contexts<I, S>(mut self, contexts: I) -> Self
632 where
633 I: IntoIterator<Item = S>,
634 S: Into<crate::browsing_context::types::BrowsingContext>,
635 {
636 let v = self.contexts.get_or_insert(Vec::new());
637 for val in contexts {
638 v.push(val.into());
639 }
640 self
641 }
642 pub fn build(self) -> Result<SetCacheBehavior, String> {
643 Ok(SetCacheBehavior {
644 method: SetCacheBehaviorMethod::SetCacheBehavior,
645 params: SetCacheBehaviorParams {
646 cache_behavior: self.cache_behavior.ok_or_else(|| {
647 format!("Field `{}` is mandatory.", std::stringify!(cache_behavior))
648 })?,
649 contexts: self.contexts,
650 },
651 })
652 }
653}
654impl SetExtraHeaders {
655 pub fn builder() -> SetExtraHeadersBuilder {
656 <SetExtraHeadersBuilder as Default>::default()
657 }
658}
659#[derive(Default, Clone)]
660pub struct SetExtraHeadersBuilder {
661 headers: Option<Vec<super::types::Header>>,
662 contexts: Option<Vec<crate::browsing_context::types::BrowsingContext>>,
663 user_contexts: Option<Vec<crate::browser::types::UserContext>>,
664}
665impl SetExtraHeadersBuilder {
666 pub fn header(mut self, header: impl Into<super::types::Header>) -> Self {
667 let v = self.headers.get_or_insert(Vec::new());
668 v.push(header.into());
669 self
670 }
671 pub fn headers<I, S>(mut self, headers: I) -> Self
672 where
673 I: IntoIterator<Item = S>,
674 S: Into<super::types::Header>,
675 {
676 let v = self.headers.get_or_insert(Vec::new());
677 for val in headers {
678 v.push(val.into());
679 }
680 self
681 }
682 pub fn context(
683 mut self,
684 context: impl Into<crate::browsing_context::types::BrowsingContext>,
685 ) -> Self {
686 let v = self.contexts.get_or_insert(Vec::new());
687 v.push(context.into());
688 self
689 }
690 pub fn contexts<I, S>(mut self, contexts: I) -> Self
691 where
692 I: IntoIterator<Item = S>,
693 S: Into<crate::browsing_context::types::BrowsingContext>,
694 {
695 let v = self.contexts.get_or_insert(Vec::new());
696 for val in contexts {
697 v.push(val.into());
698 }
699 self
700 }
701 pub fn user_context(
702 mut self,
703 user_context: impl Into<crate::browser::types::UserContext>,
704 ) -> Self {
705 let v = self.user_contexts.get_or_insert(Vec::new());
706 v.push(user_context.into());
707 self
708 }
709 pub fn user_contexts<I, S>(mut self, user_contexts: I) -> Self
710 where
711 I: IntoIterator<Item = S>,
712 S: Into<crate::browser::types::UserContext>,
713 {
714 let v = self.user_contexts.get_or_insert(Vec::new());
715 for val in user_contexts {
716 v.push(val.into());
717 }
718 self
719 }
720 pub fn build(self) -> Result<SetExtraHeaders, String> {
721 Ok(SetExtraHeaders {
722 method: SetExtraHeadersMethod::SetExtraHeaders,
723 params: SetExtraHeadersParams {
724 headers: self
725 .headers
726 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(headers)))?,
727 contexts: self.contexts,
728 user_contexts: self.user_contexts,
729 },
730 })
731 }
732}