Skip to main content

browser_protocol/target/
mod.rs

1//! Supports additional targets discovery and allows to attach to them.
2
3
4use serde::{Serialize, Deserialize};
5use serde_json::Value as JsonValue;
6use std::borrow::Cow;
7
8
9pub type TargetID<'a> = Cow<'a, str>;
10
11/// Unique identifier of attached debugging session.
12
13pub type SessionID<'a> = Cow<'a, str>;
14
15
16#[derive(Debug, Clone, Serialize, Deserialize, Default)]
17#[serde(rename_all = "camelCase")]
18pub struct TargetInfo<'a> {
19    #[serde(rename = "targetId")]
20    target_id: TargetID<'a>,
21    /// List of types: <https://source.chromium.org/chromium/chromium/src/+/main:content/browser/devtools/devtools_agent_host_impl.cc?ss=chromium&q=f:devtools%20-f:out%20%22::kTypeTab%5B%5D%22>
22    #[serde(rename = "type")]
23    type_: Cow<'a, str>,
24    title: Cow<'a, str>,
25    url: Cow<'a, str>,
26    /// Whether the target has an attached client.
27    attached: bool,
28    /// Id of the parent target, if any. For example, "iframe" target may have a "page" parent.
29    #[serde(skip_serializing_if = "Option::is_none", rename = "parentId")]
30    parent_id: Option<TargetID<'a>>,
31    /// Opener target Id
32    #[serde(skip_serializing_if = "Option::is_none", rename = "openerId")]
33    opener_id: Option<TargetID<'a>>,
34    /// Whether the target has access to the originating window.
35    #[serde(rename = "canAccessOpener")]
36    can_access_opener: bool,
37    /// Frame id of originating window (is only set if target has an opener).
38    #[serde(skip_serializing_if = "Option::is_none", rename = "openerFrameId")]
39    opener_frame_id: Option<crate::page::FrameId<'a>>,
40    /// Id of the parent frame, present for "iframe" and "worker" targets. For nested workers,
41    /// this is the "ancestor" frame that created the first worker in the nested chain.
42    #[serde(skip_serializing_if = "Option::is_none", rename = "parentFrameId")]
43    parent_frame_id: Option<crate::page::FrameId<'a>>,
44    #[serde(skip_serializing_if = "Option::is_none", rename = "browserContextId")]
45    browser_context_id: Option<crate::browser::BrowserContextID<'a>>,
46    /// Provides additional details for specific target types. For example, for
47    /// the type of "page", this may be set to "prerender".
48    #[serde(skip_serializing_if = "Option::is_none")]
49    subtype: Option<Cow<'a, str>>,
50}
51
52impl<'a> TargetInfo<'a> {
53    /// Creates a builder for this type with the required parameters:
54    /// * `target_id`: 
55    /// * `type_`: List of types: <https://source.chromium.org/chromium/chromium/src/+/main:content/browser/devtools/devtools_agent_host_impl.cc?ss=chromium&q=f:devtools%20-f:out%20%22::kTypeTab%5B%5D%22>
56    /// * `title`: 
57    /// * `url`: 
58    /// * `attached`: Whether the target has an attached client.
59    /// * `can_access_opener`: Whether the target has access to the originating window.
60    pub fn builder(target_id: impl Into<TargetID<'a>>, type_: impl Into<Cow<'a, str>>, title: impl Into<Cow<'a, str>>, url: impl Into<Cow<'a, str>>, attached: bool, can_access_opener: bool) -> TargetInfoBuilder<'a> {
61        TargetInfoBuilder {
62            target_id: target_id.into(),
63            type_: type_.into(),
64            title: title.into(),
65            url: url.into(),
66            attached: attached,
67            parent_id: None,
68            opener_id: None,
69            can_access_opener: can_access_opener,
70            opener_frame_id: None,
71            parent_frame_id: None,
72            browser_context_id: None,
73            subtype: None,
74        }
75    }
76    pub fn target_id(&self) -> &TargetID<'a> { &self.target_id }
77    /// List of types: <https://source.chromium.org/chromium/chromium/src/+/main:content/browser/devtools/devtools_agent_host_impl.cc?ss=chromium&q=f:devtools%20-f:out%20%22::kTypeTab%5B%5D%22>
78    pub fn type_(&self) -> &str { self.type_.as_ref() }
79    pub fn title(&self) -> &str { self.title.as_ref() }
80    pub fn url(&self) -> &str { self.url.as_ref() }
81    /// Whether the target has an attached client.
82    pub fn attached(&self) -> bool { self.attached }
83    /// Id of the parent target, if any. For example, "iframe" target may have a "page" parent.
84    pub fn parent_id(&self) -> Option<&TargetID<'a>> { self.parent_id.as_ref() }
85    /// Opener target Id
86    pub fn opener_id(&self) -> Option<&TargetID<'a>> { self.opener_id.as_ref() }
87    /// Whether the target has access to the originating window.
88    pub fn can_access_opener(&self) -> bool { self.can_access_opener }
89    /// Frame id of originating window (is only set if target has an opener).
90    pub fn opener_frame_id(&self) -> Option<&crate::page::FrameId<'a>> { self.opener_frame_id.as_ref() }
91    /// Id of the parent frame, present for "iframe" and "worker" targets. For nested workers,
92    /// this is the "ancestor" frame that created the first worker in the nested chain.
93    pub fn parent_frame_id(&self) -> Option<&crate::page::FrameId<'a>> { self.parent_frame_id.as_ref() }
94    pub fn browser_context_id(&self) -> Option<&crate::browser::BrowserContextID<'a>> { self.browser_context_id.as_ref() }
95    /// Provides additional details for specific target types. For example, for
96    /// the type of "page", this may be set to "prerender".
97    pub fn subtype(&self) -> Option<&str> { self.subtype.as_deref() }
98}
99
100
101pub struct TargetInfoBuilder<'a> {
102    target_id: TargetID<'a>,
103    type_: Cow<'a, str>,
104    title: Cow<'a, str>,
105    url: Cow<'a, str>,
106    attached: bool,
107    parent_id: Option<TargetID<'a>>,
108    opener_id: Option<TargetID<'a>>,
109    can_access_opener: bool,
110    opener_frame_id: Option<crate::page::FrameId<'a>>,
111    parent_frame_id: Option<crate::page::FrameId<'a>>,
112    browser_context_id: Option<crate::browser::BrowserContextID<'a>>,
113    subtype: Option<Cow<'a, str>>,
114}
115
116impl<'a> TargetInfoBuilder<'a> {
117    /// Id of the parent target, if any. For example, "iframe" target may have a "page" parent.
118    pub fn parent_id(mut self, parent_id: impl Into<TargetID<'a>>) -> Self { self.parent_id = Some(parent_id.into()); self }
119    /// Opener target Id
120    pub fn opener_id(mut self, opener_id: impl Into<TargetID<'a>>) -> Self { self.opener_id = Some(opener_id.into()); self }
121    /// Frame id of originating window (is only set if target has an opener).
122    pub fn opener_frame_id(mut self, opener_frame_id: crate::page::FrameId<'a>) -> Self { self.opener_frame_id = Some(opener_frame_id); self }
123    /// Id of the parent frame, present for "iframe" and "worker" targets. For nested workers,
124    /// this is the "ancestor" frame that created the first worker in the nested chain.
125    pub fn parent_frame_id(mut self, parent_frame_id: crate::page::FrameId<'a>) -> Self { self.parent_frame_id = Some(parent_frame_id); self }
126    pub fn browser_context_id(mut self, browser_context_id: crate::browser::BrowserContextID<'a>) -> Self { self.browser_context_id = Some(browser_context_id); self }
127    /// Provides additional details for specific target types. For example, for
128    /// the type of "page", this may be set to "prerender".
129    pub fn subtype(mut self, subtype: impl Into<Cow<'a, str>>) -> Self { self.subtype = Some(subtype.into()); self }
130    pub fn build(self) -> TargetInfo<'a> {
131        TargetInfo {
132            target_id: self.target_id,
133            type_: self.type_,
134            title: self.title,
135            url: self.url,
136            attached: self.attached,
137            parent_id: self.parent_id,
138            opener_id: self.opener_id,
139            can_access_opener: self.can_access_opener,
140            opener_frame_id: self.opener_frame_id,
141            parent_frame_id: self.parent_frame_id,
142            browser_context_id: self.browser_context_id,
143            subtype: self.subtype,
144        }
145    }
146}
147
148/// A filter used by target query/discovery/auto-attach operations.
149
150#[derive(Debug, Clone, Serialize, Deserialize, Default)]
151#[serde(rename_all = "camelCase")]
152pub struct FilterEntry<'a> {
153    /// If set, causes exclusion of matching targets from the list.
154    #[serde(skip_serializing_if = "Option::is_none")]
155    exclude: Option<bool>,
156    /// If not present, matches any type.
157    #[serde(skip_serializing_if = "Option::is_none", rename = "type")]
158    type_: Option<Cow<'a, str>>,
159}
160
161impl<'a> FilterEntry<'a> {
162    /// Creates a builder for this type.
163    pub fn builder() -> FilterEntryBuilder<'a> {
164        FilterEntryBuilder {
165            exclude: None,
166            type_: None,
167        }
168    }
169    /// If set, causes exclusion of matching targets from the list.
170    pub fn exclude(&self) -> Option<bool> { self.exclude }
171    /// If not present, matches any type.
172    pub fn type_(&self) -> Option<&str> { self.type_.as_deref() }
173}
174
175#[derive(Default)]
176pub struct FilterEntryBuilder<'a> {
177    exclude: Option<bool>,
178    type_: Option<Cow<'a, str>>,
179}
180
181impl<'a> FilterEntryBuilder<'a> {
182    /// If set, causes exclusion of matching targets from the list.
183    pub fn exclude(mut self, exclude: bool) -> Self { self.exclude = Some(exclude); self }
184    /// If not present, matches any type.
185    pub fn type_(mut self, type_: impl Into<Cow<'a, str>>) -> Self { self.type_ = Some(type_.into()); self }
186    pub fn build(self) -> FilterEntry<'a> {
187        FilterEntry {
188            exclude: self.exclude,
189            type_: self.type_,
190        }
191    }
192}
193
194/// The entries in TargetFilter are matched sequentially against targets and
195/// the first entry that matches determines if the target is included or not,
196/// depending on the value of 'exclude' field in the entry.
197/// If filter is not specified, the one assumed is
198/// \[{type: "browser", exclude: true}, {type: "tab", exclude: true}, {}\]
199/// (i.e. include everything but 'browser' and 'tab').
200
201pub type TargetFilter<'a> = Vec<FilterEntry<'a>>;
202
203
204#[derive(Debug, Clone, Serialize, Deserialize, Default)]
205#[serde(rename_all = "camelCase")]
206pub struct RemoteLocation<'a> {
207    host: Cow<'a, str>,
208    port: i64,
209}
210
211impl<'a> RemoteLocation<'a> {
212    /// Creates a builder for this type with the required parameters:
213    /// * `host`: 
214    /// * `port`: 
215    pub fn builder(host: impl Into<Cow<'a, str>>, port: i64) -> RemoteLocationBuilder<'a> {
216        RemoteLocationBuilder {
217            host: host.into(),
218            port: port,
219        }
220    }
221    pub fn host(&self) -> &str { self.host.as_ref() }
222    pub fn port(&self) -> i64 { self.port }
223}
224
225
226pub struct RemoteLocationBuilder<'a> {
227    host: Cow<'a, str>,
228    port: i64,
229}
230
231impl<'a> RemoteLocationBuilder<'a> {
232    pub fn build(self) -> RemoteLocation<'a> {
233        RemoteLocation {
234            host: self.host,
235            port: self.port,
236        }
237    }
238}
239
240/// The state of the target window.
241
242#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
243pub enum WindowState {
244    #[default]
245    #[serde(rename = "normal")]
246    Normal,
247    #[serde(rename = "minimized")]
248    Minimized,
249    #[serde(rename = "maximized")]
250    Maximized,
251    #[serde(rename = "fullscreen")]
252    Fullscreen,
253}
254
255/// Activates (focuses) the target.
256
257#[derive(Debug, Clone, Serialize, Deserialize, Default)]
258#[serde(rename_all = "camelCase")]
259pub struct ActivateTargetParams<'a> {
260    #[serde(rename = "targetId")]
261    target_id: TargetID<'a>,
262}
263
264impl<'a> ActivateTargetParams<'a> {
265    /// Creates a builder for this type with the required parameters:
266    /// * `target_id`: 
267    pub fn builder(target_id: impl Into<TargetID<'a>>) -> ActivateTargetParamsBuilder<'a> {
268        ActivateTargetParamsBuilder {
269            target_id: target_id.into(),
270        }
271    }
272    pub fn target_id(&self) -> &TargetID<'a> { &self.target_id }
273}
274
275
276pub struct ActivateTargetParamsBuilder<'a> {
277    target_id: TargetID<'a>,
278}
279
280impl<'a> ActivateTargetParamsBuilder<'a> {
281    pub fn build(self) -> ActivateTargetParams<'a> {
282        ActivateTargetParams {
283            target_id: self.target_id,
284        }
285    }
286}
287
288impl<'a> ActivateTargetParams<'a> { pub const METHOD: &'static str = "Target.activateTarget"; }
289
290impl<'a> crate::CdpCommand<'a> for ActivateTargetParams<'a> {
291    const METHOD: &'static str = "Target.activateTarget";
292    type Response = crate::EmptyReturns;
293}
294
295/// Attaches to the target with given id.
296
297#[derive(Debug, Clone, Serialize, Deserialize, Default)]
298#[serde(rename_all = "camelCase")]
299pub struct AttachToTargetParams<'a> {
300    #[serde(rename = "targetId")]
301    target_id: TargetID<'a>,
302    /// Enables "flat" access to the session via specifying sessionId attribute in the commands.
303    /// We plan to make this the default, deprecate non-flattened mode,
304    /// and eventually retire it. See crbug.com/991325.
305    #[serde(skip_serializing_if = "Option::is_none")]
306    flatten: Option<bool>,
307}
308
309impl<'a> AttachToTargetParams<'a> {
310    /// Creates a builder for this type with the required parameters:
311    /// * `target_id`: 
312    pub fn builder(target_id: impl Into<TargetID<'a>>) -> AttachToTargetParamsBuilder<'a> {
313        AttachToTargetParamsBuilder {
314            target_id: target_id.into(),
315            flatten: None,
316        }
317    }
318    pub fn target_id(&self) -> &TargetID<'a> { &self.target_id }
319    /// Enables "flat" access to the session via specifying sessionId attribute in the commands.
320    /// We plan to make this the default, deprecate non-flattened mode,
321    /// and eventually retire it. See crbug.com/991325.
322    pub fn flatten(&self) -> Option<bool> { self.flatten }
323}
324
325
326pub struct AttachToTargetParamsBuilder<'a> {
327    target_id: TargetID<'a>,
328    flatten: Option<bool>,
329}
330
331impl<'a> AttachToTargetParamsBuilder<'a> {
332    /// Enables "flat" access to the session via specifying sessionId attribute in the commands.
333    /// We plan to make this the default, deprecate non-flattened mode,
334    /// and eventually retire it. See crbug.com/991325.
335    pub fn flatten(mut self, flatten: bool) -> Self { self.flatten = Some(flatten); self }
336    pub fn build(self) -> AttachToTargetParams<'a> {
337        AttachToTargetParams {
338            target_id: self.target_id,
339            flatten: self.flatten,
340        }
341    }
342}
343
344/// Attaches to the target with given id.
345
346#[derive(Debug, Clone, Serialize, Deserialize, Default)]
347#[serde(rename_all = "camelCase")]
348pub struct AttachToTargetReturns<'a> {
349    /// Id assigned to the session.
350    #[serde(rename = "sessionId")]
351    session_id: SessionID<'a>,
352}
353
354impl<'a> AttachToTargetReturns<'a> {
355    /// Creates a builder for this type with the required parameters:
356    /// * `session_id`: Id assigned to the session.
357    pub fn builder(session_id: impl Into<SessionID<'a>>) -> AttachToTargetReturnsBuilder<'a> {
358        AttachToTargetReturnsBuilder {
359            session_id: session_id.into(),
360        }
361    }
362    /// Id assigned to the session.
363    pub fn session_id(&self) -> &SessionID<'a> { &self.session_id }
364}
365
366
367pub struct AttachToTargetReturnsBuilder<'a> {
368    session_id: SessionID<'a>,
369}
370
371impl<'a> AttachToTargetReturnsBuilder<'a> {
372    pub fn build(self) -> AttachToTargetReturns<'a> {
373        AttachToTargetReturns {
374            session_id: self.session_id,
375        }
376    }
377}
378
379impl<'a> AttachToTargetParams<'a> { pub const METHOD: &'static str = "Target.attachToTarget"; }
380
381impl<'a> crate::CdpCommand<'a> for AttachToTargetParams<'a> {
382    const METHOD: &'static str = "Target.attachToTarget";
383    type Response = AttachToTargetReturns<'a>;
384}
385
386/// Attaches to the browser target, only uses flat sessionId mode.
387
388#[derive(Debug, Clone, Serialize, Deserialize, Default)]
389#[serde(rename_all = "camelCase")]
390pub struct AttachToBrowserTargetReturns<'a> {
391    /// Id assigned to the session.
392    #[serde(rename = "sessionId")]
393    session_id: SessionID<'a>,
394}
395
396impl<'a> AttachToBrowserTargetReturns<'a> {
397    /// Creates a builder for this type with the required parameters:
398    /// * `session_id`: Id assigned to the session.
399    pub fn builder(session_id: impl Into<SessionID<'a>>) -> AttachToBrowserTargetReturnsBuilder<'a> {
400        AttachToBrowserTargetReturnsBuilder {
401            session_id: session_id.into(),
402        }
403    }
404    /// Id assigned to the session.
405    pub fn session_id(&self) -> &SessionID<'a> { &self.session_id }
406}
407
408
409pub struct AttachToBrowserTargetReturnsBuilder<'a> {
410    session_id: SessionID<'a>,
411}
412
413impl<'a> AttachToBrowserTargetReturnsBuilder<'a> {
414    pub fn build(self) -> AttachToBrowserTargetReturns<'a> {
415        AttachToBrowserTargetReturns {
416            session_id: self.session_id,
417        }
418    }
419}
420
421#[derive(Debug, Clone, Serialize, Deserialize, Default)]
422pub struct AttachToBrowserTargetParams {}
423
424impl AttachToBrowserTargetParams { pub const METHOD: &'static str = "Target.attachToBrowserTarget"; }
425
426impl<'a> crate::CdpCommand<'a> for AttachToBrowserTargetParams {
427    const METHOD: &'static str = "Target.attachToBrowserTarget";
428    type Response = AttachToBrowserTargetReturns<'a>;
429}
430
431/// Closes the target. If the target is a page that gets closed too.
432
433#[derive(Debug, Clone, Serialize, Deserialize, Default)]
434#[serde(rename_all = "camelCase")]
435pub struct CloseTargetParams<'a> {
436    #[serde(rename = "targetId")]
437    target_id: TargetID<'a>,
438}
439
440impl<'a> CloseTargetParams<'a> {
441    /// Creates a builder for this type with the required parameters:
442    /// * `target_id`: 
443    pub fn builder(target_id: impl Into<TargetID<'a>>) -> CloseTargetParamsBuilder<'a> {
444        CloseTargetParamsBuilder {
445            target_id: target_id.into(),
446        }
447    }
448    pub fn target_id(&self) -> &TargetID<'a> { &self.target_id }
449}
450
451
452pub struct CloseTargetParamsBuilder<'a> {
453    target_id: TargetID<'a>,
454}
455
456impl<'a> CloseTargetParamsBuilder<'a> {
457    pub fn build(self) -> CloseTargetParams<'a> {
458        CloseTargetParams {
459            target_id: self.target_id,
460        }
461    }
462}
463
464/// Closes the target. If the target is a page that gets closed too.
465
466#[derive(Debug, Clone, Serialize, Deserialize, Default)]
467#[serde(rename_all = "camelCase")]
468pub struct CloseTargetReturns {
469    /// Always set to true. If an error occurs, the response indicates protocol error.
470    success: bool,
471}
472
473impl CloseTargetReturns {
474    /// Creates a builder for this type with the required parameters:
475    /// * `success`: Always set to true. If an error occurs, the response indicates protocol error.
476    pub fn builder(success: bool) -> CloseTargetReturnsBuilder {
477        CloseTargetReturnsBuilder {
478            success: success,
479        }
480    }
481    /// Always set to true. If an error occurs, the response indicates protocol error.
482    pub fn success(&self) -> bool { self.success }
483}
484
485
486pub struct CloseTargetReturnsBuilder {
487    success: bool,
488}
489
490impl CloseTargetReturnsBuilder {
491    pub fn build(self) -> CloseTargetReturns {
492        CloseTargetReturns {
493            success: self.success,
494        }
495    }
496}
497
498impl<'a> CloseTargetParams<'a> { pub const METHOD: &'static str = "Target.closeTarget"; }
499
500impl<'a> crate::CdpCommand<'a> for CloseTargetParams<'a> {
501    const METHOD: &'static str = "Target.closeTarget";
502    type Response = CloseTargetReturns;
503}
504
505/// Inject object to the target's main frame that provides a communication
506/// channel with browser target.
507/// 
508/// Injected object will be available as 'window\[bindingName\]'.
509/// 
510/// The object has the following API:
511/// - 'binding.send(json)' - a method to send messages over the remote debugging protocol
512/// - 'binding.onmessage = json =\> handleMessage(json)' - a callback that will be called for the protocol notifications and command responses.
513
514#[derive(Debug, Clone, Serialize, Deserialize, Default)]
515#[serde(rename_all = "camelCase")]
516pub struct ExposeDevToolsProtocolParams<'a> {
517    #[serde(rename = "targetId")]
518    target_id: TargetID<'a>,
519    /// Binding name, 'cdp' if not specified.
520    #[serde(skip_serializing_if = "Option::is_none", rename = "bindingName")]
521    binding_name: Option<Cow<'a, str>>,
522    /// If true, inherits the current root session's permissions (default: false).
523    #[serde(skip_serializing_if = "Option::is_none", rename = "inheritPermissions")]
524    inherit_permissions: Option<bool>,
525}
526
527impl<'a> ExposeDevToolsProtocolParams<'a> {
528    /// Creates a builder for this type with the required parameters:
529    /// * `target_id`: 
530    pub fn builder(target_id: impl Into<TargetID<'a>>) -> ExposeDevToolsProtocolParamsBuilder<'a> {
531        ExposeDevToolsProtocolParamsBuilder {
532            target_id: target_id.into(),
533            binding_name: None,
534            inherit_permissions: None,
535        }
536    }
537    pub fn target_id(&self) -> &TargetID<'a> { &self.target_id }
538    /// Binding name, 'cdp' if not specified.
539    pub fn binding_name(&self) -> Option<&str> { self.binding_name.as_deref() }
540    /// If true, inherits the current root session's permissions (default: false).
541    pub fn inherit_permissions(&self) -> Option<bool> { self.inherit_permissions }
542}
543
544
545pub struct ExposeDevToolsProtocolParamsBuilder<'a> {
546    target_id: TargetID<'a>,
547    binding_name: Option<Cow<'a, str>>,
548    inherit_permissions: Option<bool>,
549}
550
551impl<'a> ExposeDevToolsProtocolParamsBuilder<'a> {
552    /// Binding name, 'cdp' if not specified.
553    pub fn binding_name(mut self, binding_name: impl Into<Cow<'a, str>>) -> Self { self.binding_name = Some(binding_name.into()); self }
554    /// If true, inherits the current root session's permissions (default: false).
555    pub fn inherit_permissions(mut self, inherit_permissions: bool) -> Self { self.inherit_permissions = Some(inherit_permissions); self }
556    pub fn build(self) -> ExposeDevToolsProtocolParams<'a> {
557        ExposeDevToolsProtocolParams {
558            target_id: self.target_id,
559            binding_name: self.binding_name,
560            inherit_permissions: self.inherit_permissions,
561        }
562    }
563}
564
565impl<'a> ExposeDevToolsProtocolParams<'a> { pub const METHOD: &'static str = "Target.exposeDevToolsProtocol"; }
566
567impl<'a> crate::CdpCommand<'a> for ExposeDevToolsProtocolParams<'a> {
568    const METHOD: &'static str = "Target.exposeDevToolsProtocol";
569    type Response = crate::EmptyReturns;
570}
571
572/// Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than
573/// one.
574
575#[derive(Debug, Clone, Serialize, Deserialize, Default)]
576#[serde(rename_all = "camelCase")]
577pub struct CreateBrowserContextParams<'a> {
578    /// If specified, disposes this context when debugging session disconnects.
579    #[serde(skip_serializing_if = "Option::is_none", rename = "disposeOnDetach")]
580    dispose_on_detach: Option<bool>,
581    /// Proxy server, similar to the one passed to --proxy-server
582    #[serde(skip_serializing_if = "Option::is_none", rename = "proxyServer")]
583    proxy_server: Option<Cow<'a, str>>,
584    /// Proxy bypass list, similar to the one passed to --proxy-bypass-list
585    #[serde(skip_serializing_if = "Option::is_none", rename = "proxyBypassList")]
586    proxy_bypass_list: Option<Cow<'a, str>>,
587    /// An optional list of origins to grant unlimited cross-origin access to.
588    /// Parts of the URL other than those constituting origin are ignored.
589    #[serde(skip_serializing_if = "Option::is_none", rename = "originsWithUniversalNetworkAccess")]
590    origins_with_universal_network_access: Option<Vec<Cow<'a, str>>>,
591}
592
593impl<'a> CreateBrowserContextParams<'a> {
594    /// Creates a builder for this type.
595    pub fn builder() -> CreateBrowserContextParamsBuilder<'a> {
596        CreateBrowserContextParamsBuilder {
597            dispose_on_detach: None,
598            proxy_server: None,
599            proxy_bypass_list: None,
600            origins_with_universal_network_access: None,
601        }
602    }
603    /// If specified, disposes this context when debugging session disconnects.
604    pub fn dispose_on_detach(&self) -> Option<bool> { self.dispose_on_detach }
605    /// Proxy server, similar to the one passed to --proxy-server
606    pub fn proxy_server(&self) -> Option<&str> { self.proxy_server.as_deref() }
607    /// Proxy bypass list, similar to the one passed to --proxy-bypass-list
608    pub fn proxy_bypass_list(&self) -> Option<&str> { self.proxy_bypass_list.as_deref() }
609    /// An optional list of origins to grant unlimited cross-origin access to.
610    /// Parts of the URL other than those constituting origin are ignored.
611    pub fn origins_with_universal_network_access(&self) -> Option<&[Cow<'a, str>]> { self.origins_with_universal_network_access.as_deref() }
612}
613
614#[derive(Default)]
615pub struct CreateBrowserContextParamsBuilder<'a> {
616    dispose_on_detach: Option<bool>,
617    proxy_server: Option<Cow<'a, str>>,
618    proxy_bypass_list: Option<Cow<'a, str>>,
619    origins_with_universal_network_access: Option<Vec<Cow<'a, str>>>,
620}
621
622impl<'a> CreateBrowserContextParamsBuilder<'a> {
623    /// If specified, disposes this context when debugging session disconnects.
624    pub fn dispose_on_detach(mut self, dispose_on_detach: bool) -> Self { self.dispose_on_detach = Some(dispose_on_detach); self }
625    /// Proxy server, similar to the one passed to --proxy-server
626    pub fn proxy_server(mut self, proxy_server: impl Into<Cow<'a, str>>) -> Self { self.proxy_server = Some(proxy_server.into()); self }
627    /// Proxy bypass list, similar to the one passed to --proxy-bypass-list
628    pub fn proxy_bypass_list(mut self, proxy_bypass_list: impl Into<Cow<'a, str>>) -> Self { self.proxy_bypass_list = Some(proxy_bypass_list.into()); self }
629    /// An optional list of origins to grant unlimited cross-origin access to.
630    /// Parts of the URL other than those constituting origin are ignored.
631    pub fn origins_with_universal_network_access(mut self, origins_with_universal_network_access: Vec<Cow<'a, str>>) -> Self { self.origins_with_universal_network_access = Some(origins_with_universal_network_access); self }
632    pub fn build(self) -> CreateBrowserContextParams<'a> {
633        CreateBrowserContextParams {
634            dispose_on_detach: self.dispose_on_detach,
635            proxy_server: self.proxy_server,
636            proxy_bypass_list: self.proxy_bypass_list,
637            origins_with_universal_network_access: self.origins_with_universal_network_access,
638        }
639    }
640}
641
642/// Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than
643/// one.
644
645#[derive(Debug, Clone, Serialize, Deserialize, Default)]
646#[serde(rename_all = "camelCase")]
647pub struct CreateBrowserContextReturns<'a> {
648    /// The id of the context created.
649    #[serde(rename = "browserContextId")]
650    browser_context_id: crate::browser::BrowserContextID<'a>,
651}
652
653impl<'a> CreateBrowserContextReturns<'a> {
654    /// Creates a builder for this type with the required parameters:
655    /// * `browser_context_id`: The id of the context created.
656    pub fn builder(browser_context_id: crate::browser::BrowserContextID<'a>) -> CreateBrowserContextReturnsBuilder<'a> {
657        CreateBrowserContextReturnsBuilder {
658            browser_context_id: browser_context_id,
659        }
660    }
661    /// The id of the context created.
662    pub fn browser_context_id(&self) -> &crate::browser::BrowserContextID<'a> { &self.browser_context_id }
663}
664
665
666pub struct CreateBrowserContextReturnsBuilder<'a> {
667    browser_context_id: crate::browser::BrowserContextID<'a>,
668}
669
670impl<'a> CreateBrowserContextReturnsBuilder<'a> {
671    pub fn build(self) -> CreateBrowserContextReturns<'a> {
672        CreateBrowserContextReturns {
673            browser_context_id: self.browser_context_id,
674        }
675    }
676}
677
678impl<'a> CreateBrowserContextParams<'a> { pub const METHOD: &'static str = "Target.createBrowserContext"; }
679
680impl<'a> crate::CdpCommand<'a> for CreateBrowserContextParams<'a> {
681    const METHOD: &'static str = "Target.createBrowserContext";
682    type Response = CreateBrowserContextReturns<'a>;
683}
684
685/// Returns all browser contexts created with 'Target.createBrowserContext' method.
686
687#[derive(Debug, Clone, Serialize, Deserialize, Default)]
688#[serde(rename_all = "camelCase")]
689pub struct GetBrowserContextsReturns<'a> {
690    /// An array of browser context ids.
691    #[serde(rename = "browserContextIds")]
692    browser_context_ids: Vec<crate::browser::BrowserContextID<'a>>,
693    /// The id of the default browser context if available.
694    #[serde(skip_serializing_if = "Option::is_none", rename = "defaultBrowserContextId")]
695    default_browser_context_id: Option<crate::browser::BrowserContextID<'a>>,
696}
697
698impl<'a> GetBrowserContextsReturns<'a> {
699    /// Creates a builder for this type with the required parameters:
700    /// * `browser_context_ids`: An array of browser context ids.
701    pub fn builder(browser_context_ids: Vec<crate::browser::BrowserContextID<'a>>) -> GetBrowserContextsReturnsBuilder<'a> {
702        GetBrowserContextsReturnsBuilder {
703            browser_context_ids: browser_context_ids,
704            default_browser_context_id: None,
705        }
706    }
707    /// An array of browser context ids.
708    pub fn browser_context_ids(&self) -> &[crate::browser::BrowserContextID<'a>] { &self.browser_context_ids }
709    /// The id of the default browser context if available.
710    pub fn default_browser_context_id(&self) -> Option<&crate::browser::BrowserContextID<'a>> { self.default_browser_context_id.as_ref() }
711}
712
713
714pub struct GetBrowserContextsReturnsBuilder<'a> {
715    browser_context_ids: Vec<crate::browser::BrowserContextID<'a>>,
716    default_browser_context_id: Option<crate::browser::BrowserContextID<'a>>,
717}
718
719impl<'a> GetBrowserContextsReturnsBuilder<'a> {
720    /// The id of the default browser context if available.
721    pub fn default_browser_context_id(mut self, default_browser_context_id: crate::browser::BrowserContextID<'a>) -> Self { self.default_browser_context_id = Some(default_browser_context_id); self }
722    pub fn build(self) -> GetBrowserContextsReturns<'a> {
723        GetBrowserContextsReturns {
724            browser_context_ids: self.browser_context_ids,
725            default_browser_context_id: self.default_browser_context_id,
726        }
727    }
728}
729
730#[derive(Debug, Clone, Serialize, Deserialize, Default)]
731pub struct GetBrowserContextsParams {}
732
733impl GetBrowserContextsParams { pub const METHOD: &'static str = "Target.getBrowserContexts"; }
734
735impl<'a> crate::CdpCommand<'a> for GetBrowserContextsParams {
736    const METHOD: &'static str = "Target.getBrowserContexts";
737    type Response = GetBrowserContextsReturns<'a>;
738}
739
740/// Creates a new page.
741
742#[derive(Debug, Clone, Serialize, Deserialize, Default)]
743#[serde(rename_all = "camelCase")]
744pub struct CreateTargetParams<'a> {
745    /// The initial URL the page will be navigated to. An empty string indicates about:blank.
746    url: Cow<'a, str>,
747    /// Frame left origin in DIP (requires newWindow to be true or headless shell).
748    #[serde(skip_serializing_if = "Option::is_none")]
749    left: Option<i64>,
750    /// Frame top origin in DIP (requires newWindow to be true or headless shell).
751    #[serde(skip_serializing_if = "Option::is_none")]
752    top: Option<i64>,
753    /// Frame width in DIP (requires newWindow to be true or headless shell).
754    #[serde(skip_serializing_if = "Option::is_none")]
755    width: Option<u64>,
756    /// Frame height in DIP (requires newWindow to be true or headless shell).
757    #[serde(skip_serializing_if = "Option::is_none")]
758    height: Option<i64>,
759    /// Frame window state (requires newWindow to be true or headless shell).
760    /// Default is normal.
761    #[serde(skip_serializing_if = "Option::is_none", rename = "windowState")]
762    window_state: Option<WindowState>,
763    /// The browser context to create the page in.
764    #[serde(skip_serializing_if = "Option::is_none", rename = "browserContextId")]
765    browser_context_id: Option<crate::browser::BrowserContextID<'a>>,
766    /// Whether BeginFrames for this target will be controlled via DevTools (headless shell only,
767    /// not supported on MacOS yet, false by default).
768    #[serde(skip_serializing_if = "Option::is_none", rename = "enableBeginFrameControl")]
769    enable_begin_frame_control: Option<bool>,
770    /// Whether to create a new Window or Tab (false by default, not supported by headless shell).
771    #[serde(skip_serializing_if = "Option::is_none", rename = "newWindow")]
772    new_window: Option<bool>,
773    /// Whether to create the target in background or foreground (false by default, not supported
774    /// by headless shell).
775    #[serde(skip_serializing_if = "Option::is_none")]
776    background: Option<bool>,
777    /// Whether to create the target of type "tab".
778    #[serde(skip_serializing_if = "Option::is_none", rename = "forTab")]
779    for_tab: Option<bool>,
780    /// Whether to create a hidden target. The hidden target is observable via protocol, but not
781    /// present in the tab UI strip. Cannot be created with 'forTab: true', 'newWindow: true' or
782    /// 'background: false'. The life-time of the tab is limited to the life-time of the session.
783    #[serde(skip_serializing_if = "Option::is_none")]
784    hidden: Option<bool>,
785    /// If specified, the option is used to determine if the new target should
786    /// be focused or not. By default, the focus behavior depends on the
787    /// value of the background field. For example, background=false and focus=false
788    /// will result in the target tab being opened but the browser window remain
789    /// unchanged (if it was in the background, it will remain in the background)
790    /// and background=false with focus=undefined will result in the window being focused.
791    /// Using background: true and focus: true is not supported and will result in an error.
792    #[serde(skip_serializing_if = "Option::is_none")]
793    focus: Option<bool>,
794}
795
796impl<'a> CreateTargetParams<'a> {
797    /// Creates a builder for this type with the required parameters:
798    /// * `url`: The initial URL the page will be navigated to. An empty string indicates about:blank.
799    pub fn builder(url: impl Into<Cow<'a, str>>) -> CreateTargetParamsBuilder<'a> {
800        CreateTargetParamsBuilder {
801            url: url.into(),
802            left: None,
803            top: None,
804            width: None,
805            height: None,
806            window_state: None,
807            browser_context_id: None,
808            enable_begin_frame_control: None,
809            new_window: None,
810            background: None,
811            for_tab: None,
812            hidden: None,
813            focus: None,
814        }
815    }
816    /// The initial URL the page will be navigated to. An empty string indicates about:blank.
817    pub fn url(&self) -> &str { self.url.as_ref() }
818    /// Frame left origin in DIP (requires newWindow to be true or headless shell).
819    pub fn left(&self) -> Option<i64> { self.left }
820    /// Frame top origin in DIP (requires newWindow to be true or headless shell).
821    pub fn top(&self) -> Option<i64> { self.top }
822    /// Frame width in DIP (requires newWindow to be true or headless shell).
823    pub fn width(&self) -> Option<u64> { self.width }
824    /// Frame height in DIP (requires newWindow to be true or headless shell).
825    pub fn height(&self) -> Option<i64> { self.height }
826    /// Frame window state (requires newWindow to be true or headless shell).
827    /// Default is normal.
828    pub fn window_state(&self) -> Option<&WindowState> { self.window_state.as_ref() }
829    /// The browser context to create the page in.
830    pub fn browser_context_id(&self) -> Option<&crate::browser::BrowserContextID<'a>> { self.browser_context_id.as_ref() }
831    /// Whether BeginFrames for this target will be controlled via DevTools (headless shell only,
832    /// not supported on MacOS yet, false by default).
833    pub fn enable_begin_frame_control(&self) -> Option<bool> { self.enable_begin_frame_control }
834    /// Whether to create a new Window or Tab (false by default, not supported by headless shell).
835    pub fn new_window(&self) -> Option<bool> { self.new_window }
836    /// Whether to create the target in background or foreground (false by default, not supported
837    /// by headless shell).
838    pub fn background(&self) -> Option<bool> { self.background }
839    /// Whether to create the target of type "tab".
840    pub fn for_tab(&self) -> Option<bool> { self.for_tab }
841    /// Whether to create a hidden target. The hidden target is observable via protocol, but not
842    /// present in the tab UI strip. Cannot be created with 'forTab: true', 'newWindow: true' or
843    /// 'background: false'. The life-time of the tab is limited to the life-time of the session.
844    pub fn hidden(&self) -> Option<bool> { self.hidden }
845    /// If specified, the option is used to determine if the new target should
846    /// be focused or not. By default, the focus behavior depends on the
847    /// value of the background field. For example, background=false and focus=false
848    /// will result in the target tab being opened but the browser window remain
849    /// unchanged (if it was in the background, it will remain in the background)
850    /// and background=false with focus=undefined will result in the window being focused.
851    /// Using background: true and focus: true is not supported and will result in an error.
852    pub fn focus(&self) -> Option<bool> { self.focus }
853}
854
855
856pub struct CreateTargetParamsBuilder<'a> {
857    url: Cow<'a, str>,
858    left: Option<i64>,
859    top: Option<i64>,
860    width: Option<u64>,
861    height: Option<i64>,
862    window_state: Option<WindowState>,
863    browser_context_id: Option<crate::browser::BrowserContextID<'a>>,
864    enable_begin_frame_control: Option<bool>,
865    new_window: Option<bool>,
866    background: Option<bool>,
867    for_tab: Option<bool>,
868    hidden: Option<bool>,
869    focus: Option<bool>,
870}
871
872impl<'a> CreateTargetParamsBuilder<'a> {
873    /// Frame left origin in DIP (requires newWindow to be true or headless shell).
874    pub fn left(mut self, left: i64) -> Self { self.left = Some(left); self }
875    /// Frame top origin in DIP (requires newWindow to be true or headless shell).
876    pub fn top(mut self, top: i64) -> Self { self.top = Some(top); self }
877    /// Frame width in DIP (requires newWindow to be true or headless shell).
878    pub fn width(mut self, width: u64) -> Self { self.width = Some(width); self }
879    /// Frame height in DIP (requires newWindow to be true or headless shell).
880    pub fn height(mut self, height: i64) -> Self { self.height = Some(height); self }
881    /// Frame window state (requires newWindow to be true or headless shell).
882    /// Default is normal.
883    pub fn window_state(mut self, window_state: impl Into<WindowState>) -> Self { self.window_state = Some(window_state.into()); self }
884    /// The browser context to create the page in.
885    pub fn browser_context_id(mut self, browser_context_id: crate::browser::BrowserContextID<'a>) -> Self { self.browser_context_id = Some(browser_context_id); self }
886    /// Whether BeginFrames for this target will be controlled via DevTools (headless shell only,
887    /// not supported on MacOS yet, false by default).
888    pub fn enable_begin_frame_control(mut self, enable_begin_frame_control: bool) -> Self { self.enable_begin_frame_control = Some(enable_begin_frame_control); self }
889    /// Whether to create a new Window or Tab (false by default, not supported by headless shell).
890    pub fn new_window(mut self, new_window: bool) -> Self { self.new_window = Some(new_window); self }
891    /// Whether to create the target in background or foreground (false by default, not supported
892    /// by headless shell).
893    pub fn background(mut self, background: bool) -> Self { self.background = Some(background); self }
894    /// Whether to create the target of type "tab".
895    pub fn for_tab(mut self, for_tab: bool) -> Self { self.for_tab = Some(for_tab); self }
896    /// Whether to create a hidden target. The hidden target is observable via protocol, but not
897    /// present in the tab UI strip. Cannot be created with 'forTab: true', 'newWindow: true' or
898    /// 'background: false'. The life-time of the tab is limited to the life-time of the session.
899    pub fn hidden(mut self, hidden: bool) -> Self { self.hidden = Some(hidden); self }
900    /// If specified, the option is used to determine if the new target should
901    /// be focused or not. By default, the focus behavior depends on the
902    /// value of the background field. For example, background=false and focus=false
903    /// will result in the target tab being opened but the browser window remain
904    /// unchanged (if it was in the background, it will remain in the background)
905    /// and background=false with focus=undefined will result in the window being focused.
906    /// Using background: true and focus: true is not supported and will result in an error.
907    pub fn focus(mut self, focus: bool) -> Self { self.focus = Some(focus); self }
908    pub fn build(self) -> CreateTargetParams<'a> {
909        CreateTargetParams {
910            url: self.url,
911            left: self.left,
912            top: self.top,
913            width: self.width,
914            height: self.height,
915            window_state: self.window_state,
916            browser_context_id: self.browser_context_id,
917            enable_begin_frame_control: self.enable_begin_frame_control,
918            new_window: self.new_window,
919            background: self.background,
920            for_tab: self.for_tab,
921            hidden: self.hidden,
922            focus: self.focus,
923        }
924    }
925}
926
927/// Creates a new page.
928
929#[derive(Debug, Clone, Serialize, Deserialize, Default)]
930#[serde(rename_all = "camelCase")]
931pub struct CreateTargetReturns<'a> {
932    /// The id of the page opened.
933    #[serde(rename = "targetId")]
934    target_id: TargetID<'a>,
935}
936
937impl<'a> CreateTargetReturns<'a> {
938    /// Creates a builder for this type with the required parameters:
939    /// * `target_id`: The id of the page opened.
940    pub fn builder(target_id: impl Into<TargetID<'a>>) -> CreateTargetReturnsBuilder<'a> {
941        CreateTargetReturnsBuilder {
942            target_id: target_id.into(),
943        }
944    }
945    /// The id of the page opened.
946    pub fn target_id(&self) -> &TargetID<'a> { &self.target_id }
947}
948
949
950pub struct CreateTargetReturnsBuilder<'a> {
951    target_id: TargetID<'a>,
952}
953
954impl<'a> CreateTargetReturnsBuilder<'a> {
955    pub fn build(self) -> CreateTargetReturns<'a> {
956        CreateTargetReturns {
957            target_id: self.target_id,
958        }
959    }
960}
961
962impl<'a> CreateTargetParams<'a> { pub const METHOD: &'static str = "Target.createTarget"; }
963
964impl<'a> crate::CdpCommand<'a> for CreateTargetParams<'a> {
965    const METHOD: &'static str = "Target.createTarget";
966    type Response = CreateTargetReturns<'a>;
967}
968
969/// Detaches session with given id.
970
971#[derive(Debug, Clone, Serialize, Deserialize, Default)]
972#[serde(rename_all = "camelCase")]
973pub struct DetachFromTargetParams<'a> {
974    /// Session to detach.
975    #[serde(skip_serializing_if = "Option::is_none", rename = "sessionId")]
976    session_id: Option<SessionID<'a>>,
977    /// Deprecated.
978    #[serde(skip_serializing_if = "Option::is_none", rename = "targetId")]
979    target_id: Option<TargetID<'a>>,
980}
981
982impl<'a> DetachFromTargetParams<'a> {
983    /// Creates a builder for this type.
984    pub fn builder() -> DetachFromTargetParamsBuilder<'a> {
985        DetachFromTargetParamsBuilder {
986            session_id: None,
987            target_id: None,
988        }
989    }
990    /// Session to detach.
991    pub fn session_id(&self) -> Option<&SessionID<'a>> { self.session_id.as_ref() }
992    /// Deprecated.
993    pub fn target_id(&self) -> Option<&TargetID<'a>> { self.target_id.as_ref() }
994}
995
996#[derive(Default)]
997pub struct DetachFromTargetParamsBuilder<'a> {
998    session_id: Option<SessionID<'a>>,
999    target_id: Option<TargetID<'a>>,
1000}
1001
1002impl<'a> DetachFromTargetParamsBuilder<'a> {
1003    /// Session to detach.
1004    pub fn session_id(mut self, session_id: impl Into<SessionID<'a>>) -> Self { self.session_id = Some(session_id.into()); self }
1005    /// Deprecated.
1006    pub fn target_id(mut self, target_id: impl Into<TargetID<'a>>) -> Self { self.target_id = Some(target_id.into()); self }
1007    pub fn build(self) -> DetachFromTargetParams<'a> {
1008        DetachFromTargetParams {
1009            session_id: self.session_id,
1010            target_id: self.target_id,
1011        }
1012    }
1013}
1014
1015impl<'a> DetachFromTargetParams<'a> { pub const METHOD: &'static str = "Target.detachFromTarget"; }
1016
1017impl<'a> crate::CdpCommand<'a> for DetachFromTargetParams<'a> {
1018    const METHOD: &'static str = "Target.detachFromTarget";
1019    type Response = crate::EmptyReturns;
1020}
1021
1022/// Deletes a BrowserContext. All the belonging pages will be closed without calling their
1023/// beforeunload hooks.
1024
1025#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1026#[serde(rename_all = "camelCase")]
1027pub struct DisposeBrowserContextParams<'a> {
1028    #[serde(rename = "browserContextId")]
1029    browser_context_id: crate::browser::BrowserContextID<'a>,
1030}
1031
1032impl<'a> DisposeBrowserContextParams<'a> {
1033    /// Creates a builder for this type with the required parameters:
1034    /// * `browser_context_id`: 
1035    pub fn builder(browser_context_id: crate::browser::BrowserContextID<'a>) -> DisposeBrowserContextParamsBuilder<'a> {
1036        DisposeBrowserContextParamsBuilder {
1037            browser_context_id: browser_context_id,
1038        }
1039    }
1040    pub fn browser_context_id(&self) -> &crate::browser::BrowserContextID<'a> { &self.browser_context_id }
1041}
1042
1043
1044pub struct DisposeBrowserContextParamsBuilder<'a> {
1045    browser_context_id: crate::browser::BrowserContextID<'a>,
1046}
1047
1048impl<'a> DisposeBrowserContextParamsBuilder<'a> {
1049    pub fn build(self) -> DisposeBrowserContextParams<'a> {
1050        DisposeBrowserContextParams {
1051            browser_context_id: self.browser_context_id,
1052        }
1053    }
1054}
1055
1056impl<'a> DisposeBrowserContextParams<'a> { pub const METHOD: &'static str = "Target.disposeBrowserContext"; }
1057
1058impl<'a> crate::CdpCommand<'a> for DisposeBrowserContextParams<'a> {
1059    const METHOD: &'static str = "Target.disposeBrowserContext";
1060    type Response = crate::EmptyReturns;
1061}
1062
1063/// Returns information about a target.
1064
1065#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1066#[serde(rename_all = "camelCase")]
1067pub struct GetTargetInfoParams<'a> {
1068    #[serde(skip_serializing_if = "Option::is_none", rename = "targetId")]
1069    target_id: Option<TargetID<'a>>,
1070}
1071
1072impl<'a> GetTargetInfoParams<'a> {
1073    /// Creates a builder for this type.
1074    pub fn builder() -> GetTargetInfoParamsBuilder<'a> {
1075        GetTargetInfoParamsBuilder {
1076            target_id: None,
1077        }
1078    }
1079    pub fn target_id(&self) -> Option<&TargetID<'a>> { self.target_id.as_ref() }
1080}
1081
1082#[derive(Default)]
1083pub struct GetTargetInfoParamsBuilder<'a> {
1084    target_id: Option<TargetID<'a>>,
1085}
1086
1087impl<'a> GetTargetInfoParamsBuilder<'a> {
1088    pub fn target_id(mut self, target_id: impl Into<TargetID<'a>>) -> Self { self.target_id = Some(target_id.into()); self }
1089    pub fn build(self) -> GetTargetInfoParams<'a> {
1090        GetTargetInfoParams {
1091            target_id: self.target_id,
1092        }
1093    }
1094}
1095
1096/// Returns information about a target.
1097
1098#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1099#[serde(rename_all = "camelCase")]
1100pub struct GetTargetInfoReturns<'a> {
1101    #[serde(rename = "targetInfo")]
1102    target_info: TargetInfo<'a>,
1103}
1104
1105impl<'a> GetTargetInfoReturns<'a> {
1106    /// Creates a builder for this type with the required parameters:
1107    /// * `target_info`: 
1108    pub fn builder(target_info: TargetInfo<'a>) -> GetTargetInfoReturnsBuilder<'a> {
1109        GetTargetInfoReturnsBuilder {
1110            target_info: target_info,
1111        }
1112    }
1113    pub fn target_info(&self) -> &TargetInfo<'a> { &self.target_info }
1114}
1115
1116
1117pub struct GetTargetInfoReturnsBuilder<'a> {
1118    target_info: TargetInfo<'a>,
1119}
1120
1121impl<'a> GetTargetInfoReturnsBuilder<'a> {
1122    pub fn build(self) -> GetTargetInfoReturns<'a> {
1123        GetTargetInfoReturns {
1124            target_info: self.target_info,
1125        }
1126    }
1127}
1128
1129impl<'a> GetTargetInfoParams<'a> { pub const METHOD: &'static str = "Target.getTargetInfo"; }
1130
1131impl<'a> crate::CdpCommand<'a> for GetTargetInfoParams<'a> {
1132    const METHOD: &'static str = "Target.getTargetInfo";
1133    type Response = GetTargetInfoReturns<'a>;
1134}
1135
1136/// Retrieves a list of available targets.
1137
1138#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1139#[serde(rename_all = "camelCase")]
1140pub struct GetTargetsParams<'a> {
1141    /// Only targets matching filter will be reported. If filter is not specified
1142    /// and target discovery is currently enabled, a filter used for target discovery
1143    /// is used for consistency.
1144    #[serde(skip_serializing_if = "Option::is_none")]
1145    filter: Option<TargetFilter<'a>>,
1146}
1147
1148impl<'a> GetTargetsParams<'a> {
1149    /// Creates a builder for this type.
1150    pub fn builder() -> GetTargetsParamsBuilder<'a> {
1151        GetTargetsParamsBuilder {
1152            filter: None,
1153        }
1154    }
1155    /// Only targets matching filter will be reported. If filter is not specified
1156    /// and target discovery is currently enabled, a filter used for target discovery
1157    /// is used for consistency.
1158    pub fn filter(&self) -> Option<&TargetFilter<'a>> { self.filter.as_ref() }
1159}
1160
1161#[derive(Default)]
1162pub struct GetTargetsParamsBuilder<'a> {
1163    filter: Option<TargetFilter<'a>>,
1164}
1165
1166impl<'a> GetTargetsParamsBuilder<'a> {
1167    /// Only targets matching filter will be reported. If filter is not specified
1168    /// and target discovery is currently enabled, a filter used for target discovery
1169    /// is used for consistency.
1170    pub fn filter(mut self, filter: TargetFilter<'a>) -> Self { self.filter = Some(filter); self }
1171    pub fn build(self) -> GetTargetsParams<'a> {
1172        GetTargetsParams {
1173            filter: self.filter,
1174        }
1175    }
1176}
1177
1178/// Retrieves a list of available targets.
1179
1180#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1181#[serde(rename_all = "camelCase")]
1182pub struct GetTargetsReturns<'a> {
1183    /// The list of targets.
1184    #[serde(rename = "targetInfos")]
1185    target_infos: Vec<TargetInfo<'a>>,
1186}
1187
1188impl<'a> GetTargetsReturns<'a> {
1189    /// Creates a builder for this type with the required parameters:
1190    /// * `target_infos`: The list of targets.
1191    pub fn builder(target_infos: Vec<TargetInfo<'a>>) -> GetTargetsReturnsBuilder<'a> {
1192        GetTargetsReturnsBuilder {
1193            target_infos: target_infos,
1194        }
1195    }
1196    /// The list of targets.
1197    pub fn target_infos(&self) -> &[TargetInfo<'a>] { &self.target_infos }
1198}
1199
1200
1201pub struct GetTargetsReturnsBuilder<'a> {
1202    target_infos: Vec<TargetInfo<'a>>,
1203}
1204
1205impl<'a> GetTargetsReturnsBuilder<'a> {
1206    pub fn build(self) -> GetTargetsReturns<'a> {
1207        GetTargetsReturns {
1208            target_infos: self.target_infos,
1209        }
1210    }
1211}
1212
1213impl<'a> GetTargetsParams<'a> { pub const METHOD: &'static str = "Target.getTargets"; }
1214
1215impl<'a> crate::CdpCommand<'a> for GetTargetsParams<'a> {
1216    const METHOD: &'static str = "Target.getTargets";
1217    type Response = GetTargetsReturns<'a>;
1218}
1219
1220/// Sends protocol message over session with given id.
1221/// Consider using flat mode instead; see commands attachToTarget, setAutoAttach,
1222/// and crbug.com/991325.
1223
1224#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1225#[serde(rename_all = "camelCase")]
1226pub struct SendMessageToTargetParams<'a> {
1227    message: Cow<'a, str>,
1228    /// Identifier of the session.
1229    #[serde(skip_serializing_if = "Option::is_none", rename = "sessionId")]
1230    session_id: Option<SessionID<'a>>,
1231    /// Deprecated.
1232    #[serde(skip_serializing_if = "Option::is_none", rename = "targetId")]
1233    target_id: Option<TargetID<'a>>,
1234}
1235
1236impl<'a> SendMessageToTargetParams<'a> {
1237    /// Creates a builder for this type with the required parameters:
1238    /// * `message`: 
1239    pub fn builder(message: impl Into<Cow<'a, str>>) -> SendMessageToTargetParamsBuilder<'a> {
1240        SendMessageToTargetParamsBuilder {
1241            message: message.into(),
1242            session_id: None,
1243            target_id: None,
1244        }
1245    }
1246    pub fn message(&self) -> &str { self.message.as_ref() }
1247    /// Identifier of the session.
1248    pub fn session_id(&self) -> Option<&SessionID<'a>> { self.session_id.as_ref() }
1249    /// Deprecated.
1250    pub fn target_id(&self) -> Option<&TargetID<'a>> { self.target_id.as_ref() }
1251}
1252
1253
1254pub struct SendMessageToTargetParamsBuilder<'a> {
1255    message: Cow<'a, str>,
1256    session_id: Option<SessionID<'a>>,
1257    target_id: Option<TargetID<'a>>,
1258}
1259
1260impl<'a> SendMessageToTargetParamsBuilder<'a> {
1261    /// Identifier of the session.
1262    pub fn session_id(mut self, session_id: impl Into<SessionID<'a>>) -> Self { self.session_id = Some(session_id.into()); self }
1263    /// Deprecated.
1264    pub fn target_id(mut self, target_id: impl Into<TargetID<'a>>) -> Self { self.target_id = Some(target_id.into()); self }
1265    pub fn build(self) -> SendMessageToTargetParams<'a> {
1266        SendMessageToTargetParams {
1267            message: self.message,
1268            session_id: self.session_id,
1269            target_id: self.target_id,
1270        }
1271    }
1272}
1273
1274impl<'a> SendMessageToTargetParams<'a> { pub const METHOD: &'static str = "Target.sendMessageToTarget"; }
1275
1276impl<'a> crate::CdpCommand<'a> for SendMessageToTargetParams<'a> {
1277    const METHOD: &'static str = "Target.sendMessageToTarget";
1278    type Response = crate::EmptyReturns;
1279}
1280
1281/// Controls whether to automatically attach to new targets which are considered
1282/// to be directly related to this one (for example, iframes or workers).
1283/// When turned on, attaches to all existing related targets as well. When turned off,
1284/// automatically detaches from all currently attached targets.
1285/// This also clears all targets added by 'autoAttachRelated' from the list of targets to watch
1286/// for creation of related targets.
1287/// You might want to call this recursively for auto-attached targets to attach
1288/// to all available targets.
1289
1290#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1291#[serde(rename_all = "camelCase")]
1292pub struct SetAutoAttachParams<'a> {
1293    /// Whether to auto-attach to related targets.
1294    #[serde(rename = "autoAttach")]
1295    auto_attach: bool,
1296    /// Whether to pause new targets when attaching to them. Use 'Runtime.runIfWaitingForDebugger'
1297    /// to run paused targets.
1298    #[serde(rename = "waitForDebuggerOnStart")]
1299    wait_for_debugger_on_start: bool,
1300    /// Enables "flat" access to the session via specifying sessionId attribute in the commands.
1301    /// We plan to make this the default, deprecate non-flattened mode,
1302    /// and eventually retire it. See crbug.com/991325.
1303    #[serde(skip_serializing_if = "Option::is_none")]
1304    flatten: Option<bool>,
1305    /// Only targets matching filter will be attached.
1306    #[serde(skip_serializing_if = "Option::is_none")]
1307    filter: Option<TargetFilter<'a>>,
1308}
1309
1310impl<'a> SetAutoAttachParams<'a> {
1311    /// Creates a builder for this type with the required parameters:
1312    /// * `auto_attach`: Whether to auto-attach to related targets.
1313    /// * `wait_for_debugger_on_start`: Whether to pause new targets when attaching to them. Use `Runtime.runIfWaitingForDebugger` to run paused targets.
1314    pub fn builder(auto_attach: bool, wait_for_debugger_on_start: bool) -> SetAutoAttachParamsBuilder<'a> {
1315        SetAutoAttachParamsBuilder {
1316            auto_attach: auto_attach,
1317            wait_for_debugger_on_start: wait_for_debugger_on_start,
1318            flatten: None,
1319            filter: None,
1320        }
1321    }
1322    /// Whether to auto-attach to related targets.
1323    pub fn auto_attach(&self) -> bool { self.auto_attach }
1324    /// Whether to pause new targets when attaching to them. Use 'Runtime.runIfWaitingForDebugger'
1325    /// to run paused targets.
1326    pub fn wait_for_debugger_on_start(&self) -> bool { self.wait_for_debugger_on_start }
1327    /// Enables "flat" access to the session via specifying sessionId attribute in the commands.
1328    /// We plan to make this the default, deprecate non-flattened mode,
1329    /// and eventually retire it. See crbug.com/991325.
1330    pub fn flatten(&self) -> Option<bool> { self.flatten }
1331    /// Only targets matching filter will be attached.
1332    pub fn filter(&self) -> Option<&TargetFilter<'a>> { self.filter.as_ref() }
1333}
1334
1335
1336pub struct SetAutoAttachParamsBuilder<'a> {
1337    auto_attach: bool,
1338    wait_for_debugger_on_start: bool,
1339    flatten: Option<bool>,
1340    filter: Option<TargetFilter<'a>>,
1341}
1342
1343impl<'a> SetAutoAttachParamsBuilder<'a> {
1344    /// Enables "flat" access to the session via specifying sessionId attribute in the commands.
1345    /// We plan to make this the default, deprecate non-flattened mode,
1346    /// and eventually retire it. See crbug.com/991325.
1347    pub fn flatten(mut self, flatten: bool) -> Self { self.flatten = Some(flatten); self }
1348    /// Only targets matching filter will be attached.
1349    pub fn filter(mut self, filter: TargetFilter<'a>) -> Self { self.filter = Some(filter); self }
1350    pub fn build(self) -> SetAutoAttachParams<'a> {
1351        SetAutoAttachParams {
1352            auto_attach: self.auto_attach,
1353            wait_for_debugger_on_start: self.wait_for_debugger_on_start,
1354            flatten: self.flatten,
1355            filter: self.filter,
1356        }
1357    }
1358}
1359
1360impl<'a> SetAutoAttachParams<'a> { pub const METHOD: &'static str = "Target.setAutoAttach"; }
1361
1362impl<'a> crate::CdpCommand<'a> for SetAutoAttachParams<'a> {
1363    const METHOD: &'static str = "Target.setAutoAttach";
1364    type Response = crate::EmptyReturns;
1365}
1366
1367/// Adds the specified target to the list of targets that will be monitored for any related target
1368/// creation (such as child frames, child workers and new versions of service worker) and reported
1369/// through 'attachedToTarget'. The specified target is also auto-attached.
1370/// This cancels the effect of any previous 'setAutoAttach' and is also cancelled by subsequent
1371/// 'setAutoAttach'. Only available at the Browser target.
1372
1373#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1374#[serde(rename_all = "camelCase")]
1375pub struct AutoAttachRelatedParams<'a> {
1376    #[serde(rename = "targetId")]
1377    target_id: TargetID<'a>,
1378    /// Whether to pause new targets when attaching to them. Use 'Runtime.runIfWaitingForDebugger'
1379    /// to run paused targets.
1380    #[serde(rename = "waitForDebuggerOnStart")]
1381    wait_for_debugger_on_start: bool,
1382    /// Only targets matching filter will be attached.
1383    #[serde(skip_serializing_if = "Option::is_none")]
1384    filter: Option<TargetFilter<'a>>,
1385}
1386
1387impl<'a> AutoAttachRelatedParams<'a> {
1388    /// Creates a builder for this type with the required parameters:
1389    /// * `target_id`: 
1390    /// * `wait_for_debugger_on_start`: Whether to pause new targets when attaching to them. Use `Runtime.runIfWaitingForDebugger` to run paused targets.
1391    pub fn builder(target_id: impl Into<TargetID<'a>>, wait_for_debugger_on_start: bool) -> AutoAttachRelatedParamsBuilder<'a> {
1392        AutoAttachRelatedParamsBuilder {
1393            target_id: target_id.into(),
1394            wait_for_debugger_on_start: wait_for_debugger_on_start,
1395            filter: None,
1396        }
1397    }
1398    pub fn target_id(&self) -> &TargetID<'a> { &self.target_id }
1399    /// Whether to pause new targets when attaching to them. Use 'Runtime.runIfWaitingForDebugger'
1400    /// to run paused targets.
1401    pub fn wait_for_debugger_on_start(&self) -> bool { self.wait_for_debugger_on_start }
1402    /// Only targets matching filter will be attached.
1403    pub fn filter(&self) -> Option<&TargetFilter<'a>> { self.filter.as_ref() }
1404}
1405
1406
1407pub struct AutoAttachRelatedParamsBuilder<'a> {
1408    target_id: TargetID<'a>,
1409    wait_for_debugger_on_start: bool,
1410    filter: Option<TargetFilter<'a>>,
1411}
1412
1413impl<'a> AutoAttachRelatedParamsBuilder<'a> {
1414    /// Only targets matching filter will be attached.
1415    pub fn filter(mut self, filter: TargetFilter<'a>) -> Self { self.filter = Some(filter); self }
1416    pub fn build(self) -> AutoAttachRelatedParams<'a> {
1417        AutoAttachRelatedParams {
1418            target_id: self.target_id,
1419            wait_for_debugger_on_start: self.wait_for_debugger_on_start,
1420            filter: self.filter,
1421        }
1422    }
1423}
1424
1425impl<'a> AutoAttachRelatedParams<'a> { pub const METHOD: &'static str = "Target.autoAttachRelated"; }
1426
1427impl<'a> crate::CdpCommand<'a> for AutoAttachRelatedParams<'a> {
1428    const METHOD: &'static str = "Target.autoAttachRelated";
1429    type Response = crate::EmptyReturns;
1430}
1431
1432/// Controls whether to discover available targets and notify via
1433/// 'targetCreated/targetInfoChanged/targetDestroyed' events.
1434
1435#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1436#[serde(rename_all = "camelCase")]
1437pub struct SetDiscoverTargetsParams<'a> {
1438    /// Whether to discover available targets.
1439    discover: bool,
1440    /// Only targets matching filter will be attached. If 'discover' is false,
1441    /// 'filter' must be omitted or empty.
1442    #[serde(skip_serializing_if = "Option::is_none")]
1443    filter: Option<TargetFilter<'a>>,
1444}
1445
1446impl<'a> SetDiscoverTargetsParams<'a> {
1447    /// Creates a builder for this type with the required parameters:
1448    /// * `discover`: Whether to discover available targets.
1449    pub fn builder(discover: bool) -> SetDiscoverTargetsParamsBuilder<'a> {
1450        SetDiscoverTargetsParamsBuilder {
1451            discover: discover,
1452            filter: None,
1453        }
1454    }
1455    /// Whether to discover available targets.
1456    pub fn discover(&self) -> bool { self.discover }
1457    /// Only targets matching filter will be attached. If 'discover' is false,
1458    /// 'filter' must be omitted or empty.
1459    pub fn filter(&self) -> Option<&TargetFilter<'a>> { self.filter.as_ref() }
1460}
1461
1462
1463pub struct SetDiscoverTargetsParamsBuilder<'a> {
1464    discover: bool,
1465    filter: Option<TargetFilter<'a>>,
1466}
1467
1468impl<'a> SetDiscoverTargetsParamsBuilder<'a> {
1469    /// Only targets matching filter will be attached. If 'discover' is false,
1470    /// 'filter' must be omitted or empty.
1471    pub fn filter(mut self, filter: TargetFilter<'a>) -> Self { self.filter = Some(filter); self }
1472    pub fn build(self) -> SetDiscoverTargetsParams<'a> {
1473        SetDiscoverTargetsParams {
1474            discover: self.discover,
1475            filter: self.filter,
1476        }
1477    }
1478}
1479
1480impl<'a> SetDiscoverTargetsParams<'a> { pub const METHOD: &'static str = "Target.setDiscoverTargets"; }
1481
1482impl<'a> crate::CdpCommand<'a> for SetDiscoverTargetsParams<'a> {
1483    const METHOD: &'static str = "Target.setDiscoverTargets";
1484    type Response = crate::EmptyReturns;
1485}
1486
1487/// Enables target discovery for the specified locations, when 'setDiscoverTargets' was set to
1488/// 'true'.
1489
1490#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1491#[serde(rename_all = "camelCase")]
1492pub struct SetRemoteLocationsParams<'a> {
1493    /// List of remote locations.
1494    locations: Vec<RemoteLocation<'a>>,
1495}
1496
1497impl<'a> SetRemoteLocationsParams<'a> {
1498    /// Creates a builder for this type with the required parameters:
1499    /// * `locations`: List of remote locations.
1500    pub fn builder(locations: Vec<RemoteLocation<'a>>) -> SetRemoteLocationsParamsBuilder<'a> {
1501        SetRemoteLocationsParamsBuilder {
1502            locations: locations,
1503        }
1504    }
1505    /// List of remote locations.
1506    pub fn locations(&self) -> &[RemoteLocation<'a>] { &self.locations }
1507}
1508
1509
1510pub struct SetRemoteLocationsParamsBuilder<'a> {
1511    locations: Vec<RemoteLocation<'a>>,
1512}
1513
1514impl<'a> SetRemoteLocationsParamsBuilder<'a> {
1515    pub fn build(self) -> SetRemoteLocationsParams<'a> {
1516        SetRemoteLocationsParams {
1517            locations: self.locations,
1518        }
1519    }
1520}
1521
1522impl<'a> SetRemoteLocationsParams<'a> { pub const METHOD: &'static str = "Target.setRemoteLocations"; }
1523
1524impl<'a> crate::CdpCommand<'a> for SetRemoteLocationsParams<'a> {
1525    const METHOD: &'static str = "Target.setRemoteLocations";
1526    type Response = crate::EmptyReturns;
1527}
1528
1529/// Gets the targetId of the DevTools page target opened for the given target
1530/// (if any).
1531
1532#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1533#[serde(rename_all = "camelCase")]
1534pub struct GetDevToolsTargetParams<'a> {
1535    /// Page or tab target ID.
1536    #[serde(rename = "targetId")]
1537    target_id: TargetID<'a>,
1538}
1539
1540impl<'a> GetDevToolsTargetParams<'a> {
1541    /// Creates a builder for this type with the required parameters:
1542    /// * `target_id`: Page or tab target ID.
1543    pub fn builder(target_id: impl Into<TargetID<'a>>) -> GetDevToolsTargetParamsBuilder<'a> {
1544        GetDevToolsTargetParamsBuilder {
1545            target_id: target_id.into(),
1546        }
1547    }
1548    /// Page or tab target ID.
1549    pub fn target_id(&self) -> &TargetID<'a> { &self.target_id }
1550}
1551
1552
1553pub struct GetDevToolsTargetParamsBuilder<'a> {
1554    target_id: TargetID<'a>,
1555}
1556
1557impl<'a> GetDevToolsTargetParamsBuilder<'a> {
1558    pub fn build(self) -> GetDevToolsTargetParams<'a> {
1559        GetDevToolsTargetParams {
1560            target_id: self.target_id,
1561        }
1562    }
1563}
1564
1565/// Gets the targetId of the DevTools page target opened for the given target
1566/// (if any).
1567
1568#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1569#[serde(rename_all = "camelCase")]
1570pub struct GetDevToolsTargetReturns<'a> {
1571    /// The targetId of DevTools page target if exists.
1572    #[serde(skip_serializing_if = "Option::is_none", rename = "targetId")]
1573    target_id: Option<TargetID<'a>>,
1574}
1575
1576impl<'a> GetDevToolsTargetReturns<'a> {
1577    /// Creates a builder for this type.
1578    pub fn builder() -> GetDevToolsTargetReturnsBuilder<'a> {
1579        GetDevToolsTargetReturnsBuilder {
1580            target_id: None,
1581        }
1582    }
1583    /// The targetId of DevTools page target if exists.
1584    pub fn target_id(&self) -> Option<&TargetID<'a>> { self.target_id.as_ref() }
1585}
1586
1587#[derive(Default)]
1588pub struct GetDevToolsTargetReturnsBuilder<'a> {
1589    target_id: Option<TargetID<'a>>,
1590}
1591
1592impl<'a> GetDevToolsTargetReturnsBuilder<'a> {
1593    /// The targetId of DevTools page target if exists.
1594    pub fn target_id(mut self, target_id: impl Into<TargetID<'a>>) -> Self { self.target_id = Some(target_id.into()); self }
1595    pub fn build(self) -> GetDevToolsTargetReturns<'a> {
1596        GetDevToolsTargetReturns {
1597            target_id: self.target_id,
1598        }
1599    }
1600}
1601
1602impl<'a> GetDevToolsTargetParams<'a> { pub const METHOD: &'static str = "Target.getDevToolsTarget"; }
1603
1604impl<'a> crate::CdpCommand<'a> for GetDevToolsTargetParams<'a> {
1605    const METHOD: &'static str = "Target.getDevToolsTarget";
1606    type Response = GetDevToolsTargetReturns<'a>;
1607}
1608
1609/// Opens a DevTools window for the target.
1610
1611#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1612#[serde(rename_all = "camelCase")]
1613pub struct OpenDevToolsParams<'a> {
1614    /// This can be the page or tab target ID.
1615    #[serde(rename = "targetId")]
1616    target_id: TargetID<'a>,
1617    /// The id of the panel we want DevTools to open initially. Currently
1618    /// supported panels are elements, console, network, sources, resources
1619    /// and performance.
1620    #[serde(skip_serializing_if = "Option::is_none", rename = "panelId")]
1621    panel_id: Option<Cow<'a, str>>,
1622}
1623
1624impl<'a> OpenDevToolsParams<'a> {
1625    /// Creates a builder for this type with the required parameters:
1626    /// * `target_id`: This can be the page or tab target ID.
1627    pub fn builder(target_id: impl Into<TargetID<'a>>) -> OpenDevToolsParamsBuilder<'a> {
1628        OpenDevToolsParamsBuilder {
1629            target_id: target_id.into(),
1630            panel_id: None,
1631        }
1632    }
1633    /// This can be the page or tab target ID.
1634    pub fn target_id(&self) -> &TargetID<'a> { &self.target_id }
1635    /// The id of the panel we want DevTools to open initially. Currently
1636    /// supported panels are elements, console, network, sources, resources
1637    /// and performance.
1638    pub fn panel_id(&self) -> Option<&str> { self.panel_id.as_deref() }
1639}
1640
1641
1642pub struct OpenDevToolsParamsBuilder<'a> {
1643    target_id: TargetID<'a>,
1644    panel_id: Option<Cow<'a, str>>,
1645}
1646
1647impl<'a> OpenDevToolsParamsBuilder<'a> {
1648    /// The id of the panel we want DevTools to open initially. Currently
1649    /// supported panels are elements, console, network, sources, resources
1650    /// and performance.
1651    pub fn panel_id(mut self, panel_id: impl Into<Cow<'a, str>>) -> Self { self.panel_id = Some(panel_id.into()); self }
1652    pub fn build(self) -> OpenDevToolsParams<'a> {
1653        OpenDevToolsParams {
1654            target_id: self.target_id,
1655            panel_id: self.panel_id,
1656        }
1657    }
1658}
1659
1660/// Opens a DevTools window for the target.
1661
1662#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1663#[serde(rename_all = "camelCase")]
1664pub struct OpenDevToolsReturns<'a> {
1665    /// The targetId of DevTools page target.
1666    #[serde(rename = "targetId")]
1667    target_id: TargetID<'a>,
1668}
1669
1670impl<'a> OpenDevToolsReturns<'a> {
1671    /// Creates a builder for this type with the required parameters:
1672    /// * `target_id`: The targetId of DevTools page target.
1673    pub fn builder(target_id: impl Into<TargetID<'a>>) -> OpenDevToolsReturnsBuilder<'a> {
1674        OpenDevToolsReturnsBuilder {
1675            target_id: target_id.into(),
1676        }
1677    }
1678    /// The targetId of DevTools page target.
1679    pub fn target_id(&self) -> &TargetID<'a> { &self.target_id }
1680}
1681
1682
1683pub struct OpenDevToolsReturnsBuilder<'a> {
1684    target_id: TargetID<'a>,
1685}
1686
1687impl<'a> OpenDevToolsReturnsBuilder<'a> {
1688    pub fn build(self) -> OpenDevToolsReturns<'a> {
1689        OpenDevToolsReturns {
1690            target_id: self.target_id,
1691        }
1692    }
1693}
1694
1695impl<'a> OpenDevToolsParams<'a> { pub const METHOD: &'static str = "Target.openDevTools"; }
1696
1697impl<'a> crate::CdpCommand<'a> for OpenDevToolsParams<'a> {
1698    const METHOD: &'static str = "Target.openDevTools";
1699    type Response = OpenDevToolsReturns<'a>;
1700}