1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
///命令 marker、完整参数与成功响应。
pub mod commands;
///事件 marker 和拥有型事件参数。
pub mod events;
///命名协议类型;不包含连接状态。
pub mod types;
///薄 Domain 视图,仅借用 Session;创建不发送数据。协议来源:Target。
///
///协议原文:
///
///<pre>Supports additional targets discovery and allows to attach to them.</pre>
///
///
pub struct Domain<'a> {
///借用的通信路由,生命周期不超过 Session。
pub(super) session: &'a ydp_core::Session,
}
impl<'a> Domain<'a> {
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.activateTarget。
///
///协议原文:
///
///<pre>Activates (focuses) the target.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::ActivateTargetParams) -> ydp_core::Result<()> {
///let response = session.target().activate_target(params).await?;
///# Ok(())
///# }
///```
pub fn activate_target(
&self,
params: commands::ActivateTargetParams,
) -> ydp_core::Request<commands::ActivateTarget> {
self.session.send::<commands::ActivateTarget>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.attachToBrowserTarget。
///
///协议原文:
///
///<pre>Attaches to the browser target, only uses flat sessionId mode.</pre>
///
///此项为 experimental,端点可能不支持。
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::AttachToBrowserTargetParams) -> ydp_core::Result<()> {
///let response = session.target().attach_to_browser_target(params).await?;
///# Ok(())
///# }
///```
pub fn attach_to_browser_target(
&self,
params: commands::AttachToBrowserTargetParams,
) -> ydp_core::Request<commands::AttachToBrowserTarget> {
self.session.send::<commands::AttachToBrowserTarget>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.attachToTarget。
///
///协议原文:
///
///<pre>Attaches to the target with given id.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::AttachToTargetParams) -> ydp_core::Result<()> {
///let response = session.target().attach_to_target(params).await?;
///# Ok(())
///# }
///```
pub fn attach_to_target(
&self,
params: commands::AttachToTargetParams,
) -> ydp_core::Request<commands::AttachToTarget> {
self.session.send::<commands::AttachToTarget>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.autoAttachRelated。
///
///协议原文:
///
///<pre>Adds the specified target to the list of targets that will be monitored for any related target
///creation (such as child frames, child workers and new versions of service worker) and reported
///through `attachedToTarget`. The specified target is also auto-attached.
///This cancels the effect of any previous `setAutoAttach` and is also cancelled by subsequent
///`setAutoAttach`. Only available at the Browser target.</pre>
///
///此项为 experimental,端点可能不支持。
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::AutoAttachRelatedParams) -> ydp_core::Result<()> {
///let response = session.target().auto_attach_related(params).await?;
///# Ok(())
///# }
///```
pub fn auto_attach_related(
&self,
params: commands::AutoAttachRelatedParams,
) -> ydp_core::Request<commands::AutoAttachRelated> {
self.session.send::<commands::AutoAttachRelated>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.closeTarget。
///
///协议原文:
///
///<pre>Closes the target. If the target is a page that gets closed too.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::CloseTargetParams) -> ydp_core::Result<()> {
///let response = session.target().close_target(params).await?;
///# Ok(())
///# }
///```
pub fn close_target(
&self,
params: commands::CloseTargetParams,
) -> ydp_core::Request<commands::CloseTarget> {
self.session.send::<commands::CloseTarget>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.createBrowserContext。
///
///协议原文:
///
///<pre>Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than
///one.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::CreateBrowserContextParams) -> ydp_core::Result<()> {
///let response = session.target().create_browser_context(params).await?;
///# Ok(())
///# }
///```
pub fn create_browser_context(
&self,
params: commands::CreateBrowserContextParams,
) -> ydp_core::Request<commands::CreateBrowserContext> {
self.session.send::<commands::CreateBrowserContext>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.createTarget。
///
///协议原文:
///
///<pre>Creates a new page.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::CreateTargetParams) -> ydp_core::Result<()> {
///let response = session.target().create_target(params).await?;
///# Ok(())
///# }
///```
pub fn create_target(
&self,
params: commands::CreateTargetParams,
) -> ydp_core::Request<commands::CreateTarget> {
self.session.send::<commands::CreateTarget>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.detachFromTarget。
///
///协议原文:
///
///<pre>Detaches session with given id.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::DetachFromTargetParams) -> ydp_core::Result<()> {
///let response = session.target().detach_from_target(params).await?;
///# Ok(())
///# }
///```
pub fn detach_from_target(
&self,
params: commands::DetachFromTargetParams,
) -> ydp_core::Request<commands::DetachFromTarget> {
self.session.send::<commands::DetachFromTarget>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.disposeBrowserContext。
///
///协议原文:
///
///<pre>Deletes a BrowserContext. All the belonging pages will be closed without calling their
///beforeunload hooks.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::DisposeBrowserContextParams) -> ydp_core::Result<()> {
///let response = session.target().dispose_browser_context(params).await?;
///# Ok(())
///# }
///```
pub fn dispose_browser_context(
&self,
params: commands::DisposeBrowserContextParams,
) -> ydp_core::Request<commands::DisposeBrowserContext> {
self.session.send::<commands::DisposeBrowserContext>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.exposeDevToolsProtocol。
///
///协议原文:
///
///<pre>Inject object to the target's main frame that provides a communication
///channel with browser target.
///
///Injected object will be available as `window[bindingName]`.
///
///The object has the following API:
///- `binding.send(json)` - a method to send messages over the remote debugging protocol
///- `binding.onmessage = json => handleMessage(json)` - a callback that will be called for the protocol notifications and command responses.</pre>
///
///此项为 experimental,端点可能不支持。
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::ExposeDevToolsProtocolParams) -> ydp_core::Result<()> {
///let response = session.target().expose_dev_tools_protocol(params).await?;
///# Ok(())
///# }
///```
pub fn expose_dev_tools_protocol(
&self,
params: commands::ExposeDevToolsProtocolParams,
) -> ydp_core::Request<commands::ExposeDevToolsProtocol> {
self.session
.send::<commands::ExposeDevToolsProtocol>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.getBrowserContexts。
///
///协议原文:
///
///<pre>Returns all browser contexts created with `Target.createBrowserContext` method.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::GetBrowserContextsParams) -> ydp_core::Result<()> {
///let response = session.target().get_browser_contexts(params).await?;
///# Ok(())
///# }
///```
pub fn get_browser_contexts(
&self,
params: commands::GetBrowserContextsParams,
) -> ydp_core::Request<commands::GetBrowserContexts> {
self.session.send::<commands::GetBrowserContexts>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.getDevToolsTarget。
///
///协议原文:
///
///<pre>Gets the targetId of the DevTools page target opened for the given target
///(if any).</pre>
///
///此项为 experimental,端点可能不支持。
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::GetDevToolsTargetParams) -> ydp_core::Result<()> {
///let response = session.target().get_dev_tools_target(params).await?;
///# Ok(())
///# }
///```
pub fn get_dev_tools_target(
&self,
params: commands::GetDevToolsTargetParams,
) -> ydp_core::Request<commands::GetDevToolsTarget> {
self.session.send::<commands::GetDevToolsTarget>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.getTargetInfo。
///
///协议原文:
///
///<pre>Returns information about a target.</pre>
///
///此项为 experimental,端点可能不支持。
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::GetTargetInfoParams) -> ydp_core::Result<()> {
///let response = session.target().get_target_info(params).await?;
///# Ok(())
///# }
///```
pub fn get_target_info(
&self,
params: commands::GetTargetInfoParams,
) -> ydp_core::Request<commands::GetTargetInfo> {
self.session.send::<commands::GetTargetInfo>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.getTargets。
///
///协议原文:
///
///<pre>Retrieves a list of available targets.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::GetTargetsParams) -> ydp_core::Result<()> {
///let response = session.target().get_targets(params).await?;
///# Ok(())
///# }
///```
pub fn get_targets(
&self,
params: commands::GetTargetsParams,
) -> ydp_core::Request<commands::GetTargets> {
self.session.send::<commands::GetTargets>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.openDevTools。
///
///协议原文:
///
///<pre>Opens a DevTools window for the target.</pre>
///
///此项为 experimental,端点可能不支持。
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::OpenDevToolsParams) -> ydp_core::Result<()> {
///let response = session.target().open_dev_tools(params).await?;
///# Ok(())
///# }
///```
pub fn open_dev_tools(
&self,
params: commands::OpenDevToolsParams,
) -> ydp_core::Request<commands::OpenDevTools> {
self.session.send::<commands::OpenDevTools>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.sendMessageToTarget。
///
///协议原文:
///
///<pre>Sends protocol message over session with given id.
///Consider using flat mode instead; see commands attachToTarget, setAutoAttach,
///and crbug.com/991325.</pre>
///
///此项已 deprecated,保留用于旧端点兼容。
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::SendMessageToTargetParams) -> ydp_core::Result<()> {
///let response = session.target().send_message_to_target(params).await?;
///# Ok(())
///# }
///```
pub fn send_message_to_target(
&self,
params: commands::SendMessageToTargetParams,
) -> ydp_core::Request<commands::SendMessageToTarget> {
self.session.send::<commands::SendMessageToTarget>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.setAutoAttach。
///
///协议原文:
///
///<pre>Controls whether to automatically attach to new targets which are considered
///to be directly related to this one (for example, iframes or workers).
///When turned on, attaches to all existing related targets as well. When turned off,
///automatically detaches from all currently attached targets.
///This also clears all targets added by `autoAttachRelated` from the list of targets to watch
///for creation of related targets.
///You might want to call this recursively for auto-attached targets to attach
///to all available targets.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::SetAutoAttachParams) -> ydp_core::Result<()> {
///let response = session.target().set_auto_attach(params).await?;
///# Ok(())
///# }
///```
pub fn set_auto_attach(
&self,
params: commands::SetAutoAttachParams,
) -> ydp_core::Request<commands::SetAutoAttach> {
self.session.send::<commands::SetAutoAttach>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.setDiscoverTargets。
///
///协议原文:
///
///<pre>Controls whether to discover available targets and notify via
///`targetCreated/targetInfoChanged/targetDestroyed` events.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::SetDiscoverTargetsParams) -> ydp_core::Result<()> {
///let response = session.target().set_discover_targets(params).await?;
///# Ok(())
///# }
///```
pub fn set_discover_targets(
&self,
params: commands::SetDiscoverTargetsParams,
) -> ydp_core::Request<commands::SetDiscoverTargets> {
self.session.send::<commands::SetDiscoverTargets>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Target.command.setRemoteLocations。
///
///协议原文:
///
///<pre>Enables target discovery for the specified locations, when `setDiscoverTargets` was set to
///`true`.</pre>
///
///此项为 experimental,端点可能不支持。
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::target::commands::SetRemoteLocationsParams) -> ydp_core::Result<()> {
///let response = session.target().set_remote_locations(params).await?;
///# Ok(())
///# }
///```
pub fn set_remote_locations(
&self,
params: commands::SetRemoteLocationsParams,
) -> ydp_core::Request<commands::SetRemoteLocations> {
self.session.send::<commands::SetRemoteLocations>(params)
}
}