1use serde::{Serialize, Deserialize};
3use serde_json::Value as JsonValue;
4
5
6pub type TargetID = String;
7
8pub type SessionID = String;
11
12
13#[derive(Debug, Clone, Serialize, Deserialize, Default)]
14#[serde(rename_all = "camelCase")]
15pub struct TargetInfo {
16
17 pub targetId: TargetID,
18 #[serde(rename = "type")]
21 pub type_: String,
22
23 pub title: String,
24
25 pub url: String,
26 pub attached: bool,
29 #[serde(skip_serializing_if = "Option::is_none")]
32 pub openerId: Option<TargetID>,
33 pub canAccessOpener: bool,
36 #[serde(skip_serializing_if = "Option::is_none")]
39 pub openerFrameId: Option<crate::page::FrameId>,
40 #[serde(skip_serializing_if = "Option::is_none")]
44 pub parentFrameId: Option<crate::page::FrameId>,
45
46 #[serde(skip_serializing_if = "Option::is_none")]
47 pub browserContextId: Option<crate::browser::BrowserContextID>,
48 #[serde(skip_serializing_if = "Option::is_none")]
52 pub subtype: Option<String>,
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize, Default)]
58#[serde(rename_all = "camelCase")]
59pub struct FilterEntry {
60 #[serde(skip_serializing_if = "Option::is_none")]
63 pub exclude: Option<bool>,
64 #[serde(skip_serializing_if = "Option::is_none")]
67 #[serde(rename = "type")]
68 pub type_: Option<String>,
69}
70
71pub type TargetFilter = Vec<FilterEntry>;
79
80
81#[derive(Debug, Clone, Serialize, Deserialize, Default)]
82#[serde(rename_all = "camelCase")]
83pub struct RemoteLocation {
84
85 pub host: String,
86
87 pub port: i64,
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
93pub enum WindowState {
94 #[default]
95 Normal,
96 Minimized,
97 Maximized,
98 Fullscreen,
99}
100
101#[derive(Debug, Clone, Serialize, Deserialize, Default)]
104#[serde(rename_all = "camelCase")]
105pub struct ActivateTargetParams {
106
107 pub targetId: TargetID,
108}
109
110impl ActivateTargetParams { pub const METHOD: &'static str = "Target.activateTarget"; }
111
112impl crate::CdpCommand for ActivateTargetParams {
113 const METHOD: &'static str = "Target.activateTarget";
114 type Response = crate::EmptyReturns;
115}
116
117#[derive(Debug, Clone, Serialize, Deserialize, Default)]
120#[serde(rename_all = "camelCase")]
121pub struct AttachToTargetParams {
122
123 pub targetId: TargetID,
124 #[serde(skip_serializing_if = "Option::is_none")]
129 pub flatten: Option<bool>,
130}
131
132#[derive(Debug, Clone, Serialize, Deserialize, Default)]
135#[serde(rename_all = "camelCase")]
136pub struct AttachToTargetReturns {
137 pub sessionId: SessionID,
140}
141
142impl AttachToTargetParams { pub const METHOD: &'static str = "Target.attachToTarget"; }
143
144impl crate::CdpCommand for AttachToTargetParams {
145 const METHOD: &'static str = "Target.attachToTarget";
146 type Response = AttachToTargetReturns;
147}
148
149#[derive(Debug, Clone, Serialize, Deserialize, Default)]
152#[serde(rename_all = "camelCase")]
153pub struct AttachToBrowserTargetReturns {
154 pub sessionId: SessionID,
157}
158
159#[derive(Debug, Clone, Serialize, Deserialize, Default)]
160pub struct AttachToBrowserTargetParams {}
161
162impl AttachToBrowserTargetParams { pub const METHOD: &'static str = "Target.attachToBrowserTarget"; }
163
164impl crate::CdpCommand for AttachToBrowserTargetParams {
165 const METHOD: &'static str = "Target.attachToBrowserTarget";
166 type Response = AttachToBrowserTargetReturns;
167}
168
169#[derive(Debug, Clone, Serialize, Deserialize, Default)]
172#[serde(rename_all = "camelCase")]
173pub struct CloseTargetParams {
174
175 pub targetId: TargetID,
176}
177
178#[derive(Debug, Clone, Serialize, Deserialize, Default)]
181#[serde(rename_all = "camelCase")]
182pub struct CloseTargetReturns {
183 pub success: bool,
186}
187
188impl CloseTargetParams { pub const METHOD: &'static str = "Target.closeTarget"; }
189
190impl crate::CdpCommand for CloseTargetParams {
191 const METHOD: &'static str = "Target.closeTarget";
192 type Response = CloseTargetReturns;
193}
194
195#[derive(Debug, Clone, Serialize, Deserialize, Default)]
205#[serde(rename_all = "camelCase")]
206pub struct ExposeDevToolsProtocolParams {
207
208 pub targetId: TargetID,
209 #[serde(skip_serializing_if = "Option::is_none")]
212 pub bindingName: Option<String>,
213 #[serde(skip_serializing_if = "Option::is_none")]
216 pub inheritPermissions: Option<bool>,
217}
218
219impl ExposeDevToolsProtocolParams { pub const METHOD: &'static str = "Target.exposeDevToolsProtocol"; }
220
221impl crate::CdpCommand for ExposeDevToolsProtocolParams {
222 const METHOD: &'static str = "Target.exposeDevToolsProtocol";
223 type Response = crate::EmptyReturns;
224}
225
226#[derive(Debug, Clone, Serialize, Deserialize, Default)]
230#[serde(rename_all = "camelCase")]
231pub struct CreateBrowserContextParams {
232 #[serde(skip_serializing_if = "Option::is_none")]
235 pub disposeOnDetach: Option<bool>,
236 #[serde(skip_serializing_if = "Option::is_none")]
239 pub proxyServer: Option<String>,
240 #[serde(skip_serializing_if = "Option::is_none")]
243 pub proxyBypassList: Option<String>,
244 #[serde(skip_serializing_if = "Option::is_none")]
248 pub originsWithUniversalNetworkAccess: Option<Vec<String>>,
249}
250
251#[derive(Debug, Clone, Serialize, Deserialize, Default)]
255#[serde(rename_all = "camelCase")]
256pub struct CreateBrowserContextReturns {
257 pub browserContextId: crate::browser::BrowserContextID,
260}
261
262impl CreateBrowserContextParams { pub const METHOD: &'static str = "Target.createBrowserContext"; }
263
264impl crate::CdpCommand for CreateBrowserContextParams {
265 const METHOD: &'static str = "Target.createBrowserContext";
266 type Response = CreateBrowserContextReturns;
267}
268
269#[derive(Debug, Clone, Serialize, Deserialize, Default)]
272#[serde(rename_all = "camelCase")]
273pub struct GetBrowserContextsReturns {
274 pub browserContextIds: Vec<crate::browser::BrowserContextID>,
277 #[serde(skip_serializing_if = "Option::is_none")]
280 pub defaultBrowserContextId: Option<crate::browser::BrowserContextID>,
281}
282
283#[derive(Debug, Clone, Serialize, Deserialize, Default)]
284pub struct GetBrowserContextsParams {}
285
286impl GetBrowserContextsParams { pub const METHOD: &'static str = "Target.getBrowserContexts"; }
287
288impl crate::CdpCommand for GetBrowserContextsParams {
289 const METHOD: &'static str = "Target.getBrowserContexts";
290 type Response = GetBrowserContextsReturns;
291}
292
293#[derive(Debug, Clone, Serialize, Deserialize, Default)]
296#[serde(rename_all = "camelCase")]
297pub struct CreateTargetParams {
298 pub url: String,
301 #[serde(skip_serializing_if = "Option::is_none")]
304 pub left: Option<i64>,
305 #[serde(skip_serializing_if = "Option::is_none")]
308 pub top: Option<i64>,
309 #[serde(skip_serializing_if = "Option::is_none")]
312 pub width: Option<u64>,
313 #[serde(skip_serializing_if = "Option::is_none")]
316 pub height: Option<i64>,
317 #[serde(skip_serializing_if = "Option::is_none")]
321 pub windowState: Option<WindowState>,
322 #[serde(skip_serializing_if = "Option::is_none")]
325 pub browserContextId: Option<crate::browser::BrowserContextID>,
326 #[serde(skip_serializing_if = "Option::is_none")]
330 pub enableBeginFrameControl: Option<bool>,
331 #[serde(skip_serializing_if = "Option::is_none")]
334 pub newWindow: Option<bool>,
335 #[serde(skip_serializing_if = "Option::is_none")]
339 pub background: Option<bool>,
340 #[serde(skip_serializing_if = "Option::is_none")]
343 pub forTab: Option<bool>,
344 #[serde(skip_serializing_if = "Option::is_none")]
349 pub hidden: Option<bool>,
350 #[serde(skip_serializing_if = "Option::is_none")]
359 pub focus: Option<bool>,
360}
361
362#[derive(Debug, Clone, Serialize, Deserialize, Default)]
365#[serde(rename_all = "camelCase")]
366pub struct CreateTargetReturns {
367 pub targetId: TargetID,
370}
371
372impl CreateTargetParams { pub const METHOD: &'static str = "Target.createTarget"; }
373
374impl crate::CdpCommand for CreateTargetParams {
375 const METHOD: &'static str = "Target.createTarget";
376 type Response = CreateTargetReturns;
377}
378
379#[derive(Debug, Clone, Serialize, Deserialize, Default)]
382#[serde(rename_all = "camelCase")]
383pub struct DetachFromTargetParams {
384 #[serde(skip_serializing_if = "Option::is_none")]
387 pub sessionId: Option<SessionID>,
388 #[serde(skip_serializing_if = "Option::is_none")]
391 pub targetId: Option<TargetID>,
392}
393
394impl DetachFromTargetParams { pub const METHOD: &'static str = "Target.detachFromTarget"; }
395
396impl crate::CdpCommand for DetachFromTargetParams {
397 const METHOD: &'static str = "Target.detachFromTarget";
398 type Response = crate::EmptyReturns;
399}
400
401#[derive(Debug, Clone, Serialize, Deserialize, Default)]
405#[serde(rename_all = "camelCase")]
406pub struct DisposeBrowserContextParams {
407
408 pub browserContextId: crate::browser::BrowserContextID,
409}
410
411impl DisposeBrowserContextParams { pub const METHOD: &'static str = "Target.disposeBrowserContext"; }
412
413impl crate::CdpCommand for DisposeBrowserContextParams {
414 const METHOD: &'static str = "Target.disposeBrowserContext";
415 type Response = crate::EmptyReturns;
416}
417
418#[derive(Debug, Clone, Serialize, Deserialize, Default)]
421#[serde(rename_all = "camelCase")]
422pub struct GetTargetInfoParams {
423
424 #[serde(skip_serializing_if = "Option::is_none")]
425 pub targetId: Option<TargetID>,
426}
427
428#[derive(Debug, Clone, Serialize, Deserialize, Default)]
431#[serde(rename_all = "camelCase")]
432pub struct GetTargetInfoReturns {
433
434 pub targetInfo: TargetInfo,
435}
436
437impl GetTargetInfoParams { pub const METHOD: &'static str = "Target.getTargetInfo"; }
438
439impl crate::CdpCommand for GetTargetInfoParams {
440 const METHOD: &'static str = "Target.getTargetInfo";
441 type Response = GetTargetInfoReturns;
442}
443
444#[derive(Debug, Clone, Serialize, Deserialize, Default)]
447#[serde(rename_all = "camelCase")]
448pub struct GetTargetsParams {
449 #[serde(skip_serializing_if = "Option::is_none")]
454 pub filter: Option<TargetFilter>,
455}
456
457#[derive(Debug, Clone, Serialize, Deserialize, Default)]
460#[serde(rename_all = "camelCase")]
461pub struct GetTargetsReturns {
462 pub targetInfos: Vec<TargetInfo>,
465}
466
467impl GetTargetsParams { pub const METHOD: &'static str = "Target.getTargets"; }
468
469impl crate::CdpCommand for GetTargetsParams {
470 const METHOD: &'static str = "Target.getTargets";
471 type Response = GetTargetsReturns;
472}
473
474#[derive(Debug, Clone, Serialize, Deserialize, Default)]
479#[serde(rename_all = "camelCase")]
480pub struct SendMessageToTargetParams {
481
482 pub message: String,
483 #[serde(skip_serializing_if = "Option::is_none")]
486 pub sessionId: Option<SessionID>,
487 #[serde(skip_serializing_if = "Option::is_none")]
490 pub targetId: Option<TargetID>,
491}
492
493impl SendMessageToTargetParams { pub const METHOD: &'static str = "Target.sendMessageToTarget"; }
494
495impl crate::CdpCommand for SendMessageToTargetParams {
496 const METHOD: &'static str = "Target.sendMessageToTarget";
497 type Response = crate::EmptyReturns;
498}
499
500#[derive(Debug, Clone, Serialize, Deserialize, Default)]
510#[serde(rename_all = "camelCase")]
511pub struct SetAutoAttachParams {
512 pub autoAttach: bool,
515 pub waitForDebuggerOnStart: bool,
519 #[serde(skip_serializing_if = "Option::is_none")]
524 pub flatten: Option<bool>,
525 #[serde(skip_serializing_if = "Option::is_none")]
528 pub filter: Option<TargetFilter>,
529}
530
531impl SetAutoAttachParams { pub const METHOD: &'static str = "Target.setAutoAttach"; }
532
533impl crate::CdpCommand for SetAutoAttachParams {
534 const METHOD: &'static str = "Target.setAutoAttach";
535 type Response = crate::EmptyReturns;
536}
537
538#[derive(Debug, Clone, Serialize, Deserialize, Default)]
545#[serde(rename_all = "camelCase")]
546pub struct AutoAttachRelatedParams {
547
548 pub targetId: TargetID,
549 pub waitForDebuggerOnStart: bool,
553 #[serde(skip_serializing_if = "Option::is_none")]
556 pub filter: Option<TargetFilter>,
557}
558
559impl AutoAttachRelatedParams { pub const METHOD: &'static str = "Target.autoAttachRelated"; }
560
561impl crate::CdpCommand for AutoAttachRelatedParams {
562 const METHOD: &'static str = "Target.autoAttachRelated";
563 type Response = crate::EmptyReturns;
564}
565
566#[derive(Debug, Clone, Serialize, Deserialize, Default)]
570#[serde(rename_all = "camelCase")]
571pub struct SetDiscoverTargetsParams {
572 pub discover: bool,
575 #[serde(skip_serializing_if = "Option::is_none")]
579 pub filter: Option<TargetFilter>,
580}
581
582impl SetDiscoverTargetsParams { pub const METHOD: &'static str = "Target.setDiscoverTargets"; }
583
584impl crate::CdpCommand for SetDiscoverTargetsParams {
585 const METHOD: &'static str = "Target.setDiscoverTargets";
586 type Response = crate::EmptyReturns;
587}
588
589#[derive(Debug, Clone, Serialize, Deserialize, Default)]
593#[serde(rename_all = "camelCase")]
594pub struct SetRemoteLocationsParams {
595 pub locations: Vec<RemoteLocation>,
598}
599
600impl SetRemoteLocationsParams { pub const METHOD: &'static str = "Target.setRemoteLocations"; }
601
602impl crate::CdpCommand for SetRemoteLocationsParams {
603 const METHOD: &'static str = "Target.setRemoteLocations";
604 type Response = crate::EmptyReturns;
605}
606
607#[derive(Debug, Clone, Serialize, Deserialize, Default)]
611#[serde(rename_all = "camelCase")]
612pub struct GetDevToolsTargetParams {
613 pub targetId: TargetID,
616}
617
618#[derive(Debug, Clone, Serialize, Deserialize, Default)]
622#[serde(rename_all = "camelCase")]
623pub struct GetDevToolsTargetReturns {
624 #[serde(skip_serializing_if = "Option::is_none")]
627 pub targetId: Option<TargetID>,
628}
629
630impl GetDevToolsTargetParams { pub const METHOD: &'static str = "Target.getDevToolsTarget"; }
631
632impl crate::CdpCommand for GetDevToolsTargetParams {
633 const METHOD: &'static str = "Target.getDevToolsTarget";
634 type Response = GetDevToolsTargetReturns;
635}
636
637#[derive(Debug, Clone, Serialize, Deserialize, Default)]
640#[serde(rename_all = "camelCase")]
641pub struct OpenDevToolsParams {
642 pub targetId: TargetID,
645 #[serde(skip_serializing_if = "Option::is_none")]
650 pub panelId: Option<String>,
651}
652
653#[derive(Debug, Clone, Serialize, Deserialize, Default)]
656#[serde(rename_all = "camelCase")]
657pub struct OpenDevToolsReturns {
658 pub targetId: TargetID,
661}
662
663impl OpenDevToolsParams { pub const METHOD: &'static str = "Target.openDevTools"; }
664
665impl crate::CdpCommand for OpenDevToolsParams {
666 const METHOD: &'static str = "Target.openDevTools";
667 type Response = OpenDevToolsReturns;
668}