Skip to main content

cdp_driver/protocol/
target.rs

1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! Supports additional targets discovery and allows to attach to them.
5//!
6//! Types, command parameters and event payloads for the `Target`
7//! domain. The method-name constants for the same domain are in
8//! [`crate::methods`].
9
10use serde::{Deserialize, Serialize};
11
12pub type TargetId = String;
13
14/// Unique identifier of attached debugging session.
15pub type SessionId = String;
16
17#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
18pub struct TargetInfo {
19    #[serde(rename = "targetId")]
20    pub target_id: TargetId,
21    /// List of types:
22    /// <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>
23    pub r#type: String,
24    pub title: String,
25    pub url: String,
26    /// Whether the target has an attached client.
27    pub attached: bool,
28    /// Id of the parent target, if any. For example, "iframe" target may have a
29    /// "page" parent.
30    #[serde(rename = "parentId", default, skip_serializing_if = "Option::is_none")]
31    pub parent_id: Option<TargetId>,
32    /// Opener target Id
33    #[serde(rename = "openerId", default, skip_serializing_if = "Option::is_none")]
34    pub opener_id: Option<TargetId>,
35    /// Whether the target has access to the originating window.
36    ///
37    /// Experimental: may change without notice.
38    #[serde(rename = "canAccessOpener")]
39    pub can_access_opener: bool,
40    /// Frame id of originating window (is only set if target has an opener).
41    ///
42    /// Experimental: may change without notice.
43    #[serde(
44        rename = "openerFrameId",
45        default,
46        skip_serializing_if = "Option::is_none"
47    )]
48    pub opener_frame_id: Option<crate::protocol::page::FrameId>,
49    /// Id of the parent frame, present for "iframe" and "worker" targets. For
50    /// nested workers, this is the "ancestor" frame that created the first worker
51    /// in the nested chain.
52    ///
53    /// Experimental: may change without notice.
54    #[serde(
55        rename = "parentFrameId",
56        default,
57        skip_serializing_if = "Option::is_none"
58    )]
59    pub parent_frame_id: Option<crate::protocol::page::FrameId>,
60    /// Experimental: may change without notice.
61    #[serde(
62        rename = "browserContextId",
63        default,
64        skip_serializing_if = "Option::is_none"
65    )]
66    pub browser_context_id: Option<crate::protocol::browser::BrowserContextId>,
67    /// Provides additional details for specific target types. For example, for
68    /// the type of "page", this may be set to "prerender".
69    ///
70    /// Experimental: may change without notice.
71    #[serde(default, skip_serializing_if = "Option::is_none")]
72    pub subtype: Option<String>,
73    /// Embedder-specific target metadata. This is only set for targets of type
74    /// "tab".
75    ///
76    /// Experimental: may change without notice.
77    #[serde(
78        rename = "embedderData",
79        default,
80        skip_serializing_if = "Option::is_none"
81    )]
82    pub embedder_data: Option<serde_json::Value>,
83}
84
85/// A filter used by target query/discovery/auto-attach operations.
86///
87/// Experimental: may change without notice.
88#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
89pub struct FilterEntry {
90    /// If set, causes exclusion of matching targets from the list.
91    #[serde(default, skip_serializing_if = "Option::is_none")]
92    pub exclude: Option<bool>,
93    /// If not present, matches any type.
94    #[serde(default, skip_serializing_if = "Option::is_none")]
95    pub r#type: Option<String>,
96}
97
98/// The entries in TargetFilter are matched sequentially against targets and
99/// the first entry that matches determines if the target is included or not,
100/// depending on the value of `exclude` field in the entry. If filter is not
101/// specified, the one assumed is \[{type: "browser", exclude: true}, {type:
102/// "tab", exclude: true}, {}\] (i.e. include everything but `browser` and
103/// `tab`).
104///
105/// Experimental: may change without notice.
106pub type TargetFilter = Vec<FilterEntry>;
107
108/// Experimental: may change without notice.
109#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
110pub struct RemoteLocation {
111    pub host: String,
112    pub port: i64,
113}
114
115/// The state of the target window.
116///
117/// Experimental: may change without notice.
118#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
119pub enum WindowState {
120    /// `normal`
121    #[serde(rename = "normal")]
122    Normal,
123    /// `minimized`
124    #[serde(rename = "minimized")]
125    Minimized,
126    /// `maximized`
127    #[serde(rename = "maximized")]
128    Maximized,
129    /// `fullscreen`
130    #[serde(rename = "fullscreen")]
131    Fullscreen,
132    /// A value this vendored schema does not list. Chrome adds values ahead of
133    /// the published protocol, so an unrecognised one is kept as it arrived
134    /// rather than failing the payload it came in.
135    #[serde(untagged)]
136    Unrecognized(String),
137}
138
139/// Activates (focuses) the target.
140///
141/// Parameters of `Target.activateTarget`.
142#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
143pub struct ActivateTargetParams {
144    #[serde(rename = "targetId")]
145    pub target_id: TargetId,
146}
147
148impl crate::typed::Command for ActivateTargetParams {
149    const METHOD: &'static str = "Target.activateTarget";
150    type Returns = crate::typed::NoReturns;
151}
152
153/// Attaches to the target with given id.
154///
155/// Parameters of `Target.attachToTarget`.
156#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
157pub struct AttachToTargetParams {
158    #[serde(rename = "targetId")]
159    pub target_id: TargetId,
160    /// Enables "flat" access to the session via specifying sessionId attribute in
161    /// the commands. We plan to make this the default, deprecate non-flattened
162    /// mode, and eventually retire it. See crbug.com/991325.
163    #[serde(default, skip_serializing_if = "Option::is_none")]
164    pub flatten: Option<bool>,
165}
166
167/// What `Target.attachToTarget` answers with.
168#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
169pub struct AttachToTargetReturns {
170    /// Id assigned to the session.
171    #[serde(rename = "sessionId")]
172    pub session_id: SessionId,
173}
174
175impl crate::typed::Command for AttachToTargetParams {
176    const METHOD: &'static str = "Target.attachToTarget";
177    type Returns = AttachToTargetReturns;
178}
179
180/// Attaches to the browser target, only uses flat sessionId mode.
181///
182/// Experimental: may change without notice.
183///
184/// Parameters of `Target.attachToBrowserTarget`.
185#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
186pub struct AttachToBrowserTargetParams {}
187
188/// What `Target.attachToBrowserTarget` answers with.
189#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
190pub struct AttachToBrowserTargetReturns {
191    /// Id assigned to the session.
192    #[serde(rename = "sessionId")]
193    pub session_id: SessionId,
194}
195
196impl crate::typed::Command for AttachToBrowserTargetParams {
197    const METHOD: &'static str = "Target.attachToBrowserTarget";
198    type Returns = AttachToBrowserTargetReturns;
199}
200
201/// Closes the target. If the target is a page that gets closed too.
202///
203/// Parameters of `Target.closeTarget`.
204#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
205pub struct CloseTargetParams {
206    #[serde(rename = "targetId")]
207    pub target_id: TargetId,
208}
209
210/// What `Target.closeTarget` answers with.
211#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
212pub struct CloseTargetReturns {
213    /// Always set to true. If an error occurs, the response indicates protocol
214    /// error.
215    ///
216    /// Deprecated in the protocol.
217    pub success: bool,
218}
219
220impl crate::typed::Command for CloseTargetParams {
221    const METHOD: &'static str = "Target.closeTarget";
222    type Returns = CloseTargetReturns;
223}
224
225/// Inject object to the target's main frame that provides a communication
226/// channel with browser target. Injected object will be available as
227/// `window\[bindingName\]`. The object has the following API: -
228/// `binding.send(json)` - a method to send messages over the remote debugging
229/// protocol - `binding.onmessage = json =\> handleMessage(json)` - a callback
230/// that will be called for the protocol notifications and command responses.
231///
232/// Experimental: may change without notice.
233///
234/// Parameters of `Target.exposeDevToolsProtocol`.
235#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
236pub struct ExposeDevToolsProtocolParams {
237    #[serde(rename = "targetId")]
238    pub target_id: TargetId,
239    /// Binding name, 'cdp' if not specified.
240    #[serde(
241        rename = "bindingName",
242        default,
243        skip_serializing_if = "Option::is_none"
244    )]
245    pub binding_name: Option<String>,
246    /// If true, inherits the current root session's permissions (default: false).
247    #[serde(
248        rename = "inheritPermissions",
249        default,
250        skip_serializing_if = "Option::is_none"
251    )]
252    pub inherit_permissions: Option<bool>,
253}
254
255impl crate::typed::Command for ExposeDevToolsProtocolParams {
256    const METHOD: &'static str = "Target.exposeDevToolsProtocol";
257    type Returns = crate::typed::NoReturns;
258}
259
260/// Creates a new empty BrowserContext. Similar to an incognito profile but
261/// you can have more than one.
262///
263/// Parameters of `Target.createBrowserContext`.
264#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
265pub struct CreateBrowserContextParams {
266    /// If specified, disposes this context when debugging session disconnects.
267    ///
268    /// Experimental: may change without notice.
269    #[serde(
270        rename = "disposeOnDetach",
271        default,
272        skip_serializing_if = "Option::is_none"
273    )]
274    pub dispose_on_detach: Option<bool>,
275    /// Proxy server, similar to the one passed to --proxy-server
276    ///
277    /// Experimental: may change without notice.
278    #[serde(
279        rename = "proxyServer",
280        default,
281        skip_serializing_if = "Option::is_none"
282    )]
283    pub proxy_server: Option<String>,
284    /// Proxy bypass list, similar to the one passed to --proxy-bypass-list
285    ///
286    /// Experimental: may change without notice.
287    #[serde(
288        rename = "proxyBypassList",
289        default,
290        skip_serializing_if = "Option::is_none"
291    )]
292    pub proxy_bypass_list: Option<String>,
293    /// An optional list of origins to grant unlimited cross-origin access to.
294    /// Parts of the URL other than those constituting origin are ignored.
295    ///
296    /// Experimental: may change without notice.
297    #[serde(
298        rename = "originsWithUniversalNetworkAccess",
299        default,
300        skip_serializing_if = "Option::is_none"
301    )]
302    pub origins_with_universal_network_access: Option<Vec<String>>,
303}
304
305/// What `Target.createBrowserContext` answers with.
306#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
307pub struct CreateBrowserContextReturns {
308    /// The id of the context created.
309    #[serde(rename = "browserContextId")]
310    pub browser_context_id: crate::protocol::browser::BrowserContextId,
311}
312
313impl crate::typed::Command for CreateBrowserContextParams {
314    const METHOD: &'static str = "Target.createBrowserContext";
315    type Returns = CreateBrowserContextReturns;
316}
317
318/// Returns all browser contexts created with `Target.createBrowserContext`
319/// method.
320///
321/// Parameters of `Target.getBrowserContexts`.
322#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
323pub struct GetBrowserContextsParams {}
324
325/// What `Target.getBrowserContexts` answers with.
326#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
327pub struct GetBrowserContextsReturns {
328    /// An array of browser context ids.
329    #[serde(rename = "browserContextIds")]
330    pub browser_context_ids: Vec<crate::protocol::browser::BrowserContextId>,
331    /// The id of the default browser context if available.
332    ///
333    /// Experimental: may change without notice.
334    #[serde(
335        rename = "defaultBrowserContextId",
336        default,
337        skip_serializing_if = "Option::is_none"
338    )]
339    pub default_browser_context_id: Option<crate::protocol::browser::BrowserContextId>,
340}
341
342impl crate::typed::Command for GetBrowserContextsParams {
343    const METHOD: &'static str = "Target.getBrowserContexts";
344    type Returns = GetBrowserContextsReturns;
345}
346
347/// Creates a new page.
348///
349/// Parameters of `Target.createTarget`.
350#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
351pub struct CreateTargetParams {
352    /// The initial URL the page will be navigated to. An empty string indicates
353    /// about:blank.
354    pub url: String,
355    /// Frame left origin in DIP (requires newWindow to be true or headless
356    /// shell).
357    ///
358    /// Experimental: may change without notice.
359    #[serde(default, skip_serializing_if = "Option::is_none")]
360    pub left: Option<i64>,
361    /// Frame top origin in DIP (requires newWindow to be true or headless shell).
362    ///
363    /// Experimental: may change without notice.
364    #[serde(default, skip_serializing_if = "Option::is_none")]
365    pub top: Option<i64>,
366    /// Frame width in DIP (requires newWindow to be true or headless shell).
367    #[serde(default, skip_serializing_if = "Option::is_none")]
368    pub width: Option<i64>,
369    /// Frame height in DIP (requires newWindow to be true or headless shell).
370    #[serde(default, skip_serializing_if = "Option::is_none")]
371    pub height: Option<i64>,
372    /// Frame window state (requires newWindow to be true or headless shell).
373    /// Default is normal.
374    #[serde(
375        rename = "windowState",
376        default,
377        skip_serializing_if = "Option::is_none"
378    )]
379    pub window_state: Option<WindowState>,
380    /// The browser context to create the page in.
381    ///
382    /// Experimental: may change without notice.
383    #[serde(
384        rename = "browserContextId",
385        default,
386        skip_serializing_if = "Option::is_none"
387    )]
388    pub browser_context_id: Option<crate::protocol::browser::BrowserContextId>,
389    /// Whether BeginFrames for this target will be controlled via DevTools
390    /// (headless shell only, not supported on MacOS yet, false by default).
391    ///
392    /// Experimental: may change without notice.
393    #[serde(
394        rename = "enableBeginFrameControl",
395        default,
396        skip_serializing_if = "Option::is_none"
397    )]
398    pub enable_begin_frame_control: Option<bool>,
399    /// Whether to create a new Window or Tab (false by default, not supported by
400    /// headless shell).
401    #[serde(rename = "newWindow", default, skip_serializing_if = "Option::is_none")]
402    pub new_window: Option<bool>,
403    /// Whether to create the target in background or foreground (false by
404    /// default, not supported by headless shell).
405    #[serde(default, skip_serializing_if = "Option::is_none")]
406    pub background: Option<bool>,
407    /// Whether to create the target of type "tab".
408    ///
409    /// Experimental: may change without notice.
410    #[serde(rename = "forTab", default, skip_serializing_if = "Option::is_none")]
411    pub for_tab: Option<bool>,
412    /// Whether to create a hidden target. The hidden target is observable via
413    /// protocol, but not present in the tab UI strip. Cannot be created with
414    /// `forTab: true`, `newWindow: true` or `background: false`. The life-time of
415    /// the tab is limited to the life-time of the session.
416    ///
417    /// Experimental: may change without notice.
418    #[serde(default, skip_serializing_if = "Option::is_none")]
419    pub hidden: Option<bool>,
420    /// If specified, determines whether the new target should be focused. By
421    /// default, the focus behavior depends on the `background` parameter: - If
422    /// `background` is false (default) and `focus` is omitted, the new target is
423    /// focused and the browser window is brought to the foreground. - If
424    /// `background` is false and `focus` is false, the target is opened but the
425    /// browser window's focus remains unchanged (e.g., if the window was in the
426    /// background, it stays there). - If `background` is true, setting `focus` to
427    /// true is not supported and will result in an error.
428    ///
429    /// Experimental: may change without notice.
430    #[serde(default, skip_serializing_if = "Option::is_none")]
431    pub focus: Option<bool>,
432}
433
434/// What `Target.createTarget` answers with.
435#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
436pub struct CreateTargetReturns {
437    /// The id of the page opened.
438    #[serde(rename = "targetId")]
439    pub target_id: TargetId,
440}
441
442impl crate::typed::Command for CreateTargetParams {
443    const METHOD: &'static str = "Target.createTarget";
444    type Returns = CreateTargetReturns;
445}
446
447/// Detaches session with given id.
448///
449/// Parameters of `Target.detachFromTarget`.
450#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
451pub struct DetachFromTargetParams {
452    /// Session to detach.
453    #[serde(rename = "sessionId", default, skip_serializing_if = "Option::is_none")]
454    pub session_id: Option<SessionId>,
455    /// Deprecated.
456    ///
457    /// Deprecated in the protocol.
458    #[serde(rename = "targetId", default, skip_serializing_if = "Option::is_none")]
459    pub target_id: Option<TargetId>,
460}
461
462impl crate::typed::Command for DetachFromTargetParams {
463    const METHOD: &'static str = "Target.detachFromTarget";
464    type Returns = crate::typed::NoReturns;
465}
466
467/// Deletes a BrowserContext. All the belonging pages will be closed without
468/// calling their beforeunload hooks.
469///
470/// Parameters of `Target.disposeBrowserContext`.
471#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
472pub struct DisposeBrowserContextParams {
473    #[serde(rename = "browserContextId")]
474    pub browser_context_id: crate::protocol::browser::BrowserContextId,
475}
476
477impl crate::typed::Command for DisposeBrowserContextParams {
478    const METHOD: &'static str = "Target.disposeBrowserContext";
479    type Returns = crate::typed::NoReturns;
480}
481
482/// Returns information about a target.
483///
484/// Experimental: may change without notice.
485///
486/// Parameters of `Target.getTargetInfo`.
487#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
488pub struct GetTargetInfoParams {
489    #[serde(rename = "targetId", default, skip_serializing_if = "Option::is_none")]
490    pub target_id: Option<TargetId>,
491}
492
493/// What `Target.getTargetInfo` answers with.
494#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
495pub struct GetTargetInfoReturns {
496    #[serde(rename = "targetInfo")]
497    pub target_info: TargetInfo,
498}
499
500impl crate::typed::Command for GetTargetInfoParams {
501    const METHOD: &'static str = "Target.getTargetInfo";
502    type Returns = GetTargetInfoReturns;
503}
504
505/// Retrieves a list of available targets.
506///
507/// Parameters of `Target.getTargets`.
508#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
509pub struct GetTargetsParams {
510    /// Only targets matching filter will be reported. If filter is not specified
511    /// and target discovery is currently enabled, a filter used for target
512    /// discovery is used for consistency.
513    ///
514    /// Experimental: may change without notice.
515    #[serde(default, skip_serializing_if = "Option::is_none")]
516    pub filter: Option<TargetFilter>,
517}
518
519/// What `Target.getTargets` answers with.
520#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
521pub struct GetTargetsReturns {
522    /// The list of targets.
523    #[serde(rename = "targetInfos")]
524    pub target_infos: Vec<TargetInfo>,
525}
526
527impl crate::typed::Command for GetTargetsParams {
528    const METHOD: &'static str = "Target.getTargets";
529    type Returns = GetTargetsReturns;
530}
531
532/// Sends protocol message over session with given id. Consider using flat
533/// mode instead; see commands attachToTarget, setAutoAttach, and
534/// crbug.com/991325.
535///
536/// Deprecated in the protocol.
537///
538/// Parameters of `Target.sendMessageToTarget`.
539#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
540pub struct SendMessageToTargetParams {
541    pub message: String,
542    /// Identifier of the session.
543    #[serde(rename = "sessionId", default, skip_serializing_if = "Option::is_none")]
544    pub session_id: Option<SessionId>,
545    /// Deprecated.
546    ///
547    /// Deprecated in the protocol.
548    #[serde(rename = "targetId", default, skip_serializing_if = "Option::is_none")]
549    pub target_id: Option<TargetId>,
550}
551
552impl crate::typed::Command for SendMessageToTargetParams {
553    const METHOD: &'static str = "Target.sendMessageToTarget";
554    type Returns = crate::typed::NoReturns;
555}
556
557/// Controls whether to automatically attach to new targets which are
558/// considered to be directly related to this one (for example, iframes or
559/// workers). When turned on, attaches to all existing related targets as
560/// well. When turned off, automatically detaches from all currently attached
561/// targets. This also clears all targets added by `autoAttachRelated` from
562/// the list of targets to watch for creation of related targets. You might
563/// want to call this recursively for auto-attached targets to attach to all
564/// available targets.
565///
566/// Parameters of `Target.setAutoAttach`.
567#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
568pub struct SetAutoAttachParams {
569    /// Whether to auto-attach to related targets.
570    #[serde(rename = "autoAttach")]
571    pub auto_attach: bool,
572    /// Whether to pause new targets when attaching to them. Use
573    /// `Runtime.runIfWaitingForDebugger` to run paused targets.
574    #[serde(rename = "waitForDebuggerOnStart")]
575    pub wait_for_debugger_on_start: bool,
576    /// Enables "flat" access to the session via specifying sessionId attribute in
577    /// the commands. We plan to make this the default, deprecate non-flattened
578    /// mode, and eventually retire it. See crbug.com/991325.
579    ///
580    /// Experimental: may change without notice.
581    #[serde(default, skip_serializing_if = "Option::is_none")]
582    pub flatten: Option<bool>,
583    /// Only targets matching filter will be attached.
584    ///
585    /// Experimental: may change without notice.
586    #[serde(default, skip_serializing_if = "Option::is_none")]
587    pub filter: Option<TargetFilter>,
588}
589
590impl crate::typed::Command for SetAutoAttachParams {
591    const METHOD: &'static str = "Target.setAutoAttach";
592    type Returns = crate::typed::NoReturns;
593}
594
595/// Adds the specified target to the list of targets that will be monitored
596/// for any related target creation (such as child frames, child workers and
597/// new versions of service worker) and reported through `attachedToTarget`.
598/// The specified target is also auto-attached. This cancels the effect of any
599/// previous `setAutoAttach` and is also cancelled by subsequent
600/// `setAutoAttach`. Only available at the Browser target.
601///
602/// Experimental: may change without notice.
603///
604/// Parameters of `Target.autoAttachRelated`.
605#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
606pub struct AutoAttachRelatedParams {
607    #[serde(rename = "targetId")]
608    pub target_id: TargetId,
609    /// Whether to pause new targets when attaching to them. Use
610    /// `Runtime.runIfWaitingForDebugger` to run paused targets.
611    #[serde(rename = "waitForDebuggerOnStart")]
612    pub wait_for_debugger_on_start: bool,
613    /// Only targets matching filter will be attached.
614    ///
615    /// Experimental: may change without notice.
616    #[serde(default, skip_serializing_if = "Option::is_none")]
617    pub filter: Option<TargetFilter>,
618}
619
620impl crate::typed::Command for AutoAttachRelatedParams {
621    const METHOD: &'static str = "Target.autoAttachRelated";
622    type Returns = crate::typed::NoReturns;
623}
624
625/// Controls whether to discover available targets and notify via
626/// `targetCreated/targetInfoChanged/targetDestroyed` events.
627///
628/// Parameters of `Target.setDiscoverTargets`.
629#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
630pub struct SetDiscoverTargetsParams {
631    /// Whether to discover available targets.
632    pub discover: bool,
633    /// Only targets matching filter will be attached. If `discover` is false,
634    /// `filter` must be omitted or empty.
635    ///
636    /// Experimental: may change without notice.
637    #[serde(default, skip_serializing_if = "Option::is_none")]
638    pub filter: Option<TargetFilter>,
639}
640
641impl crate::typed::Command for SetDiscoverTargetsParams {
642    const METHOD: &'static str = "Target.setDiscoverTargets";
643    type Returns = crate::typed::NoReturns;
644}
645
646/// Enables target discovery for the specified locations, when
647/// `setDiscoverTargets` was set to `true`.
648///
649/// Experimental: may change without notice.
650///
651/// Parameters of `Target.setRemoteLocations`.
652#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
653pub struct SetRemoteLocationsParams {
654    /// List of remote locations.
655    pub locations: Vec<RemoteLocation>,
656}
657
658impl crate::typed::Command for SetRemoteLocationsParams {
659    const METHOD: &'static str = "Target.setRemoteLocations";
660    type Returns = crate::typed::NoReturns;
661}
662
663/// Gets the targetId of the DevTools page target opened for the given target
664/// (if any).
665///
666/// Experimental: may change without notice.
667///
668/// Parameters of `Target.getDevToolsTarget`.
669#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
670pub struct GetDevToolsTargetParams {
671    /// Page or tab target ID.
672    #[serde(rename = "targetId")]
673    pub target_id: TargetId,
674}
675
676/// What `Target.getDevToolsTarget` answers with.
677#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
678pub struct GetDevToolsTargetReturns {
679    /// The targetId of DevTools page target if exists.
680    #[serde(rename = "targetId", default, skip_serializing_if = "Option::is_none")]
681    pub target_id: Option<TargetId>,
682}
683
684impl crate::typed::Command for GetDevToolsTargetParams {
685    const METHOD: &'static str = "Target.getDevToolsTarget";
686    type Returns = GetDevToolsTargetReturns;
687}
688
689/// Opens a DevTools window for the target.
690///
691/// Experimental: may change without notice.
692///
693/// Parameters of `Target.openDevTools`.
694#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
695pub struct OpenDevToolsParams {
696    /// This can be the page or tab target ID.
697    #[serde(rename = "targetId")]
698    pub target_id: TargetId,
699    /// The id of the panel we want DevTools to open initially. Currently
700    /// supported panels are elements, console, network, sources, resources,
701    /// timeline, chrome-recorder, heap-profiler, lighthouse, and security.
702    #[serde(rename = "panelId", default, skip_serializing_if = "Option::is_none")]
703    pub panel_id: Option<String>,
704}
705
706/// What `Target.openDevTools` answers with.
707#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
708pub struct OpenDevToolsReturns {
709    /// The targetId of DevTools page target.
710    #[serde(rename = "targetId")]
711    pub target_id: TargetId,
712}
713
714impl crate::typed::Command for OpenDevToolsParams {
715    const METHOD: &'static str = "Target.openDevTools";
716    type Returns = OpenDevToolsReturns;
717}
718
719/// Issued when attached to target because of auto-attach or `attachToTarget`
720/// command.
721///
722/// Experimental: may change without notice.
723///
724/// Payload of the `Target.attachedToTarget` event.
725#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
726pub struct AttachedToTargetEvent {
727    /// Identifier assigned to the session used to send/receive messages.
728    #[serde(rename = "sessionId")]
729    pub session_id: SessionId,
730    #[serde(rename = "targetInfo")]
731    pub target_info: TargetInfo,
732    #[serde(rename = "waitingForDebugger")]
733    pub waiting_for_debugger: bool,
734}
735
736impl crate::typed::Event for AttachedToTargetEvent {
737    const METHOD: &'static str = "Target.attachedToTarget";
738}
739
740/// Issued when detached from target for any reason (including
741/// `detachFromTarget` command). Can be issued multiple times per target if
742/// multiple sessions have been attached to it.
743///
744/// Experimental: may change without notice.
745///
746/// Payload of the `Target.detachedFromTarget` event.
747#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
748pub struct DetachedFromTargetEvent {
749    /// Detached session identifier.
750    #[serde(rename = "sessionId")]
751    pub session_id: SessionId,
752    /// Deprecated.
753    ///
754    /// Deprecated in the protocol.
755    #[serde(rename = "targetId", default, skip_serializing_if = "Option::is_none")]
756    pub target_id: Option<TargetId>,
757}
758
759impl crate::typed::Event for DetachedFromTargetEvent {
760    const METHOD: &'static str = "Target.detachedFromTarget";
761}
762
763/// Notifies about a new protocol message received from the session (as
764/// reported in `attachedToTarget` event).
765///
766/// Payload of the `Target.receivedMessageFromTarget` event.
767#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
768pub struct ReceivedMessageFromTargetEvent {
769    /// Identifier of a session which sends a message.
770    #[serde(rename = "sessionId")]
771    pub session_id: SessionId,
772    pub message: String,
773    /// Deprecated.
774    ///
775    /// Deprecated in the protocol.
776    #[serde(rename = "targetId", default, skip_serializing_if = "Option::is_none")]
777    pub target_id: Option<TargetId>,
778}
779
780impl crate::typed::Event for ReceivedMessageFromTargetEvent {
781    const METHOD: &'static str = "Target.receivedMessageFromTarget";
782}
783
784/// Issued when a possible inspection target is created.
785///
786/// Payload of the `Target.targetCreated` event.
787#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
788pub struct TargetCreatedEvent {
789    #[serde(rename = "targetInfo")]
790    pub target_info: TargetInfo,
791}
792
793impl crate::typed::Event for TargetCreatedEvent {
794    const METHOD: &'static str = "Target.targetCreated";
795}
796
797/// Issued when a target is destroyed.
798///
799/// Payload of the `Target.targetDestroyed` event.
800#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
801pub struct TargetDestroyedEvent {
802    #[serde(rename = "targetId")]
803    pub target_id: TargetId,
804}
805
806impl crate::typed::Event for TargetDestroyedEvent {
807    const METHOD: &'static str = "Target.targetDestroyed";
808}
809
810/// Issued when a target has crashed.
811///
812/// Payload of the `Target.targetCrashed` event.
813#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
814pub struct TargetCrashedEvent {
815    #[serde(rename = "targetId")]
816    pub target_id: TargetId,
817    /// Termination status type.
818    pub status: String,
819    /// Termination error code.
820    #[serde(rename = "errorCode")]
821    pub error_code: i64,
822}
823
824impl crate::typed::Event for TargetCrashedEvent {
825    const METHOD: &'static str = "Target.targetCrashed";
826}
827
828/// Issued when some information about a target has changed. This only happens
829/// between `targetCreated` and `targetDestroyed`.
830///
831/// Payload of the `Target.targetInfoChanged` event.
832#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
833pub struct TargetInfoChangedEvent {
834    #[serde(rename = "targetInfo")]
835    pub target_info: TargetInfo,
836}
837
838impl crate::typed::Event for TargetInfoChangedEvent {
839    const METHOD: &'static str = "Target.targetInfoChanged";
840}