rustenium-bidi-definitions 0.1.1

Generated WebDriver BiDi protocol type definitions for Rustenium
Documentation
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
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ActivateParams {
    #[serde(rename = "context")]
    pub context: super::types::BrowsingContext,
}
impl ActivateParams {
    pub fn new(context: impl Into<super::types::BrowsingContext>) -> Self {
        Self {
            context: context.into(),
        }
    }
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum ActivateMethod {
    #[serde(rename = "browsingContext.activate")]
    Activate,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Activate {
    pub method: ActivateMethod,
    pub params: ActivateParams,
}
impl Activate {
    pub const IDENTIFIER: &'static str = "browsingContext.activate";
    pub const DOMAIN_DIRECTION: &'static str = "remote";
    pub fn identifier(&self) -> &'static str {
        Self::IDENTIFIER
    }
}
impl crate::CommandResult for Activate {
    type Result = super::results::ActivateResult;
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CaptureScreenshotParams {
    #[serde(rename = "context")]
    pub context: super::types::BrowsingContext,
    #[serde(rename = "origin")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub origin: Option<CaptureScreenshotOrigin>,
    #[serde(rename = "format")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub format: Option<super::types::ImageFormat>,
    #[serde(rename = "clip")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub clip: Option<super::types::ClipRectangle>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum CaptureScreenshotOrigin {
    #[serde(rename = "viewport")]
    Viewport,
    #[serde(rename = "document")]
    Document,
}
impl CaptureScreenshotParams {
    pub fn new(context: impl Into<super::types::BrowsingContext>) -> Self {
        Self {
            context: context.into(),
            origin: None,
            format: None,
            clip: None,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum CaptureScreenshotMethod {
    #[serde(rename = "browsingContext.captureScreenshot")]
    CaptureScreenshot,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CaptureScreenshot {
    pub method: CaptureScreenshotMethod,
    pub params: CaptureScreenshotParams,
}
impl CaptureScreenshot {
    pub const IDENTIFIER: &'static str = "browsingContext.captureScreenshot";
    pub const DOMAIN_DIRECTION: &'static str = "remote";
    pub fn identifier(&self) -> &'static str {
        Self::IDENTIFIER
    }
}
impl crate::CommandResult for CaptureScreenshot {
    type Result = super::results::CaptureScreenshotResult;
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CloseParams {
    #[serde(rename = "context")]
    pub context: super::types::BrowsingContext,
    #[serde(rename = "promptUnload")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "default_close_params_prompt_unload")]
    pub prompt_unload: Option<bool>,
}
fn default_close_params_prompt_unload() -> Option<bool> {
    Some(false)
}
impl CloseParams {
    pub fn new(context: impl Into<super::types::BrowsingContext>) -> Self {
        Self {
            context: context.into(),
            prompt_unload: None,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum CloseMethod {
    #[serde(rename = "browsingContext.close")]
    Close,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Close {
    pub method: CloseMethod,
    pub params: CloseParams,
}
impl Close {
    pub const IDENTIFIER: &'static str = "browsingContext.close";
    pub const DOMAIN_DIRECTION: &'static str = "remote";
    pub fn identifier(&self) -> &'static str {
        Self::IDENTIFIER
    }
}
impl crate::CommandResult for Close {
    type Result = super::results::CloseResult;
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CreateParams {
    #[serde(rename = "type")]
    pub r#type: super::types::CreateType,
    #[serde(rename = "referenceContext")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub reference_context: Option<super::types::BrowsingContext>,
    #[serde(rename = "background")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "default_create_params_background")]
    pub background: Option<bool>,
    #[serde(rename = "userContext")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub user_context: Option<crate::browser::types::UserContext>,
}
fn default_create_params_background() -> Option<bool> {
    Some(false)
}
impl CreateParams {
    pub fn new(r#type: impl Into<super::types::CreateType>) -> Self {
        Self {
            r#type: r#type.into(),
            reference_context: None,
            background: None,
            user_context: None,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum CreateMethod {
    #[serde(rename = "browsingContext.create")]
    Create,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Create {
    pub method: CreateMethod,
    pub params: CreateParams,
}
impl Create {
    pub const IDENTIFIER: &'static str = "browsingContext.create";
    pub const DOMAIN_DIRECTION: &'static str = "remote";
    pub fn identifier(&self) -> &'static str {
        Self::IDENTIFIER
    }
}
impl crate::CommandResult for Create {
    type Result = super::results::CreateResult;
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct GetTreeParams {
    #[serde(rename = "maxDepth")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub max_depth: Option<u64>,
    #[serde(rename = "root")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub root: Option<super::types::BrowsingContext>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum GetTreeMethod {
    #[serde(rename = "browsingContext.getTree")]
    GetTree,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct GetTree {
    pub method: GetTreeMethod,
    pub params: GetTreeParams,
}
impl GetTree {
    pub const IDENTIFIER: &'static str = "browsingContext.getTree";
    pub const DOMAIN_DIRECTION: &'static str = "remote";
    pub fn identifier(&self) -> &'static str {
        Self::IDENTIFIER
    }
}
impl crate::CommandResult for GetTree {
    type Result = super::results::GetTreeResult;
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct HandleUserPromptParams {
    #[serde(rename = "context")]
    pub context: super::types::BrowsingContext,
    #[serde(rename = "accept")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub accept: Option<bool>,
    #[serde(rename = "userText")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub user_text: Option<String>,
}
impl HandleUserPromptParams {
    pub fn new(context: impl Into<super::types::BrowsingContext>) -> Self {
        Self {
            context: context.into(),
            accept: None,
            user_text: None,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum HandleUserPromptMethod {
    #[serde(rename = "browsingContext.handleUserPrompt")]
    HandleUserPrompt,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct HandleUserPrompt {
    pub method: HandleUserPromptMethod,
    pub params: HandleUserPromptParams,
}
impl HandleUserPrompt {
    pub const IDENTIFIER: &'static str = "browsingContext.handleUserPrompt";
    pub const DOMAIN_DIRECTION: &'static str = "remote";
    pub fn identifier(&self) -> &'static str {
        Self::IDENTIFIER
    }
}
impl crate::CommandResult for HandleUserPrompt {
    type Result = super::results::HandleUserPromptResult;
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, serde_valid :: Validate)]
pub struct LocateNodesParams {
    #[serde(rename = "context")]
    pub context: super::types::BrowsingContext,
    #[serde(rename = "locator")]
    pub locator: super::types::Locator,
    #[serde(rename = "maxNodeCount")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    #[validate(minimum = 1u64)]
    pub max_node_count: Option<u64>,
    #[serde(rename = "serializationOptions")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub serialization_options: Option<crate::script::types::SerializationOptions>,
    #[serde(rename = "startNodes")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub start_nodes: Option<Vec<crate::script::types::SharedReference>>,
}
impl LocateNodesParams {
    pub fn new(
        context: impl Into<super::types::BrowsingContext>,
        locator: impl Into<super::types::Locator>,
    ) -> Self {
        Self {
            context: context.into(),
            locator: locator.into(),
            max_node_count: None,
            serialization_options: None,
            start_nodes: None,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum LocateNodesMethod {
    #[serde(rename = "browsingContext.locateNodes")]
    LocateNodes,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct LocateNodes {
    pub method: LocateNodesMethod,
    pub params: LocateNodesParams,
}
impl LocateNodes {
    pub const IDENTIFIER: &'static str = "browsingContext.locateNodes";
    pub const DOMAIN_DIRECTION: &'static str = "remote";
    pub fn identifier(&self) -> &'static str {
        Self::IDENTIFIER
    }
}
impl crate::CommandResult for LocateNodes {
    type Result = super::results::LocateNodesResult;
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct NavigateParams {
    #[serde(rename = "context")]
    pub context: super::types::BrowsingContext,
    #[serde(rename = "url")]
    pub url: String,
    #[serde(rename = "wait")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub wait: Option<super::types::ReadinessState>,
}
impl NavigateParams {
    pub fn new(context: impl Into<super::types::BrowsingContext>, url: impl Into<String>) -> Self {
        Self {
            context: context.into(),
            url: url.into(),
            wait: None,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum NavigateMethod {
    #[serde(rename = "browsingContext.navigate")]
    Navigate,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Navigate {
    pub method: NavigateMethod,
    pub params: NavigateParams,
}
impl Navigate {
    pub const IDENTIFIER: &'static str = "browsingContext.navigate";
    pub const DOMAIN_DIRECTION: &'static str = "remote";
    pub fn identifier(&self) -> &'static str {
        Self::IDENTIFIER
    }
}
impl crate::CommandResult for Navigate {
    type Result = super::results::NavigateResult;
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PrintParams {
    #[serde(rename = "context")]
    pub context: super::types::BrowsingContext,
    #[serde(rename = "background")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "default_print_params_background")]
    pub background: Option<bool>,
    #[serde(rename = "margin")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub margin: Option<super::types::PrintMarginParameters>,
    #[serde(rename = "orientation")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub orientation: Option<PrintOrientation>,
    #[serde(rename = "page")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub page: Option<super::types::PrintPageParameters>,
    #[serde(rename = "pageRanges")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub page_ranges: Option<Vec<serde_json::Value>>,
    #[serde(rename = "scale")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "default_print_params_scale")]
    pub scale: Option<f64>,
    #[serde(rename = "shrinkToFit")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "default_print_params_shrink_to_fit")]
    pub shrink_to_fit: Option<bool>,
}
fn default_print_params_background() -> Option<bool> {
    Some(false)
}
fn default_print_params_scale() -> Option<f64> {
    Some(1f64)
}
fn default_print_params_shrink_to_fit() -> Option<bool> {
    Some(true)
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PrintOrientation {
    #[serde(rename = "portrait")]
    Portrait,
    #[serde(rename = "landscape")]
    Landscape,
}
impl PrintParams {
    pub fn new(context: impl Into<super::types::BrowsingContext>) -> Self {
        Self {
            context: context.into(),
            background: None,
            margin: None,
            orientation: None,
            page: None,
            page_ranges: None,
            scale: None,
            shrink_to_fit: None,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum PrintMethod {
    #[serde(rename = "browsingContext.print")]
    Print,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Print {
    pub method: PrintMethod,
    pub params: PrintParams,
}
impl Print {
    pub const IDENTIFIER: &'static str = "browsingContext.print";
    pub const DOMAIN_DIRECTION: &'static str = "remote";
    pub fn identifier(&self) -> &'static str {
        Self::IDENTIFIER
    }
}
impl crate::CommandResult for Print {
    type Result = super::results::PrintResult;
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ReloadParams {
    #[serde(rename = "context")]
    pub context: super::types::BrowsingContext,
    #[serde(rename = "ignoreCache")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub ignore_cache: Option<bool>,
    #[serde(rename = "wait")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub wait: Option<super::types::ReadinessState>,
}
impl ReloadParams {
    pub fn new(context: impl Into<super::types::BrowsingContext>) -> Self {
        Self {
            context: context.into(),
            ignore_cache: None,
            wait: None,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum ReloadMethod {
    #[serde(rename = "browsingContext.reload")]
    Reload,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Reload {
    pub method: ReloadMethod,
    pub params: ReloadParams,
}
impl Reload {
    pub const IDENTIFIER: &'static str = "browsingContext.reload";
    pub const DOMAIN_DIRECTION: &'static str = "remote";
    pub fn identifier(&self) -> &'static str {
        Self::IDENTIFIER
    }
}
impl crate::CommandResult for Reload {
    type Result = super::results::ReloadResult;
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, serde_valid :: Validate)]
pub struct SetViewportParams {
    #[serde(rename = "context")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub context: Option<super::types::BrowsingContext>,
    #[serde(rename = "viewport")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub viewport: Option<super::types::Viewport>,
    #[serde(rename = "devicePixelRatio")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    #[validate(exclusive_minimum = 0f64)]
    pub device_pixel_ratio: Option<f64>,
    #[serde(rename = "userContexts")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub user_contexts: Option<Vec<crate::browser::types::UserContext>>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum SetViewportMethod {
    #[serde(rename = "browsingContext.setViewport")]
    SetViewport,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SetViewport {
    pub method: SetViewportMethod,
    pub params: SetViewportParams,
}
impl SetViewport {
    pub const IDENTIFIER: &'static str = "browsingContext.setViewport";
    pub const DOMAIN_DIRECTION: &'static str = "remote";
    pub fn identifier(&self) -> &'static str {
        Self::IDENTIFIER
    }
}
impl crate::CommandResult for SetViewport {
    type Result = super::results::SetViewportResult;
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TraverseHistoryParams {
    #[serde(rename = "context")]
    pub context: super::types::BrowsingContext,
    #[serde(rename = "delta")]
    pub delta: i64,
}
impl TraverseHistoryParams {
    pub fn new(context: impl Into<super::types::BrowsingContext>, delta: impl Into<i64>) -> Self {
        Self {
            context: context.into(),
            delta: delta.into(),
        }
    }
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum TraverseHistoryMethod {
    #[serde(rename = "browsingContext.traverseHistory")]
    TraverseHistory,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TraverseHistory {
    pub method: TraverseHistoryMethod,
    pub params: TraverseHistoryParams,
}
impl TraverseHistory {
    pub const IDENTIFIER: &'static str = "browsingContext.traverseHistory";
    pub const DOMAIN_DIRECTION: &'static str = "remote";
    pub fn identifier(&self) -> &'static str {
        Self::IDENTIFIER
    }
}
impl crate::CommandResult for TraverseHistory {
    type Result = super::results::TraverseHistoryResult;
}
group_enum ! (BrowsingContextCommand { Activate (Activate) , CaptureScreenshot (CaptureScreenshot) , Close (Close) , Create (Create) , GetTree (GetTree) , HandleUserPrompt (HandleUserPrompt) , LocateNodes (LocateNodes) , Navigate (Navigate) , Print (Print) , Reload (Reload) , SetViewport (SetViewport) , TraverseHistory (TraverseHistory) } + identifiable);