1use super::commands::*;
2impl ActivateTarget {
3 pub fn builder() -> ActivateTargetBuilder {
4 <ActivateTargetBuilder as Default>::default()
5 }
6}
7#[derive(Default, Clone)]
8pub struct ActivateTargetBuilder {
9 target_id: Option<super::types::TargetId>,
10}
11impl ActivateTargetBuilder {
12 pub fn target_id(mut self, target_id: impl Into<super::types::TargetId>) -> Self {
13 self.target_id = Some(target_id.into());
14 self
15 }
16 pub fn build(self) -> Result<ActivateTarget, String> {
17 Ok(ActivateTarget {
18 method: ActivateTargetMethod::ActivateTarget,
19 params: ActivateTargetParams {
20 target_id: self.target_id.ok_or_else(|| {
21 format!("Field `{}` is mandatory.", std::stringify!(target_id))
22 })?,
23 },
24 })
25 }
26}
27impl AttachToTarget {
28 pub fn builder() -> AttachToTargetBuilder {
29 <AttachToTargetBuilder as Default>::default()
30 }
31}
32#[derive(Default, Clone)]
33pub struct AttachToTargetBuilder {
34 target_id: Option<super::types::TargetId>,
35 flatten: Option<bool>,
36}
37impl AttachToTargetBuilder {
38 pub fn target_id(mut self, target_id: impl Into<super::types::TargetId>) -> Self {
39 self.target_id = Some(target_id.into());
40 self
41 }
42 pub fn flatten(mut self, flatten: impl Into<bool>) -> Self {
43 self.flatten = Some(flatten.into());
44 self
45 }
46 pub fn build(self) -> Result<AttachToTarget, String> {
47 Ok(AttachToTarget {
48 method: AttachToTargetMethod::AttachToTarget,
49 params: AttachToTargetParams {
50 target_id: self.target_id.ok_or_else(|| {
51 format!("Field `{}` is mandatory.", std::stringify!(target_id))
52 })?,
53 flatten: self.flatten,
54 },
55 })
56 }
57}
58#[derive(Debug, Clone, Default)]
59pub struct AttachToBrowserTargetBuilder;
60impl AttachToBrowserTargetBuilder {
61 pub fn new() -> Self {
62 Self
63 }
64 pub fn build(self) -> AttachToBrowserTarget {
65 AttachToBrowserTarget {
66 method: AttachToBrowserTargetMethod::AttachToBrowserTarget,
67 params: AttachToBrowserTargetParams {},
68 }
69 }
70}
71impl AttachToBrowserTarget {
72 pub fn builder() -> AttachToBrowserTargetBuilder {
73 AttachToBrowserTargetBuilder
74 }
75}
76impl CloseTarget {
77 pub fn builder() -> CloseTargetBuilder {
78 <CloseTargetBuilder as Default>::default()
79 }
80}
81#[derive(Default, Clone)]
82pub struct CloseTargetBuilder {
83 target_id: Option<super::types::TargetId>,
84}
85impl CloseTargetBuilder {
86 pub fn target_id(mut self, target_id: impl Into<super::types::TargetId>) -> Self {
87 self.target_id = Some(target_id.into());
88 self
89 }
90 pub fn build(self) -> Result<CloseTarget, String> {
91 Ok(CloseTarget {
92 method: CloseTargetMethod::CloseTarget,
93 params: CloseTargetParams {
94 target_id: self.target_id.ok_or_else(|| {
95 format!("Field `{}` is mandatory.", std::stringify!(target_id))
96 })?,
97 },
98 })
99 }
100}
101impl ExposeDevToolsProtocol {
102 pub fn builder() -> ExposeDevToolsProtocolBuilder {
103 <ExposeDevToolsProtocolBuilder as Default>::default()
104 }
105}
106#[derive(Default, Clone)]
107pub struct ExposeDevToolsProtocolBuilder {
108 target_id: Option<super::types::TargetId>,
109 binding_name: Option<String>,
110 inherit_permissions: Option<bool>,
111}
112impl ExposeDevToolsProtocolBuilder {
113 pub fn target_id(mut self, target_id: impl Into<super::types::TargetId>) -> Self {
114 self.target_id = Some(target_id.into());
115 self
116 }
117 pub fn binding_name(mut self, binding_name: impl Into<String>) -> Self {
118 self.binding_name = Some(binding_name.into());
119 self
120 }
121 pub fn inherit_permissions(mut self, inherit_permissions: impl Into<bool>) -> Self {
122 self.inherit_permissions = Some(inherit_permissions.into());
123 self
124 }
125 pub fn build(self) -> Result<ExposeDevToolsProtocol, String> {
126 Ok(ExposeDevToolsProtocol {
127 method: ExposeDevToolsProtocolMethod::ExposeDevToolsProtocol,
128 params: ExposeDevToolsProtocolParams {
129 target_id: self.target_id.ok_or_else(|| {
130 format!("Field `{}` is mandatory.", std::stringify!(target_id))
131 })?,
132 binding_name: self.binding_name,
133 inherit_permissions: self.inherit_permissions,
134 },
135 })
136 }
137}
138impl CreateBrowserContext {
139 pub fn builder() -> CreateBrowserContextBuilder {
140 <CreateBrowserContextBuilder as Default>::default()
141 }
142}
143#[derive(Default, Clone)]
144pub struct CreateBrowserContextBuilder {
145 dispose_on_detach: Option<bool>,
146 proxy_server: Option<String>,
147 proxy_bypass_list: Option<String>,
148 origins_with_universal_network_access: Option<Vec<String>>,
149}
150impl CreateBrowserContextBuilder {
151 pub fn dispose_on_detach(mut self, dispose_on_detach: impl Into<bool>) -> Self {
152 self.dispose_on_detach = Some(dispose_on_detach.into());
153 self
154 }
155 pub fn proxy_server(mut self, proxy_server: impl Into<String>) -> Self {
156 self.proxy_server = Some(proxy_server.into());
157 self
158 }
159 pub fn proxy_bypass_list(mut self, proxy_bypass_list: impl Into<String>) -> Self {
160 self.proxy_bypass_list = Some(proxy_bypass_list.into());
161 self
162 }
163 pub fn origins_with_universal_network_acces(
164 mut self,
165 origins_with_universal_network_acces: impl Into<String>,
166 ) -> Self {
167 let v = self
168 .origins_with_universal_network_access
169 .get_or_insert(Vec::new());
170 v.push(origins_with_universal_network_acces.into());
171 self
172 }
173 pub fn origins_with_universal_network_access<I, S>(
174 mut self,
175 origins_with_universal_network_access: I,
176 ) -> Self
177 where
178 I: IntoIterator<Item = S>,
179 S: Into<String>,
180 {
181 let v = self
182 .origins_with_universal_network_access
183 .get_or_insert(Vec::new());
184 for val in origins_with_universal_network_access {
185 v.push(val.into());
186 }
187 self
188 }
189 pub fn build(self) -> CreateBrowserContext {
190 CreateBrowserContext {
191 method: CreateBrowserContextMethod::CreateBrowserContext,
192 params: CreateBrowserContextParams {
193 dispose_on_detach: self.dispose_on_detach,
194 proxy_server: self.proxy_server,
195 proxy_bypass_list: self.proxy_bypass_list,
196 origins_with_universal_network_access: self.origins_with_universal_network_access,
197 },
198 }
199 }
200}
201#[derive(Debug, Clone, Default)]
202pub struct GetBrowserContextsBuilder;
203impl GetBrowserContextsBuilder {
204 pub fn new() -> Self {
205 Self
206 }
207 pub fn build(self) -> GetBrowserContexts {
208 GetBrowserContexts {
209 method: GetBrowserContextsMethod::GetBrowserContexts,
210 params: GetBrowserContextsParams {},
211 }
212 }
213}
214impl GetBrowserContexts {
215 pub fn builder() -> GetBrowserContextsBuilder {
216 GetBrowserContextsBuilder
217 }
218}
219impl CreateTarget {
220 pub fn builder() -> CreateTargetBuilder {
221 <CreateTargetBuilder as Default>::default()
222 }
223}
224#[derive(Default, Clone)]
225pub struct CreateTargetBuilder {
226 url: Option<String>,
227 left: Option<i64>,
228 top: Option<i64>,
229 width: Option<i64>,
230 height: Option<i64>,
231 window_state: Option<super::types::WindowState>,
232 browser_context_id: Option<crate::browser_protocol::browser::types::BrowserContextId>,
233 enable_begin_frame_control: Option<bool>,
234 new_window: Option<bool>,
235 background: Option<bool>,
236 for_tab: Option<bool>,
237 hidden: Option<bool>,
238 focus: Option<bool>,
239}
240impl CreateTargetBuilder {
241 pub fn url(mut self, url: impl Into<String>) -> Self {
242 self.url = Some(url.into());
243 self
244 }
245 pub fn left(mut self, left: impl Into<i64>) -> Self {
246 self.left = Some(left.into());
247 self
248 }
249 pub fn top(mut self, top: impl Into<i64>) -> Self {
250 self.top = Some(top.into());
251 self
252 }
253 pub fn width(mut self, width: impl Into<i64>) -> Self {
254 self.width = Some(width.into());
255 self
256 }
257 pub fn height(mut self, height: impl Into<i64>) -> Self {
258 self.height = Some(height.into());
259 self
260 }
261 pub fn window_state(mut self, window_state: impl Into<super::types::WindowState>) -> Self {
262 self.window_state = Some(window_state.into());
263 self
264 }
265 pub fn browser_context_id(
266 mut self,
267 browser_context_id: impl Into<crate::browser_protocol::browser::types::BrowserContextId>,
268 ) -> Self {
269 self.browser_context_id = Some(browser_context_id.into());
270 self
271 }
272 pub fn enable_begin_frame_control(
273 mut self,
274 enable_begin_frame_control: impl Into<bool>,
275 ) -> Self {
276 self.enable_begin_frame_control = Some(enable_begin_frame_control.into());
277 self
278 }
279 pub fn new_window(mut self, new_window: impl Into<bool>) -> Self {
280 self.new_window = Some(new_window.into());
281 self
282 }
283 pub fn background(mut self, background: impl Into<bool>) -> Self {
284 self.background = Some(background.into());
285 self
286 }
287 pub fn for_tab(mut self, for_tab: impl Into<bool>) -> Self {
288 self.for_tab = Some(for_tab.into());
289 self
290 }
291 pub fn hidden(mut self, hidden: impl Into<bool>) -> Self {
292 self.hidden = Some(hidden.into());
293 self
294 }
295 pub fn focus(mut self, focus: impl Into<bool>) -> Self {
296 self.focus = Some(focus.into());
297 self
298 }
299 pub fn build(self) -> Result<CreateTarget, String> {
300 Ok(CreateTarget {
301 method: CreateTargetMethod::CreateTarget,
302 params: CreateTargetParams {
303 url: self
304 .url
305 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(url)))?,
306 left: self.left,
307 top: self.top,
308 width: self.width,
309 height: self.height,
310 window_state: self.window_state,
311 browser_context_id: self.browser_context_id,
312 enable_begin_frame_control: self.enable_begin_frame_control,
313 new_window: self.new_window,
314 background: self.background,
315 for_tab: self.for_tab,
316 hidden: self.hidden,
317 focus: self.focus,
318 },
319 })
320 }
321}
322impl DetachFromTarget {
323 pub fn builder() -> DetachFromTargetBuilder {
324 <DetachFromTargetBuilder as Default>::default()
325 }
326}
327#[derive(Default, Clone)]
328pub struct DetachFromTargetBuilder {
329 session_id: Option<super::types::SessionId>,
330}
331impl DetachFromTargetBuilder {
332 pub fn session_id(mut self, session_id: impl Into<super::types::SessionId>) -> Self {
333 self.session_id = Some(session_id.into());
334 self
335 }
336 pub fn build(self) -> DetachFromTarget {
337 DetachFromTarget {
338 method: DetachFromTargetMethod::DetachFromTarget,
339 params: DetachFromTargetParams {
340 session_id: self.session_id,
341 },
342 }
343 }
344}
345impl DisposeBrowserContext {
346 pub fn builder() -> DisposeBrowserContextBuilder {
347 <DisposeBrowserContextBuilder as Default>::default()
348 }
349}
350#[derive(Default, Clone)]
351pub struct DisposeBrowserContextBuilder {
352 browser_context_id: Option<crate::browser_protocol::browser::types::BrowserContextId>,
353}
354impl DisposeBrowserContextBuilder {
355 pub fn browser_context_id(
356 mut self,
357 browser_context_id: impl Into<crate::browser_protocol::browser::types::BrowserContextId>,
358 ) -> Self {
359 self.browser_context_id = Some(browser_context_id.into());
360 self
361 }
362 pub fn build(self) -> Result<DisposeBrowserContext, String> {
363 Ok(DisposeBrowserContext {
364 method: DisposeBrowserContextMethod::DisposeBrowserContext,
365 params: DisposeBrowserContextParams {
366 browser_context_id: self.browser_context_id.ok_or_else(|| {
367 format!(
368 "Field `{}` is mandatory.",
369 std::stringify!(browser_context_id)
370 )
371 })?,
372 },
373 })
374 }
375}
376impl GetTargetInfo {
377 pub fn builder() -> GetTargetInfoBuilder {
378 <GetTargetInfoBuilder as Default>::default()
379 }
380}
381#[derive(Default, Clone)]
382pub struct GetTargetInfoBuilder {
383 target_id: Option<super::types::TargetId>,
384}
385impl GetTargetInfoBuilder {
386 pub fn target_id(mut self, target_id: impl Into<super::types::TargetId>) -> Self {
387 self.target_id = Some(target_id.into());
388 self
389 }
390 pub fn build(self) -> GetTargetInfo {
391 GetTargetInfo {
392 method: GetTargetInfoMethod::GetTargetInfo,
393 params: GetTargetInfoParams {
394 target_id: self.target_id,
395 },
396 }
397 }
398}
399impl GetTargets {
400 pub fn builder() -> GetTargetsBuilder {
401 <GetTargetsBuilder as Default>::default()
402 }
403}
404#[derive(Default, Clone)]
405pub struct GetTargetsBuilder {
406 filter: Option<super::types::TargetFilter>,
407}
408impl GetTargetsBuilder {
409 pub fn filter(mut self, filter: impl Into<super::types::TargetFilter>) -> Self {
410 self.filter = Some(filter.into());
411 self
412 }
413 pub fn build(self) -> GetTargets {
414 GetTargets {
415 method: GetTargetsMethod::GetTargets,
416 params: GetTargetsParams {
417 filter: self.filter,
418 },
419 }
420 }
421}
422impl SetAutoAttach {
423 pub fn builder() -> SetAutoAttachBuilder {
424 <SetAutoAttachBuilder as Default>::default()
425 }
426}
427#[derive(Default, Clone)]
428pub struct SetAutoAttachBuilder {
429 auto_attach: Option<bool>,
430 wait_for_debugger_on_start: Option<bool>,
431 flatten: Option<bool>,
432 filter: Option<super::types::TargetFilter>,
433}
434impl SetAutoAttachBuilder {
435 pub fn auto_attach(mut self, auto_attach: impl Into<bool>) -> Self {
436 self.auto_attach = Some(auto_attach.into());
437 self
438 }
439 pub fn wait_for_debugger_on_start(
440 mut self,
441 wait_for_debugger_on_start: impl Into<bool>,
442 ) -> Self {
443 self.wait_for_debugger_on_start = Some(wait_for_debugger_on_start.into());
444 self
445 }
446 pub fn flatten(mut self, flatten: impl Into<bool>) -> Self {
447 self.flatten = Some(flatten.into());
448 self
449 }
450 pub fn filter(mut self, filter: impl Into<super::types::TargetFilter>) -> Self {
451 self.filter = Some(filter.into());
452 self
453 }
454 pub fn build(self) -> Result<SetAutoAttach, String> {
455 Ok(SetAutoAttach {
456 method: SetAutoAttachMethod::SetAutoAttach,
457 params: SetAutoAttachParams {
458 auto_attach: self.auto_attach.ok_or_else(|| {
459 format!("Field `{}` is mandatory.", std::stringify!(auto_attach))
460 })?,
461 wait_for_debugger_on_start: self.wait_for_debugger_on_start.ok_or_else(|| {
462 format!(
463 "Field `{}` is mandatory.",
464 std::stringify!(wait_for_debugger_on_start)
465 )
466 })?,
467 flatten: self.flatten,
468 filter: self.filter,
469 },
470 })
471 }
472}
473impl AutoAttachRelated {
474 pub fn builder() -> AutoAttachRelatedBuilder {
475 <AutoAttachRelatedBuilder as Default>::default()
476 }
477}
478#[derive(Default, Clone)]
479pub struct AutoAttachRelatedBuilder {
480 target_id: Option<super::types::TargetId>,
481 wait_for_debugger_on_start: Option<bool>,
482 filter: Option<super::types::TargetFilter>,
483}
484impl AutoAttachRelatedBuilder {
485 pub fn target_id(mut self, target_id: impl Into<super::types::TargetId>) -> Self {
486 self.target_id = Some(target_id.into());
487 self
488 }
489 pub fn wait_for_debugger_on_start(
490 mut self,
491 wait_for_debugger_on_start: impl Into<bool>,
492 ) -> Self {
493 self.wait_for_debugger_on_start = Some(wait_for_debugger_on_start.into());
494 self
495 }
496 pub fn filter(mut self, filter: impl Into<super::types::TargetFilter>) -> Self {
497 self.filter = Some(filter.into());
498 self
499 }
500 pub fn build(self) -> Result<AutoAttachRelated, String> {
501 Ok(AutoAttachRelated {
502 method: AutoAttachRelatedMethod::AutoAttachRelated,
503 params: AutoAttachRelatedParams {
504 target_id: self.target_id.ok_or_else(|| {
505 format!("Field `{}` is mandatory.", std::stringify!(target_id))
506 })?,
507 wait_for_debugger_on_start: self.wait_for_debugger_on_start.ok_or_else(|| {
508 format!(
509 "Field `{}` is mandatory.",
510 std::stringify!(wait_for_debugger_on_start)
511 )
512 })?,
513 filter: self.filter,
514 },
515 })
516 }
517}
518impl SetDiscoverTargets {
519 pub fn builder() -> SetDiscoverTargetsBuilder {
520 <SetDiscoverTargetsBuilder as Default>::default()
521 }
522}
523#[derive(Default, Clone)]
524pub struct SetDiscoverTargetsBuilder {
525 discover: Option<bool>,
526 filter: Option<super::types::TargetFilter>,
527}
528impl SetDiscoverTargetsBuilder {
529 pub fn discover(mut self, discover: impl Into<bool>) -> Self {
530 self.discover = Some(discover.into());
531 self
532 }
533 pub fn filter(mut self, filter: impl Into<super::types::TargetFilter>) -> Self {
534 self.filter = Some(filter.into());
535 self
536 }
537 pub fn build(self) -> Result<SetDiscoverTargets, String> {
538 Ok(SetDiscoverTargets {
539 method: SetDiscoverTargetsMethod::SetDiscoverTargets,
540 params: SetDiscoverTargetsParams {
541 discover: self.discover.ok_or_else(|| {
542 format!("Field `{}` is mandatory.", std::stringify!(discover))
543 })?,
544 filter: self.filter,
545 },
546 })
547 }
548}
549impl SetRemoteLocations {
550 pub fn builder() -> SetRemoteLocationsBuilder {
551 <SetRemoteLocationsBuilder as Default>::default()
552 }
553}
554#[derive(Default, Clone)]
555pub struct SetRemoteLocationsBuilder {
556 locations: Option<Vec<super::types::RemoteLocation>>,
557}
558impl SetRemoteLocationsBuilder {
559 pub fn location(mut self, location: impl Into<super::types::RemoteLocation>) -> Self {
560 let v = self.locations.get_or_insert(Vec::new());
561 v.push(location.into());
562 self
563 }
564 pub fn locations<I, S>(mut self, locations: I) -> Self
565 where
566 I: IntoIterator<Item = S>,
567 S: Into<super::types::RemoteLocation>,
568 {
569 let v = self.locations.get_or_insert(Vec::new());
570 for val in locations {
571 v.push(val.into());
572 }
573 self
574 }
575 pub fn build(self) -> Result<SetRemoteLocations, String> {
576 Ok(SetRemoteLocations {
577 method: SetRemoteLocationsMethod::SetRemoteLocations,
578 params: SetRemoteLocationsParams {
579 locations: self.locations.ok_or_else(|| {
580 format!("Field `{}` is mandatory.", std::stringify!(locations))
581 })?,
582 },
583 })
584 }
585}
586impl GetDevToolsTarget {
587 pub fn builder() -> GetDevToolsTargetBuilder {
588 <GetDevToolsTargetBuilder as Default>::default()
589 }
590}
591#[derive(Default, Clone)]
592pub struct GetDevToolsTargetBuilder {
593 target_id: Option<super::types::TargetId>,
594}
595impl GetDevToolsTargetBuilder {
596 pub fn target_id(mut self, target_id: impl Into<super::types::TargetId>) -> Self {
597 self.target_id = Some(target_id.into());
598 self
599 }
600 pub fn build(self) -> Result<GetDevToolsTarget, String> {
601 Ok(GetDevToolsTarget {
602 method: GetDevToolsTargetMethod::GetDevToolsTarget,
603 params: GetDevToolsTargetParams {
604 target_id: self.target_id.ok_or_else(|| {
605 format!("Field `{}` is mandatory.", std::stringify!(target_id))
606 })?,
607 },
608 })
609 }
610}
611impl OpenDevTools {
612 pub fn builder() -> OpenDevToolsBuilder {
613 <OpenDevToolsBuilder as Default>::default()
614 }
615}
616#[derive(Default, Clone)]
617pub struct OpenDevToolsBuilder {
618 target_id: Option<super::types::TargetId>,
619 panel_id: Option<String>,
620}
621impl OpenDevToolsBuilder {
622 pub fn target_id(mut self, target_id: impl Into<super::types::TargetId>) -> Self {
623 self.target_id = Some(target_id.into());
624 self
625 }
626 pub fn panel_id(mut self, panel_id: impl Into<String>) -> Self {
627 self.panel_id = Some(panel_id.into());
628 self
629 }
630 pub fn build(self) -> Result<OpenDevTools, String> {
631 Ok(OpenDevTools {
632 method: OpenDevToolsMethod::OpenDevTools,
633 params: OpenDevToolsParams {
634 target_id: self.target_id.ok_or_else(|| {
635 format!("Field `{}` is mandatory.", std::stringify!(target_id))
636 })?,
637 panel_id: self.panel_id,
638 },
639 })
640 }
641}