browser-protocol 0.1.4

Generated Rust types and commands for the Chrome DevTools Protocol (browser-protocol)
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
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
//! Defines commands and events for browser extensions.


use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue;
use std::borrow::Cow;

/// Storage areas.

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum StorageArea {
    #[default]
    #[serde(rename = "session")]
    Session,
    #[serde(rename = "local")]
    Local,
    #[serde(rename = "sync")]
    Sync,
    #[serde(rename = "managed")]
    Managed,
}

/// Detailed information about an extension.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ExtensionInfo<'a> {
    /// Extension id.
    id: Cow<'a, str>,
    /// Extension name.
    name: Cow<'a, str>,
    /// Extension version.
    version: Cow<'a, str>,
    /// The path from which the extension was loaded.
    path: Cow<'a, str>,
    /// Extension enabled status.
    enabled: bool,
}

impl<'a> ExtensionInfo<'a> {
    /// Creates a builder for this type with the required parameters:
    /// * `id`: Extension id.
    /// * `name`: Extension name.
    /// * `version`: Extension version.
    /// * `path`: The path from which the extension was loaded.
    /// * `enabled`: Extension enabled status.
    pub fn builder(id: impl Into<Cow<'a, str>>, name: impl Into<Cow<'a, str>>, version: impl Into<Cow<'a, str>>, path: impl Into<Cow<'a, str>>, enabled: bool) -> ExtensionInfoBuilder<'a> {
        ExtensionInfoBuilder {
            id: id.into(),
            name: name.into(),
            version: version.into(),
            path: path.into(),
            enabled: enabled,
        }
    }
    /// Extension id.
    pub fn id(&self) -> &str { self.id.as_ref() }
    /// Extension name.
    pub fn name(&self) -> &str { self.name.as_ref() }
    /// Extension version.
    pub fn version(&self) -> &str { self.version.as_ref() }
    /// The path from which the extension was loaded.
    pub fn path(&self) -> &str { self.path.as_ref() }
    /// Extension enabled status.
    pub fn enabled(&self) -> bool { self.enabled }
}


pub struct ExtensionInfoBuilder<'a> {
    id: Cow<'a, str>,
    name: Cow<'a, str>,
    version: Cow<'a, str>,
    path: Cow<'a, str>,
    enabled: bool,
}

impl<'a> ExtensionInfoBuilder<'a> {
    pub fn build(self) -> ExtensionInfo<'a> {
        ExtensionInfo {
            id: self.id,
            name: self.name,
            version: self.version,
            path: self.path,
            enabled: self.enabled,
        }
    }
}

/// Runs an extension default action.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct TriggerActionParams<'a> {
    /// Extension id.
    id: Cow<'a, str>,
    /// A tab target ID to trigger the default extension action on.
    #[serde(rename = "targetId")]
    target_id: Cow<'a, str>,
}

impl<'a> TriggerActionParams<'a> {
    /// Creates a builder for this type with the required parameters:
    /// * `id`: Extension id.
    /// * `target_id`: A tab target ID to trigger the default extension action on.
    pub fn builder(id: impl Into<Cow<'a, str>>, target_id: impl Into<Cow<'a, str>>) -> TriggerActionParamsBuilder<'a> {
        TriggerActionParamsBuilder {
            id: id.into(),
            target_id: target_id.into(),
        }
    }
    /// Extension id.
    pub fn id(&self) -> &str { self.id.as_ref() }
    /// A tab target ID to trigger the default extension action on.
    pub fn target_id(&self) -> &str { self.target_id.as_ref() }
}


pub struct TriggerActionParamsBuilder<'a> {
    id: Cow<'a, str>,
    target_id: Cow<'a, str>,
}

impl<'a> TriggerActionParamsBuilder<'a> {
    pub fn build(self) -> TriggerActionParams<'a> {
        TriggerActionParams {
            id: self.id,
            target_id: self.target_id,
        }
    }
}

impl<'a> TriggerActionParams<'a> { pub const METHOD: &'static str = "Extensions.triggerAction"; }

impl<'a> crate::CdpCommand<'a> for TriggerActionParams<'a> {
    const METHOD: &'static str = "Extensions.triggerAction";
    type Response = crate::EmptyReturns;
}

/// Installs an unpacked extension from the filesystem similar to
/// --load-extension CLI flags. Returns extension ID once the extension
/// has been installed.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct LoadUnpackedParams<'a> {
    /// Absolute file path.
    path: Cow<'a, str>,
    /// Enable the extension in incognito
    #[serde(skip_serializing_if = "Option::is_none", rename = "enableInIncognito")]
    enable_in_incognito: Option<bool>,
}

impl<'a> LoadUnpackedParams<'a> {
    /// Creates a builder for this type with the required parameters:
    /// * `path`: Absolute file path.
    pub fn builder(path: impl Into<Cow<'a, str>>) -> LoadUnpackedParamsBuilder<'a> {
        LoadUnpackedParamsBuilder {
            path: path.into(),
            enable_in_incognito: None,
        }
    }
    /// Absolute file path.
    pub fn path(&self) -> &str { self.path.as_ref() }
    /// Enable the extension in incognito
    pub fn enable_in_incognito(&self) -> Option<bool> { self.enable_in_incognito }
}


pub struct LoadUnpackedParamsBuilder<'a> {
    path: Cow<'a, str>,
    enable_in_incognito: Option<bool>,
}

impl<'a> LoadUnpackedParamsBuilder<'a> {
    /// Enable the extension in incognito
    pub fn enable_in_incognito(mut self, enable_in_incognito: bool) -> Self { self.enable_in_incognito = Some(enable_in_incognito); self }
    pub fn build(self) -> LoadUnpackedParams<'a> {
        LoadUnpackedParams {
            path: self.path,
            enable_in_incognito: self.enable_in_incognito,
        }
    }
}

/// Installs an unpacked extension from the filesystem similar to
/// --load-extension CLI flags. Returns extension ID once the extension
/// has been installed.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct LoadUnpackedReturns<'a> {
    /// Extension id.
    id: Cow<'a, str>,
}

impl<'a> LoadUnpackedReturns<'a> {
    /// Creates a builder for this type with the required parameters:
    /// * `id`: Extension id.
    pub fn builder(id: impl Into<Cow<'a, str>>) -> LoadUnpackedReturnsBuilder<'a> {
        LoadUnpackedReturnsBuilder {
            id: id.into(),
        }
    }
    /// Extension id.
    pub fn id(&self) -> &str { self.id.as_ref() }
}


pub struct LoadUnpackedReturnsBuilder<'a> {
    id: Cow<'a, str>,
}

impl<'a> LoadUnpackedReturnsBuilder<'a> {
    pub fn build(self) -> LoadUnpackedReturns<'a> {
        LoadUnpackedReturns {
            id: self.id,
        }
    }
}

impl<'a> LoadUnpackedParams<'a> { pub const METHOD: &'static str = "Extensions.loadUnpacked"; }

impl<'a> crate::CdpCommand<'a> for LoadUnpackedParams<'a> {
    const METHOD: &'static str = "Extensions.loadUnpacked";
    type Response = LoadUnpackedReturns<'a>;
}

/// Gets a list of all unpacked extensions.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetExtensionsReturns<'a> {
    extensions: Vec<ExtensionInfo<'a>>,
}

impl<'a> GetExtensionsReturns<'a> {
    /// Creates a builder for this type with the required parameters:
    /// * `extensions`: 
    pub fn builder(extensions: Vec<ExtensionInfo<'a>>) -> GetExtensionsReturnsBuilder<'a> {
        GetExtensionsReturnsBuilder {
            extensions: extensions,
        }
    }
    pub fn extensions(&self) -> &[ExtensionInfo<'a>] { &self.extensions }
}


pub struct GetExtensionsReturnsBuilder<'a> {
    extensions: Vec<ExtensionInfo<'a>>,
}

impl<'a> GetExtensionsReturnsBuilder<'a> {
    pub fn build(self) -> GetExtensionsReturns<'a> {
        GetExtensionsReturns {
            extensions: self.extensions,
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct GetExtensionsParams {}

impl GetExtensionsParams { pub const METHOD: &'static str = "Extensions.getExtensions"; }

impl<'a> crate::CdpCommand<'a> for GetExtensionsParams {
    const METHOD: &'static str = "Extensions.getExtensions";
    type Response = GetExtensionsReturns<'a>;
}

/// Uninstalls an unpacked extension (others not supported) from the profile.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct UninstallParams<'a> {
    /// Extension id.
    id: Cow<'a, str>,
}

impl<'a> UninstallParams<'a> {
    /// Creates a builder for this type with the required parameters:
    /// * `id`: Extension id.
    pub fn builder(id: impl Into<Cow<'a, str>>) -> UninstallParamsBuilder<'a> {
        UninstallParamsBuilder {
            id: id.into(),
        }
    }
    /// Extension id.
    pub fn id(&self) -> &str { self.id.as_ref() }
}


pub struct UninstallParamsBuilder<'a> {
    id: Cow<'a, str>,
}

impl<'a> UninstallParamsBuilder<'a> {
    pub fn build(self) -> UninstallParams<'a> {
        UninstallParams {
            id: self.id,
        }
    }
}

impl<'a> UninstallParams<'a> { pub const METHOD: &'static str = "Extensions.uninstall"; }

impl<'a> crate::CdpCommand<'a> for UninstallParams<'a> {
    const METHOD: &'static str = "Extensions.uninstall";
    type Response = crate::EmptyReturns;
}

/// Gets data from extension storage in the given 'storageArea'. If 'keys' is
/// specified, these are used to filter the result.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetStorageItemsParams<'a> {
    /// ID of extension.
    id: Cow<'a, str>,
    /// StorageArea to retrieve data from.
    #[serde(rename = "storageArea")]
    storage_area: StorageArea,
    /// Keys to retrieve.
    #[serde(skip_serializing_if = "Option::is_none")]
    keys: Option<Vec<Cow<'a, str>>>,
}

impl<'a> GetStorageItemsParams<'a> {
    /// Creates a builder for this type with the required parameters:
    /// * `id`: ID of extension.
    /// * `storage_area`: StorageArea to retrieve data from.
    pub fn builder(id: impl Into<Cow<'a, str>>, storage_area: impl Into<StorageArea>) -> GetStorageItemsParamsBuilder<'a> {
        GetStorageItemsParamsBuilder {
            id: id.into(),
            storage_area: storage_area.into(),
            keys: None,
        }
    }
    /// ID of extension.
    pub fn id(&self) -> &str { self.id.as_ref() }
    /// StorageArea to retrieve data from.
    pub fn storage_area(&self) -> &StorageArea { &self.storage_area }
    /// Keys to retrieve.
    pub fn keys(&self) -> Option<&[Cow<'a, str>]> { self.keys.as_deref() }
}


pub struct GetStorageItemsParamsBuilder<'a> {
    id: Cow<'a, str>,
    storage_area: StorageArea,
    keys: Option<Vec<Cow<'a, str>>>,
}

impl<'a> GetStorageItemsParamsBuilder<'a> {
    /// Keys to retrieve.
    pub fn keys(mut self, keys: Vec<Cow<'a, str>>) -> Self { self.keys = Some(keys); self }
    pub fn build(self) -> GetStorageItemsParams<'a> {
        GetStorageItemsParams {
            id: self.id,
            storage_area: self.storage_area,
            keys: self.keys,
        }
    }
}

/// Gets data from extension storage in the given 'storageArea'. If 'keys' is
/// specified, these are used to filter the result.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetStorageItemsReturns {
    data: serde_json::Map<String, JsonValue>,
}

impl GetStorageItemsReturns {
    /// Creates a builder for this type with the required parameters:
    /// * `data`: 
    pub fn builder(data: serde_json::Map<String, JsonValue>) -> GetStorageItemsReturnsBuilder {
        GetStorageItemsReturnsBuilder {
            data: data,
        }
    }
    pub fn data(&self) -> &serde_json::Map<String, JsonValue> { &self.data }
}


pub struct GetStorageItemsReturnsBuilder {
    data: serde_json::Map<String, JsonValue>,
}

impl GetStorageItemsReturnsBuilder {
    pub fn build(self) -> GetStorageItemsReturns {
        GetStorageItemsReturns {
            data: self.data,
        }
    }
}

impl<'a> GetStorageItemsParams<'a> { pub const METHOD: &'static str = "Extensions.getStorageItems"; }

impl<'a> crate::CdpCommand<'a> for GetStorageItemsParams<'a> {
    const METHOD: &'static str = "Extensions.getStorageItems";
    type Response = GetStorageItemsReturns;
}

/// Removes 'keys' from extension storage in the given 'storageArea'.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RemoveStorageItemsParams<'a> {
    /// ID of extension.
    id: Cow<'a, str>,
    /// StorageArea to remove data from.
    #[serde(rename = "storageArea")]
    storage_area: StorageArea,
    /// Keys to remove.
    keys: Vec<Cow<'a, str>>,
}

impl<'a> RemoveStorageItemsParams<'a> {
    /// Creates a builder for this type with the required parameters:
    /// * `id`: ID of extension.
    /// * `storage_area`: StorageArea to remove data from.
    /// * `keys`: Keys to remove.
    pub fn builder(id: impl Into<Cow<'a, str>>, storage_area: impl Into<StorageArea>, keys: Vec<Cow<'a, str>>) -> RemoveStorageItemsParamsBuilder<'a> {
        RemoveStorageItemsParamsBuilder {
            id: id.into(),
            storage_area: storage_area.into(),
            keys: keys,
        }
    }
    /// ID of extension.
    pub fn id(&self) -> &str { self.id.as_ref() }
    /// StorageArea to remove data from.
    pub fn storage_area(&self) -> &StorageArea { &self.storage_area }
    /// Keys to remove.
    pub fn keys(&self) -> &[Cow<'a, str>] { &self.keys }
}


pub struct RemoveStorageItemsParamsBuilder<'a> {
    id: Cow<'a, str>,
    storage_area: StorageArea,
    keys: Vec<Cow<'a, str>>,
}

impl<'a> RemoveStorageItemsParamsBuilder<'a> {
    pub fn build(self) -> RemoveStorageItemsParams<'a> {
        RemoveStorageItemsParams {
            id: self.id,
            storage_area: self.storage_area,
            keys: self.keys,
        }
    }
}

impl<'a> RemoveStorageItemsParams<'a> { pub const METHOD: &'static str = "Extensions.removeStorageItems"; }

impl<'a> crate::CdpCommand<'a> for RemoveStorageItemsParams<'a> {
    const METHOD: &'static str = "Extensions.removeStorageItems";
    type Response = crate::EmptyReturns;
}

/// Clears extension storage in the given 'storageArea'.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ClearStorageItemsParams<'a> {
    /// ID of extension.
    id: Cow<'a, str>,
    /// StorageArea to remove data from.
    #[serde(rename = "storageArea")]
    storage_area: StorageArea,
}

impl<'a> ClearStorageItemsParams<'a> {
    /// Creates a builder for this type with the required parameters:
    /// * `id`: ID of extension.
    /// * `storage_area`: StorageArea to remove data from.
    pub fn builder(id: impl Into<Cow<'a, str>>, storage_area: impl Into<StorageArea>) -> ClearStorageItemsParamsBuilder<'a> {
        ClearStorageItemsParamsBuilder {
            id: id.into(),
            storage_area: storage_area.into(),
        }
    }
    /// ID of extension.
    pub fn id(&self) -> &str { self.id.as_ref() }
    /// StorageArea to remove data from.
    pub fn storage_area(&self) -> &StorageArea { &self.storage_area }
}


pub struct ClearStorageItemsParamsBuilder<'a> {
    id: Cow<'a, str>,
    storage_area: StorageArea,
}

impl<'a> ClearStorageItemsParamsBuilder<'a> {
    pub fn build(self) -> ClearStorageItemsParams<'a> {
        ClearStorageItemsParams {
            id: self.id,
            storage_area: self.storage_area,
        }
    }
}

impl<'a> ClearStorageItemsParams<'a> { pub const METHOD: &'static str = "Extensions.clearStorageItems"; }

impl<'a> crate::CdpCommand<'a> for ClearStorageItemsParams<'a> {
    const METHOD: &'static str = "Extensions.clearStorageItems";
    type Response = crate::EmptyReturns;
}

/// Sets 'values' in extension storage in the given 'storageArea'. The provided 'values'
/// will be merged with existing values in the storage area.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetStorageItemsParams<'a> {
    /// ID of extension.
    id: Cow<'a, str>,
    /// StorageArea to set data in.
    #[serde(rename = "storageArea")]
    storage_area: StorageArea,
    /// Values to set.
    values: serde_json::Map<String, JsonValue>,
}

impl<'a> SetStorageItemsParams<'a> {
    /// Creates a builder for this type with the required parameters:
    /// * `id`: ID of extension.
    /// * `storage_area`: StorageArea to set data in.
    /// * `values`: Values to set.
    pub fn builder(id: impl Into<Cow<'a, str>>, storage_area: impl Into<StorageArea>, values: serde_json::Map<String, JsonValue>) -> SetStorageItemsParamsBuilder<'a> {
        SetStorageItemsParamsBuilder {
            id: id.into(),
            storage_area: storage_area.into(),
            values: values,
        }
    }
    /// ID of extension.
    pub fn id(&self) -> &str { self.id.as_ref() }
    /// StorageArea to set data in.
    pub fn storage_area(&self) -> &StorageArea { &self.storage_area }
    /// Values to set.
    pub fn values(&self) -> &serde_json::Map<String, JsonValue> { &self.values }
}


pub struct SetStorageItemsParamsBuilder<'a> {
    id: Cow<'a, str>,
    storage_area: StorageArea,
    values: serde_json::Map<String, JsonValue>,
}

impl<'a> SetStorageItemsParamsBuilder<'a> {
    pub fn build(self) -> SetStorageItemsParams<'a> {
        SetStorageItemsParams {
            id: self.id,
            storage_area: self.storage_area,
            values: self.values,
        }
    }
}

impl<'a> SetStorageItemsParams<'a> { pub const METHOD: &'static str = "Extensions.setStorageItems"; }

impl<'a> crate::CdpCommand<'a> for SetStorageItemsParams<'a> {
    const METHOD: &'static str = "Extensions.setStorageItems";
    type Response = crate::EmptyReturns;
}