1use serde::{Serialize, Deserialize};
5use serde_json::Value as JsonValue;
6use std::borrow::Cow;
7
8#[derive(Debug, Clone, Serialize, Deserialize, Default)]
12#[serde(rename_all = "camelCase")]
13pub struct FileHandlerAccept<'a> {
14 #[serde(rename = "mediaType")]
17 media_type: Cow<'a, str>,
18 #[serde(rename = "fileExtensions")]
19 file_extensions: Vec<Cow<'a, str>>,
20}
21
22impl<'a> FileHandlerAccept<'a> {
23 pub fn builder(media_type: impl Into<Cow<'a, str>>, file_extensions: Vec<Cow<'a, str>>) -> FileHandlerAcceptBuilder<'a> {
27 FileHandlerAcceptBuilder {
28 media_type: media_type.into(),
29 file_extensions: file_extensions,
30 }
31 }
32 pub fn media_type(&self) -> &str { self.media_type.as_ref() }
35 pub fn file_extensions(&self) -> &[Cow<'a, str>] { &self.file_extensions }
36}
37
38
39pub struct FileHandlerAcceptBuilder<'a> {
40 media_type: Cow<'a, str>,
41 file_extensions: Vec<Cow<'a, str>>,
42}
43
44impl<'a> FileHandlerAcceptBuilder<'a> {
45 pub fn build(self) -> FileHandlerAccept<'a> {
46 FileHandlerAccept {
47 media_type: self.media_type,
48 file_extensions: self.file_extensions,
49 }
50 }
51}
52
53
54#[derive(Debug, Clone, Serialize, Deserialize, Default)]
55#[serde(rename_all = "camelCase")]
56pub struct FileHandler<'a> {
57 action: Cow<'a, str>,
58 accepts: Vec<FileHandlerAccept<'a>>,
59 #[serde(rename = "displayName")]
60 display_name: Cow<'a, str>,
61}
62
63impl<'a> FileHandler<'a> {
64 pub fn builder(action: impl Into<Cow<'a, str>>, accepts: Vec<FileHandlerAccept<'a>>, display_name: impl Into<Cow<'a, str>>) -> FileHandlerBuilder<'a> {
69 FileHandlerBuilder {
70 action: action.into(),
71 accepts: accepts,
72 display_name: display_name.into(),
73 }
74 }
75 pub fn action(&self) -> &str { self.action.as_ref() }
76 pub fn accepts(&self) -> &[FileHandlerAccept<'a>] { &self.accepts }
77 pub fn display_name(&self) -> &str { self.display_name.as_ref() }
78}
79
80
81pub struct FileHandlerBuilder<'a> {
82 action: Cow<'a, str>,
83 accepts: Vec<FileHandlerAccept<'a>>,
84 display_name: Cow<'a, str>,
85}
86
87impl<'a> FileHandlerBuilder<'a> {
88 pub fn build(self) -> FileHandler<'a> {
89 FileHandler {
90 action: self.action,
91 accepts: self.accepts,
92 display_name: self.display_name,
93 }
94 }
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
100pub enum DisplayMode {
101 #[default]
102 #[serde(rename = "standalone")]
103 Standalone,
104 #[serde(rename = "browser")]
105 Browser,
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize, Default)]
111#[serde(rename_all = "camelCase")]
112pub struct GetOsAppStateParams<'a> {
113 #[serde(rename = "manifestId")]
117 manifest_id: Cow<'a, str>,
118}
119
120impl<'a> GetOsAppStateParams<'a> {
121 pub fn builder(manifest_id: impl Into<Cow<'a, str>>) -> GetOsAppStateParamsBuilder<'a> {
124 GetOsAppStateParamsBuilder {
125 manifest_id: manifest_id.into(),
126 }
127 }
128 pub fn manifest_id(&self) -> &str { self.manifest_id.as_ref() }
132}
133
134
135pub struct GetOsAppStateParamsBuilder<'a> {
136 manifest_id: Cow<'a, str>,
137}
138
139impl<'a> GetOsAppStateParamsBuilder<'a> {
140 pub fn build(self) -> GetOsAppStateParams<'a> {
141 GetOsAppStateParams {
142 manifest_id: self.manifest_id,
143 }
144 }
145}
146
147#[derive(Debug, Clone, Serialize, Deserialize, Default)]
150#[serde(rename_all = "camelCase")]
151pub struct GetOsAppStateReturns<'a> {
152 #[serde(rename = "badgeCount")]
153 badge_count: u64,
154 #[serde(rename = "fileHandlers")]
155 file_handlers: Vec<FileHandler<'a>>,
156}
157
158impl<'a> GetOsAppStateReturns<'a> {
159 pub fn builder(badge_count: u64, file_handlers: Vec<FileHandler<'a>>) -> GetOsAppStateReturnsBuilder<'a> {
163 GetOsAppStateReturnsBuilder {
164 badge_count: badge_count,
165 file_handlers: file_handlers,
166 }
167 }
168 pub fn badge_count(&self) -> u64 { self.badge_count }
169 pub fn file_handlers(&self) -> &[FileHandler<'a>] { &self.file_handlers }
170}
171
172
173pub struct GetOsAppStateReturnsBuilder<'a> {
174 badge_count: u64,
175 file_handlers: Vec<FileHandler<'a>>,
176}
177
178impl<'a> GetOsAppStateReturnsBuilder<'a> {
179 pub fn build(self) -> GetOsAppStateReturns<'a> {
180 GetOsAppStateReturns {
181 badge_count: self.badge_count,
182 file_handlers: self.file_handlers,
183 }
184 }
185}
186
187impl<'a> GetOsAppStateParams<'a> { pub const METHOD: &'static str = "PWA.getOsAppState"; }
188
189impl<'a> crate::CdpCommand<'a> for GetOsAppStateParams<'a> {
190 const METHOD: &'static str = "PWA.getOsAppState";
191 type Response = GetOsAppStateReturns<'a>;
192}
193
194#[derive(Debug, Clone, Serialize, Deserialize, Default)]
222#[serde(rename_all = "camelCase")]
223pub struct InstallParams<'a> {
224 #[serde(rename = "manifestId")]
225 manifest_id: Cow<'a, str>,
226 #[serde(skip_serializing_if = "Option::is_none", rename = "installUrlOrBundleUrl")]
229 install_url_or_bundle_url: Option<Cow<'a, str>>,
230}
231
232impl<'a> InstallParams<'a> {
233 pub fn builder(manifest_id: impl Into<Cow<'a, str>>) -> InstallParamsBuilder<'a> {
236 InstallParamsBuilder {
237 manifest_id: manifest_id.into(),
238 install_url_or_bundle_url: None,
239 }
240 }
241 pub fn manifest_id(&self) -> &str { self.manifest_id.as_ref() }
242 pub fn install_url_or_bundle_url(&self) -> Option<&str> { self.install_url_or_bundle_url.as_deref() }
245}
246
247
248pub struct InstallParamsBuilder<'a> {
249 manifest_id: Cow<'a, str>,
250 install_url_or_bundle_url: Option<Cow<'a, str>>,
251}
252
253impl<'a> InstallParamsBuilder<'a> {
254 pub fn install_url_or_bundle_url(mut self, install_url_or_bundle_url: impl Into<Cow<'a, str>>) -> Self { self.install_url_or_bundle_url = Some(install_url_or_bundle_url.into()); self }
257 pub fn build(self) -> InstallParams<'a> {
258 InstallParams {
259 manifest_id: self.manifest_id,
260 install_url_or_bundle_url: self.install_url_or_bundle_url,
261 }
262 }
263}
264
265impl<'a> InstallParams<'a> { pub const METHOD: &'static str = "PWA.install"; }
266
267impl<'a> crate::CdpCommand<'a> for InstallParams<'a> {
268 const METHOD: &'static str = "PWA.install";
269 type Response = crate::EmptyReturns;
270}
271
272#[derive(Debug, Clone, Serialize, Deserialize, Default)]
275#[serde(rename_all = "camelCase")]
276pub struct UninstallParams<'a> {
277 #[serde(rename = "manifestId")]
278 manifest_id: Cow<'a, str>,
279}
280
281impl<'a> UninstallParams<'a> {
282 pub fn builder(manifest_id: impl Into<Cow<'a, str>>) -> UninstallParamsBuilder<'a> {
285 UninstallParamsBuilder {
286 manifest_id: manifest_id.into(),
287 }
288 }
289 pub fn manifest_id(&self) -> &str { self.manifest_id.as_ref() }
290}
291
292
293pub struct UninstallParamsBuilder<'a> {
294 manifest_id: Cow<'a, str>,
295}
296
297impl<'a> UninstallParamsBuilder<'a> {
298 pub fn build(self) -> UninstallParams<'a> {
299 UninstallParams {
300 manifest_id: self.manifest_id,
301 }
302 }
303}
304
305impl<'a> UninstallParams<'a> { pub const METHOD: &'static str = "PWA.uninstall"; }
306
307impl<'a> crate::CdpCommand<'a> for UninstallParams<'a> {
308 const METHOD: &'static str = "PWA.uninstall";
309 type Response = crate::EmptyReturns;
310}
311
312#[derive(Debug, Clone, Serialize, Deserialize, Default)]
317#[serde(rename_all = "camelCase")]
318pub struct LaunchParams<'a> {
319 #[serde(rename = "manifestId")]
320 manifest_id: Cow<'a, str>,
321 #[serde(skip_serializing_if = "Option::is_none")]
322 url: Option<Cow<'a, str>>,
323}
324
325impl<'a> LaunchParams<'a> {
326 pub fn builder(manifest_id: impl Into<Cow<'a, str>>) -> LaunchParamsBuilder<'a> {
329 LaunchParamsBuilder {
330 manifest_id: manifest_id.into(),
331 url: None,
332 }
333 }
334 pub fn manifest_id(&self) -> &str { self.manifest_id.as_ref() }
335 pub fn url(&self) -> Option<&str> { self.url.as_deref() }
336}
337
338
339pub struct LaunchParamsBuilder<'a> {
340 manifest_id: Cow<'a, str>,
341 url: Option<Cow<'a, str>>,
342}
343
344impl<'a> LaunchParamsBuilder<'a> {
345 pub fn url(mut self, url: impl Into<Cow<'a, str>>) -> Self { self.url = Some(url.into()); self }
346 pub fn build(self) -> LaunchParams<'a> {
347 LaunchParams {
348 manifest_id: self.manifest_id,
349 url: self.url,
350 }
351 }
352}
353
354#[derive(Debug, Clone, Serialize, Deserialize, Default)]
359#[serde(rename_all = "camelCase")]
360pub struct LaunchReturns<'a> {
361 #[serde(rename = "targetId")]
363 target_id: crate::target::TargetID<'a>,
364}
365
366impl<'a> LaunchReturns<'a> {
367 pub fn builder(target_id: crate::target::TargetID<'a>) -> LaunchReturnsBuilder<'a> {
370 LaunchReturnsBuilder {
371 target_id: target_id,
372 }
373 }
374 pub fn target_id(&self) -> &crate::target::TargetID<'a> { &self.target_id }
376}
377
378
379pub struct LaunchReturnsBuilder<'a> {
380 target_id: crate::target::TargetID<'a>,
381}
382
383impl<'a> LaunchReturnsBuilder<'a> {
384 pub fn build(self) -> LaunchReturns<'a> {
385 LaunchReturns {
386 target_id: self.target_id,
387 }
388 }
389}
390
391impl<'a> LaunchParams<'a> { pub const METHOD: &'static str = "PWA.launch"; }
392
393impl<'a> crate::CdpCommand<'a> for LaunchParams<'a> {
394 const METHOD: &'static str = "PWA.launch";
395 type Response = LaunchReturns<'a>;
396}
397
398#[derive(Debug, Clone, Serialize, Deserialize, Default)]
413#[serde(rename_all = "camelCase")]
414pub struct LaunchFilesInAppParams<'a> {
415 #[serde(rename = "manifestId")]
416 manifest_id: Cow<'a, str>,
417 files: Vec<Cow<'a, str>>,
418}
419
420impl<'a> LaunchFilesInAppParams<'a> {
421 pub fn builder(manifest_id: impl Into<Cow<'a, str>>, files: Vec<Cow<'a, str>>) -> LaunchFilesInAppParamsBuilder<'a> {
425 LaunchFilesInAppParamsBuilder {
426 manifest_id: manifest_id.into(),
427 files: files,
428 }
429 }
430 pub fn manifest_id(&self) -> &str { self.manifest_id.as_ref() }
431 pub fn files(&self) -> &[Cow<'a, str>] { &self.files }
432}
433
434
435pub struct LaunchFilesInAppParamsBuilder<'a> {
436 manifest_id: Cow<'a, str>,
437 files: Vec<Cow<'a, str>>,
438}
439
440impl<'a> LaunchFilesInAppParamsBuilder<'a> {
441 pub fn build(self) -> LaunchFilesInAppParams<'a> {
442 LaunchFilesInAppParams {
443 manifest_id: self.manifest_id,
444 files: self.files,
445 }
446 }
447}
448
449#[derive(Debug, Clone, Serialize, Deserialize, Default)]
464#[serde(rename_all = "camelCase")]
465pub struct LaunchFilesInAppReturns<'a> {
466 #[serde(rename = "targetIds")]
468 target_ids: Vec<crate::target::TargetID<'a>>,
469}
470
471impl<'a> LaunchFilesInAppReturns<'a> {
472 pub fn builder(target_ids: Vec<crate::target::TargetID<'a>>) -> LaunchFilesInAppReturnsBuilder<'a> {
475 LaunchFilesInAppReturnsBuilder {
476 target_ids: target_ids,
477 }
478 }
479 pub fn target_ids(&self) -> &[crate::target::TargetID<'a>] { &self.target_ids }
481}
482
483
484pub struct LaunchFilesInAppReturnsBuilder<'a> {
485 target_ids: Vec<crate::target::TargetID<'a>>,
486}
487
488impl<'a> LaunchFilesInAppReturnsBuilder<'a> {
489 pub fn build(self) -> LaunchFilesInAppReturns<'a> {
490 LaunchFilesInAppReturns {
491 target_ids: self.target_ids,
492 }
493 }
494}
495
496impl<'a> LaunchFilesInAppParams<'a> { pub const METHOD: &'static str = "PWA.launchFilesInApp"; }
497
498impl<'a> crate::CdpCommand<'a> for LaunchFilesInAppParams<'a> {
499 const METHOD: &'static str = "PWA.launchFilesInApp";
500 type Response = LaunchFilesInAppReturns<'a>;
501}
502
503#[derive(Debug, Clone, Serialize, Deserialize, Default)]
508#[serde(rename_all = "camelCase")]
509pub struct OpenCurrentPageInAppParams<'a> {
510 #[serde(rename = "manifestId")]
511 manifest_id: Cow<'a, str>,
512}
513
514impl<'a> OpenCurrentPageInAppParams<'a> {
515 pub fn builder(manifest_id: impl Into<Cow<'a, str>>) -> OpenCurrentPageInAppParamsBuilder<'a> {
518 OpenCurrentPageInAppParamsBuilder {
519 manifest_id: manifest_id.into(),
520 }
521 }
522 pub fn manifest_id(&self) -> &str { self.manifest_id.as_ref() }
523}
524
525
526pub struct OpenCurrentPageInAppParamsBuilder<'a> {
527 manifest_id: Cow<'a, str>,
528}
529
530impl<'a> OpenCurrentPageInAppParamsBuilder<'a> {
531 pub fn build(self) -> OpenCurrentPageInAppParams<'a> {
532 OpenCurrentPageInAppParams {
533 manifest_id: self.manifest_id,
534 }
535 }
536}
537
538impl<'a> OpenCurrentPageInAppParams<'a> { pub const METHOD: &'static str = "PWA.openCurrentPageInApp"; }
539
540impl<'a> crate::CdpCommand<'a> for OpenCurrentPageInAppParams<'a> {
541 const METHOD: &'static str = "PWA.openCurrentPageInApp";
542 type Response = crate::EmptyReturns;
543}
544
545#[derive(Debug, Clone, Serialize, Deserialize, Default)]
556#[serde(rename_all = "camelCase")]
557pub struct ChangeAppUserSettingsParams<'a> {
558 #[serde(rename = "manifestId")]
559 manifest_id: Cow<'a, str>,
560 #[serde(skip_serializing_if = "Option::is_none", rename = "linkCapturing")]
572 link_capturing: Option<bool>,
573 #[serde(skip_serializing_if = "Option::is_none", rename = "displayMode")]
574 display_mode: Option<DisplayMode>,
575}
576
577impl<'a> ChangeAppUserSettingsParams<'a> {
578 pub fn builder(manifest_id: impl Into<Cow<'a, str>>) -> ChangeAppUserSettingsParamsBuilder<'a> {
581 ChangeAppUserSettingsParamsBuilder {
582 manifest_id: manifest_id.into(),
583 link_capturing: None,
584 display_mode: None,
585 }
586 }
587 pub fn manifest_id(&self) -> &str { self.manifest_id.as_ref() }
588 pub fn link_capturing(&self) -> Option<bool> { self.link_capturing }
600 pub fn display_mode(&self) -> Option<&DisplayMode> { self.display_mode.as_ref() }
601}
602
603
604pub struct ChangeAppUserSettingsParamsBuilder<'a> {
605 manifest_id: Cow<'a, str>,
606 link_capturing: Option<bool>,
607 display_mode: Option<DisplayMode>,
608}
609
610impl<'a> ChangeAppUserSettingsParamsBuilder<'a> {
611 pub fn link_capturing(mut self, link_capturing: bool) -> Self { self.link_capturing = Some(link_capturing); self }
623 pub fn display_mode(mut self, display_mode: impl Into<DisplayMode>) -> Self { self.display_mode = Some(display_mode.into()); self }
624 pub fn build(self) -> ChangeAppUserSettingsParams<'a> {
625 ChangeAppUserSettingsParams {
626 manifest_id: self.manifest_id,
627 link_capturing: self.link_capturing,
628 display_mode: self.display_mode,
629 }
630 }
631}
632
633impl<'a> ChangeAppUserSettingsParams<'a> { pub const METHOD: &'static str = "PWA.changeAppUserSettings"; }
634
635impl<'a> crate::CdpCommand<'a> for ChangeAppUserSettingsParams<'a> {
636 const METHOD: &'static str = "PWA.changeAppUserSettings";
637 type Response = crate::EmptyReturns;
638}