rustenium_cdp_definitions/browser_protocol/pwa/
command_builders.rs1use super::commands::*;
2impl GetOsAppState {
3 pub fn builder() -> GetOsAppStateBuilder {
4 <GetOsAppStateBuilder as Default>::default()
5 }
6}
7#[derive(Default, Clone)]
8pub struct GetOsAppStateBuilder {
9 manifest_id: Option<String>,
10}
11impl GetOsAppStateBuilder {
12 pub fn manifest_id(mut self, manifest_id: impl Into<String>) -> Self {
13 self.manifest_id = Some(manifest_id.into());
14 self
15 }
16 pub fn build(self) -> Result<GetOsAppState, String> {
17 Ok(GetOsAppState {
18 method: GetOsAppStateMethod::GetOsAppState,
19 params: GetOsAppStateParams {
20 manifest_id: self.manifest_id.ok_or_else(|| {
21 format!("Field `{}` is mandatory.", std::stringify!(manifest_id))
22 })?,
23 },
24 })
25 }
26}
27impl Install {
28 pub fn builder() -> InstallBuilder {
29 <InstallBuilder as Default>::default()
30 }
31}
32#[derive(Default, Clone)]
33pub struct InstallBuilder {
34 manifest_id: Option<String>,
35 install_url_or_bundle_url: Option<String>,
36}
37impl InstallBuilder {
38 pub fn manifest_id(mut self, manifest_id: impl Into<String>) -> Self {
39 self.manifest_id = Some(manifest_id.into());
40 self
41 }
42 pub fn install_url_or_bundle_url(
43 mut self,
44 install_url_or_bundle_url: impl Into<String>,
45 ) -> Self {
46 self.install_url_or_bundle_url = Some(install_url_or_bundle_url.into());
47 self
48 }
49 pub fn build(self) -> Result<Install, String> {
50 Ok(Install {
51 method: InstallMethod::Install,
52 params: InstallParams {
53 manifest_id: self.manifest_id.ok_or_else(|| {
54 format!("Field `{}` is mandatory.", std::stringify!(manifest_id))
55 })?,
56 install_url_or_bundle_url: self.install_url_or_bundle_url,
57 },
58 })
59 }
60}
61impl Uninstall {
62 pub fn builder() -> UninstallBuilder {
63 <UninstallBuilder as Default>::default()
64 }
65}
66#[derive(Default, Clone)]
67pub struct UninstallBuilder {
68 manifest_id: Option<String>,
69}
70impl UninstallBuilder {
71 pub fn manifest_id(mut self, manifest_id: impl Into<String>) -> Self {
72 self.manifest_id = Some(manifest_id.into());
73 self
74 }
75 pub fn build(self) -> Result<Uninstall, String> {
76 Ok(Uninstall {
77 method: UninstallMethod::Uninstall,
78 params: UninstallParams {
79 manifest_id: self.manifest_id.ok_or_else(|| {
80 format!("Field `{}` is mandatory.", std::stringify!(manifest_id))
81 })?,
82 },
83 })
84 }
85}
86impl Launch {
87 pub fn builder() -> LaunchBuilder {
88 <LaunchBuilder as Default>::default()
89 }
90}
91#[derive(Default, Clone)]
92pub struct LaunchBuilder {
93 manifest_id: Option<String>,
94 url: Option<String>,
95}
96impl LaunchBuilder {
97 pub fn manifest_id(mut self, manifest_id: impl Into<String>) -> Self {
98 self.manifest_id = Some(manifest_id.into());
99 self
100 }
101 pub fn url(mut self, url: impl Into<String>) -> Self {
102 self.url = Some(url.into());
103 self
104 }
105 pub fn build(self) -> Result<Launch, String> {
106 Ok(Launch {
107 method: LaunchMethod::Launch,
108 params: LaunchParams {
109 manifest_id: self.manifest_id.ok_or_else(|| {
110 format!("Field `{}` is mandatory.", std::stringify!(manifest_id))
111 })?,
112 url: self.url,
113 },
114 })
115 }
116}
117impl LaunchFilesInApp {
118 pub fn builder() -> LaunchFilesInAppBuilder {
119 <LaunchFilesInAppBuilder as Default>::default()
120 }
121}
122#[derive(Default, Clone)]
123pub struct LaunchFilesInAppBuilder {
124 manifest_id: Option<String>,
125 files: Option<Vec<String>>,
126}
127impl LaunchFilesInAppBuilder {
128 pub fn manifest_id(mut self, manifest_id: impl Into<String>) -> Self {
129 self.manifest_id = Some(manifest_id.into());
130 self
131 }
132 pub fn file(mut self, file: impl Into<String>) -> Self {
133 let v = self.files.get_or_insert(Vec::new());
134 v.push(file.into());
135 self
136 }
137 pub fn files<I, S>(mut self, files: I) -> Self
138 where
139 I: IntoIterator<Item = S>,
140 S: Into<String>,
141 {
142 let v = self.files.get_or_insert(Vec::new());
143 for val in files {
144 v.push(val.into());
145 }
146 self
147 }
148 pub fn build(self) -> Result<LaunchFilesInApp, String> {
149 Ok(LaunchFilesInApp {
150 method: LaunchFilesInAppMethod::LaunchFilesInApp,
151 params: LaunchFilesInAppParams {
152 manifest_id: self.manifest_id.ok_or_else(|| {
153 format!("Field `{}` is mandatory.", std::stringify!(manifest_id))
154 })?,
155 files: self
156 .files
157 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(files)))?,
158 },
159 })
160 }
161}
162impl OpenCurrentPageInApp {
163 pub fn builder() -> OpenCurrentPageInAppBuilder {
164 <OpenCurrentPageInAppBuilder as Default>::default()
165 }
166}
167#[derive(Default, Clone)]
168pub struct OpenCurrentPageInAppBuilder {
169 manifest_id: Option<String>,
170}
171impl OpenCurrentPageInAppBuilder {
172 pub fn manifest_id(mut self, manifest_id: impl Into<String>) -> Self {
173 self.manifest_id = Some(manifest_id.into());
174 self
175 }
176 pub fn build(self) -> Result<OpenCurrentPageInApp, String> {
177 Ok(OpenCurrentPageInApp {
178 method: OpenCurrentPageInAppMethod::OpenCurrentPageInApp,
179 params: OpenCurrentPageInAppParams {
180 manifest_id: self.manifest_id.ok_or_else(|| {
181 format!("Field `{}` is mandatory.", std::stringify!(manifest_id))
182 })?,
183 },
184 })
185 }
186}
187impl ChangeAppUserSettings {
188 pub fn builder() -> ChangeAppUserSettingsBuilder {
189 <ChangeAppUserSettingsBuilder as Default>::default()
190 }
191}
192#[derive(Default, Clone)]
193pub struct ChangeAppUserSettingsBuilder {
194 manifest_id: Option<String>,
195 link_capturing: Option<bool>,
196 display_mode: Option<super::types::DisplayMode>,
197}
198impl ChangeAppUserSettingsBuilder {
199 pub fn manifest_id(mut self, manifest_id: impl Into<String>) -> Self {
200 self.manifest_id = Some(manifest_id.into());
201 self
202 }
203 pub fn link_capturing(mut self, link_capturing: impl Into<bool>) -> Self {
204 self.link_capturing = Some(link_capturing.into());
205 self
206 }
207 pub fn display_mode(mut self, display_mode: impl Into<super::types::DisplayMode>) -> Self {
208 self.display_mode = Some(display_mode.into());
209 self
210 }
211 pub fn build(self) -> Result<ChangeAppUserSettings, String> {
212 Ok(ChangeAppUserSettings {
213 method: ChangeAppUserSettingsMethod::ChangeAppUserSettings,
214 params: ChangeAppUserSettingsParams {
215 manifest_id: self.manifest_id.ok_or_else(|| {
216 format!("Field `{}` is mandatory.", std::stringify!(manifest_id))
217 })?,
218 link_capturing: self.link_capturing,
219 display_mode: self.display_mode,
220 },
221 })
222 }
223}