1use serde::{Serialize, Deserialize};
5use serde_json::Value as JsonValue;
6use std::borrow::Cow;
7
8#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
11pub enum StorageArea {
12 #[default]
13 #[serde(rename = "session")]
14 Session,
15 #[serde(rename = "local")]
16 Local,
17 #[serde(rename = "sync")]
18 Sync,
19 #[serde(rename = "managed")]
20 Managed,
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize, Default)]
26#[serde(rename_all = "camelCase")]
27pub struct ExtensionInfo<'a> {
28 id: Cow<'a, str>,
30 name: Cow<'a, str>,
32 version: Cow<'a, str>,
34 path: Cow<'a, str>,
36 enabled: bool,
38}
39
40impl<'a> ExtensionInfo<'a> {
41 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> {
42 ExtensionInfoBuilder {
43 id: id.into(),
44 name: name.into(),
45 version: version.into(),
46 path: path.into(),
47 enabled: enabled,
48 }
49 }
50 pub fn id(&self) -> &str { self.id.as_ref() }
51 pub fn name(&self) -> &str { self.name.as_ref() }
52 pub fn version(&self) -> &str { self.version.as_ref() }
53 pub fn path(&self) -> &str { self.path.as_ref() }
54 pub fn enabled(&self) -> bool { self.enabled }
55}
56
57
58pub struct ExtensionInfoBuilder<'a> {
59 id: Cow<'a, str>,
60 name: Cow<'a, str>,
61 version: Cow<'a, str>,
62 path: Cow<'a, str>,
63 enabled: bool,
64}
65
66impl<'a> ExtensionInfoBuilder<'a> {
67 pub fn build(self) -> ExtensionInfo<'a> {
68 ExtensionInfo {
69 id: self.id,
70 name: self.name,
71 version: self.version,
72 path: self.path,
73 enabled: self.enabled,
74 }
75 }
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize, Default)]
83#[serde(rename_all = "camelCase")]
84pub struct TriggerActionParams<'a> {
85 id: Cow<'a, str>,
87 targetId: Cow<'a, str>,
89}
90
91impl<'a> TriggerActionParams<'a> {
92 pub fn builder(id: impl Into<Cow<'a, str>>, targetId: impl Into<Cow<'a, str>>) -> TriggerActionParamsBuilder<'a> {
93 TriggerActionParamsBuilder {
94 id: id.into(),
95 targetId: targetId.into(),
96 }
97 }
98 pub fn id(&self) -> &str { self.id.as_ref() }
99 pub fn targetId(&self) -> &str { self.targetId.as_ref() }
100}
101
102
103pub struct TriggerActionParamsBuilder<'a> {
104 id: Cow<'a, str>,
105 targetId: Cow<'a, str>,
106}
107
108impl<'a> TriggerActionParamsBuilder<'a> {
109 pub fn build(self) -> TriggerActionParams<'a> {
110 TriggerActionParams {
111 id: self.id,
112 targetId: self.targetId,
113 }
114 }
115}
116
117impl<'a> TriggerActionParams<'a> { pub const METHOD: &'static str = "Extensions.triggerAction"; }
118
119impl<'a> crate::CdpCommand<'a> for TriggerActionParams<'a> {
120 const METHOD: &'static str = "Extensions.triggerAction";
121 type Response = crate::EmptyReturns;
122}
123
124#[derive(Debug, Clone, Serialize, Deserialize, Default)]
131#[serde(rename_all = "camelCase")]
132pub struct LoadUnpackedParams<'a> {
133 path: Cow<'a, str>,
135 #[serde(skip_serializing_if = "Option::is_none")]
137 enableInIncognito: Option<bool>,
138}
139
140impl<'a> LoadUnpackedParams<'a> {
141 pub fn builder(path: impl Into<Cow<'a, str>>) -> LoadUnpackedParamsBuilder<'a> {
142 LoadUnpackedParamsBuilder {
143 path: path.into(),
144 enableInIncognito: None,
145 }
146 }
147 pub fn path(&self) -> &str { self.path.as_ref() }
148 pub fn enableInIncognito(&self) -> Option<bool> { self.enableInIncognito }
149}
150
151
152pub struct LoadUnpackedParamsBuilder<'a> {
153 path: Cow<'a, str>,
154 enableInIncognito: Option<bool>,
155}
156
157impl<'a> LoadUnpackedParamsBuilder<'a> {
158 pub fn enableInIncognito(mut self, enableInIncognito: bool) -> Self { self.enableInIncognito = Some(enableInIncognito); self }
160 pub fn build(self) -> LoadUnpackedParams<'a> {
161 LoadUnpackedParams {
162 path: self.path,
163 enableInIncognito: self.enableInIncognito,
164 }
165 }
166}
167
168#[derive(Debug, Clone, Serialize, Deserialize, Default)]
175#[serde(rename_all = "camelCase")]
176pub struct LoadUnpackedReturns<'a> {
177 id: Cow<'a, str>,
179}
180
181impl<'a> LoadUnpackedReturns<'a> {
182 pub fn builder(id: impl Into<Cow<'a, str>>) -> LoadUnpackedReturnsBuilder<'a> {
183 LoadUnpackedReturnsBuilder {
184 id: id.into(),
185 }
186 }
187 pub fn id(&self) -> &str { self.id.as_ref() }
188}
189
190
191pub struct LoadUnpackedReturnsBuilder<'a> {
192 id: Cow<'a, str>,
193}
194
195impl<'a> LoadUnpackedReturnsBuilder<'a> {
196 pub fn build(self) -> LoadUnpackedReturns<'a> {
197 LoadUnpackedReturns {
198 id: self.id,
199 }
200 }
201}
202
203impl<'a> LoadUnpackedParams<'a> { pub const METHOD: &'static str = "Extensions.loadUnpacked"; }
204
205impl<'a> crate::CdpCommand<'a> for LoadUnpackedParams<'a> {
206 const METHOD: &'static str = "Extensions.loadUnpacked";
207 type Response = LoadUnpackedReturns<'a>;
208}
209
210#[derive(Debug, Clone, Serialize, Deserialize, Default)]
215#[serde(rename_all = "camelCase")]
216pub struct GetExtensionsReturns<'a> {
217 extensions: Vec<ExtensionInfo<'a>>,
218}
219
220impl<'a> GetExtensionsReturns<'a> {
221 pub fn builder(extensions: Vec<ExtensionInfo<'a>>) -> GetExtensionsReturnsBuilder<'a> {
222 GetExtensionsReturnsBuilder {
223 extensions: extensions,
224 }
225 }
226 pub fn extensions(&self) -> &[ExtensionInfo<'a>] { &self.extensions }
227}
228
229
230pub struct GetExtensionsReturnsBuilder<'a> {
231 extensions: Vec<ExtensionInfo<'a>>,
232}
233
234impl<'a> GetExtensionsReturnsBuilder<'a> {
235 pub fn build(self) -> GetExtensionsReturns<'a> {
236 GetExtensionsReturns {
237 extensions: self.extensions,
238 }
239 }
240}
241
242#[derive(Debug, Clone, Serialize, Deserialize, Default)]
243pub struct GetExtensionsParams {}
244
245impl GetExtensionsParams { pub const METHOD: &'static str = "Extensions.getExtensions"; }
246
247impl<'a> crate::CdpCommand<'a> for GetExtensionsParams {
248 const METHOD: &'static str = "Extensions.getExtensions";
249 type Response = GetExtensionsReturns<'a>;
250}
251
252#[derive(Debug, Clone, Serialize, Deserialize, Default)]
257#[serde(rename_all = "camelCase")]
258pub struct UninstallParams<'a> {
259 id: Cow<'a, str>,
261}
262
263impl<'a> UninstallParams<'a> {
264 pub fn builder(id: impl Into<Cow<'a, str>>) -> UninstallParamsBuilder<'a> {
265 UninstallParamsBuilder {
266 id: id.into(),
267 }
268 }
269 pub fn id(&self) -> &str { self.id.as_ref() }
270}
271
272
273pub struct UninstallParamsBuilder<'a> {
274 id: Cow<'a, str>,
275}
276
277impl<'a> UninstallParamsBuilder<'a> {
278 pub fn build(self) -> UninstallParams<'a> {
279 UninstallParams {
280 id: self.id,
281 }
282 }
283}
284
285impl<'a> UninstallParams<'a> { pub const METHOD: &'static str = "Extensions.uninstall"; }
286
287impl<'a> crate::CdpCommand<'a> for UninstallParams<'a> {
288 const METHOD: &'static str = "Extensions.uninstall";
289 type Response = crate::EmptyReturns;
290}
291
292#[derive(Debug, Clone, Serialize, Deserialize, Default)]
296#[serde(rename_all = "camelCase")]
297pub struct GetStorageItemsParams<'a> {
298 id: Cow<'a, str>,
300 storageArea: StorageArea,
302 #[serde(skip_serializing_if = "Option::is_none")]
304 keys: Option<Vec<Cow<'a, str>>>,
305}
306
307impl<'a> GetStorageItemsParams<'a> {
308 pub fn builder(id: impl Into<Cow<'a, str>>, storageArea: StorageArea) -> GetStorageItemsParamsBuilder<'a> {
309 GetStorageItemsParamsBuilder {
310 id: id.into(),
311 storageArea: storageArea,
312 keys: None,
313 }
314 }
315 pub fn id(&self) -> &str { self.id.as_ref() }
316 pub fn storageArea(&self) -> &StorageArea { &self.storageArea }
317 pub fn keys(&self) -> Option<&[Cow<'a, str>]> { self.keys.as_deref() }
318}
319
320
321pub struct GetStorageItemsParamsBuilder<'a> {
322 id: Cow<'a, str>,
323 storageArea: StorageArea,
324 keys: Option<Vec<Cow<'a, str>>>,
325}
326
327impl<'a> GetStorageItemsParamsBuilder<'a> {
328 pub fn keys(mut self, keys: Vec<Cow<'a, str>>) -> Self { self.keys = Some(keys); self }
330 pub fn build(self) -> GetStorageItemsParams<'a> {
331 GetStorageItemsParams {
332 id: self.id,
333 storageArea: self.storageArea,
334 keys: self.keys,
335 }
336 }
337}
338
339#[derive(Debug, Clone, Serialize, Deserialize, Default)]
343#[serde(rename_all = "camelCase")]
344pub struct GetStorageItemsReturns {
345 data: serde_json::Map<String, JsonValue>,
346}
347
348impl GetStorageItemsReturns {
349 pub fn builder(data: serde_json::Map<String, JsonValue>) -> GetStorageItemsReturnsBuilder {
350 GetStorageItemsReturnsBuilder {
351 data: data,
352 }
353 }
354 pub fn data(&self) -> &serde_json::Map<String, JsonValue> { &self.data }
355}
356
357
358pub struct GetStorageItemsReturnsBuilder {
359 data: serde_json::Map<String, JsonValue>,
360}
361
362impl GetStorageItemsReturnsBuilder {
363 pub fn build(self) -> GetStorageItemsReturns {
364 GetStorageItemsReturns {
365 data: self.data,
366 }
367 }
368}
369
370impl<'a> GetStorageItemsParams<'a> { pub const METHOD: &'static str = "Extensions.getStorageItems"; }
371
372impl<'a> crate::CdpCommand<'a> for GetStorageItemsParams<'a> {
373 const METHOD: &'static str = "Extensions.getStorageItems";
374 type Response = GetStorageItemsReturns;
375}
376
377#[derive(Debug, Clone, Serialize, Deserialize, Default)]
380#[serde(rename_all = "camelCase")]
381pub struct RemoveStorageItemsParams<'a> {
382 id: Cow<'a, str>,
384 storageArea: StorageArea,
386 keys: Vec<Cow<'a, str>>,
388}
389
390impl<'a> RemoveStorageItemsParams<'a> {
391 pub fn builder(id: impl Into<Cow<'a, str>>, storageArea: StorageArea, keys: Vec<Cow<'a, str>>) -> RemoveStorageItemsParamsBuilder<'a> {
392 RemoveStorageItemsParamsBuilder {
393 id: id.into(),
394 storageArea: storageArea,
395 keys: keys,
396 }
397 }
398 pub fn id(&self) -> &str { self.id.as_ref() }
399 pub fn storageArea(&self) -> &StorageArea { &self.storageArea }
400 pub fn keys(&self) -> &[Cow<'a, str>] { &self.keys }
401}
402
403
404pub struct RemoveStorageItemsParamsBuilder<'a> {
405 id: Cow<'a, str>,
406 storageArea: StorageArea,
407 keys: Vec<Cow<'a, str>>,
408}
409
410impl<'a> RemoveStorageItemsParamsBuilder<'a> {
411 pub fn build(self) -> RemoveStorageItemsParams<'a> {
412 RemoveStorageItemsParams {
413 id: self.id,
414 storageArea: self.storageArea,
415 keys: self.keys,
416 }
417 }
418}
419
420impl<'a> RemoveStorageItemsParams<'a> { pub const METHOD: &'static str = "Extensions.removeStorageItems"; }
421
422impl<'a> crate::CdpCommand<'a> for RemoveStorageItemsParams<'a> {
423 const METHOD: &'static str = "Extensions.removeStorageItems";
424 type Response = crate::EmptyReturns;
425}
426
427#[derive(Debug, Clone, Serialize, Deserialize, Default)]
430#[serde(rename_all = "camelCase")]
431pub struct ClearStorageItemsParams<'a> {
432 id: Cow<'a, str>,
434 storageArea: StorageArea,
436}
437
438impl<'a> ClearStorageItemsParams<'a> {
439 pub fn builder(id: impl Into<Cow<'a, str>>, storageArea: StorageArea) -> ClearStorageItemsParamsBuilder<'a> {
440 ClearStorageItemsParamsBuilder {
441 id: id.into(),
442 storageArea: storageArea,
443 }
444 }
445 pub fn id(&self) -> &str { self.id.as_ref() }
446 pub fn storageArea(&self) -> &StorageArea { &self.storageArea }
447}
448
449
450pub struct ClearStorageItemsParamsBuilder<'a> {
451 id: Cow<'a, str>,
452 storageArea: StorageArea,
453}
454
455impl<'a> ClearStorageItemsParamsBuilder<'a> {
456 pub fn build(self) -> ClearStorageItemsParams<'a> {
457 ClearStorageItemsParams {
458 id: self.id,
459 storageArea: self.storageArea,
460 }
461 }
462}
463
464impl<'a> ClearStorageItemsParams<'a> { pub const METHOD: &'static str = "Extensions.clearStorageItems"; }
465
466impl<'a> crate::CdpCommand<'a> for ClearStorageItemsParams<'a> {
467 const METHOD: &'static str = "Extensions.clearStorageItems";
468 type Response = crate::EmptyReturns;
469}
470
471#[derive(Debug, Clone, Serialize, Deserialize, Default)]
475#[serde(rename_all = "camelCase")]
476pub struct SetStorageItemsParams<'a> {
477 id: Cow<'a, str>,
479 storageArea: StorageArea,
481 values: serde_json::Map<String, JsonValue>,
483}
484
485impl<'a> SetStorageItemsParams<'a> {
486 pub fn builder(id: impl Into<Cow<'a, str>>, storageArea: StorageArea, values: serde_json::Map<String, JsonValue>) -> SetStorageItemsParamsBuilder<'a> {
487 SetStorageItemsParamsBuilder {
488 id: id.into(),
489 storageArea: storageArea,
490 values: values,
491 }
492 }
493 pub fn id(&self) -> &str { self.id.as_ref() }
494 pub fn storageArea(&self) -> &StorageArea { &self.storageArea }
495 pub fn values(&self) -> &serde_json::Map<String, JsonValue> { &self.values }
496}
497
498
499pub struct SetStorageItemsParamsBuilder<'a> {
500 id: Cow<'a, str>,
501 storageArea: StorageArea,
502 values: serde_json::Map<String, JsonValue>,
503}
504
505impl<'a> SetStorageItemsParamsBuilder<'a> {
506 pub fn build(self) -> SetStorageItemsParams<'a> {
507 SetStorageItemsParams {
508 id: self.id,
509 storageArea: self.storageArea,
510 values: self.values,
511 }
512 }
513}
514
515impl<'a> SetStorageItemsParams<'a> { pub const METHOD: &'static str = "Extensions.setStorageItems"; }
516
517impl<'a> crate::CdpCommand<'a> for SetStorageItemsParams<'a> {
518 const METHOD: &'static str = "Extensions.setStorageItems";
519 type Response = crate::EmptyReturns;
520}