rustenium_cdp_definitions/browser_protocol/extensions/
command_builders.rs1use super::commands::*;
2impl TriggerAction {
3 pub fn builder() -> TriggerActionBuilder {
4 <TriggerActionBuilder as Default>::default()
5 }
6}
7#[derive(Default, Clone)]
8pub struct TriggerActionBuilder {
9 id: Option<String>,
10 target_id: Option<String>,
11}
12impl TriggerActionBuilder {
13 pub fn id(mut self, id: impl Into<String>) -> Self {
14 self.id = Some(id.into());
15 self
16 }
17 pub fn target_id(mut self, target_id: impl Into<String>) -> Self {
18 self.target_id = Some(target_id.into());
19 self
20 }
21 pub fn build(self) -> Result<TriggerAction, String> {
22 Ok(TriggerAction {
23 method: TriggerActionMethod::TriggerAction,
24 params: TriggerActionParams {
25 id: self
26 .id
27 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(id)))?,
28 target_id: self.target_id.ok_or_else(|| {
29 format!("Field `{}` is mandatory.", std::stringify!(target_id))
30 })?,
31 },
32 })
33 }
34}
35impl LoadUnpacked {
36 pub fn builder() -> LoadUnpackedBuilder {
37 <LoadUnpackedBuilder as Default>::default()
38 }
39}
40#[derive(Default, Clone)]
41pub struct LoadUnpackedBuilder {
42 path: Option<String>,
43 enable_in_incognito: Option<bool>,
44}
45impl LoadUnpackedBuilder {
46 pub fn path(mut self, path: impl Into<String>) -> Self {
47 self.path = Some(path.into());
48 self
49 }
50 pub fn enable_in_incognito(mut self, enable_in_incognito: impl Into<bool>) -> Self {
51 self.enable_in_incognito = Some(enable_in_incognito.into());
52 self
53 }
54 pub fn build(self) -> Result<LoadUnpacked, String> {
55 Ok(LoadUnpacked {
56 method: LoadUnpackedMethod::LoadUnpacked,
57 params: LoadUnpackedParams {
58 path: self
59 .path
60 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(path)))?,
61 enable_in_incognito: self.enable_in_incognito,
62 },
63 })
64 }
65}
66#[derive(Debug, Clone, Default)]
67pub struct GetExtensionsBuilder;
68impl GetExtensionsBuilder {
69 pub fn new() -> Self {
70 Self
71 }
72 pub fn build(self) -> GetExtensions {
73 GetExtensions {
74 method: GetExtensionsMethod::GetExtensions,
75 params: GetExtensionsParams {},
76 }
77 }
78}
79impl GetExtensions {
80 pub fn builder() -> GetExtensionsBuilder {
81 GetExtensionsBuilder
82 }
83}
84impl Uninstall {
85 pub fn builder() -> UninstallBuilder {
86 <UninstallBuilder as Default>::default()
87 }
88}
89#[derive(Default, Clone)]
90pub struct UninstallBuilder {
91 id: Option<String>,
92}
93impl UninstallBuilder {
94 pub fn id(mut self, id: impl Into<String>) -> Self {
95 self.id = Some(id.into());
96 self
97 }
98 pub fn build(self) -> Result<Uninstall, String> {
99 Ok(Uninstall {
100 method: UninstallMethod::Uninstall,
101 params: UninstallParams {
102 id: self
103 .id
104 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(id)))?,
105 },
106 })
107 }
108}
109impl GetStorageItems {
110 pub fn builder() -> GetStorageItemsBuilder {
111 <GetStorageItemsBuilder as Default>::default()
112 }
113}
114#[derive(Default, Clone)]
115pub struct GetStorageItemsBuilder {
116 id: Option<String>,
117 storage_area: Option<super::types::StorageArea>,
118 keys: Option<Vec<String>>,
119}
120impl GetStorageItemsBuilder {
121 pub fn id(mut self, id: impl Into<String>) -> Self {
122 self.id = Some(id.into());
123 self
124 }
125 pub fn storage_area(mut self, storage_area: impl Into<super::types::StorageArea>) -> Self {
126 self.storage_area = Some(storage_area.into());
127 self
128 }
129 pub fn key(mut self, key: impl Into<String>) -> Self {
130 let v = self.keys.get_or_insert(Vec::new());
131 v.push(key.into());
132 self
133 }
134 pub fn keys<I, S>(mut self, keys: I) -> Self
135 where
136 I: IntoIterator<Item = S>,
137 S: Into<String>,
138 {
139 let v = self.keys.get_or_insert(Vec::new());
140 for val in keys {
141 v.push(val.into());
142 }
143 self
144 }
145 pub fn build(self) -> Result<GetStorageItems, String> {
146 Ok(GetStorageItems {
147 method: GetStorageItemsMethod::GetStorageItems,
148 params: GetStorageItemsParams {
149 id: self
150 .id
151 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(id)))?,
152 storage_area: self.storage_area.ok_or_else(|| {
153 format!("Field `{}` is mandatory.", std::stringify!(storage_area))
154 })?,
155 keys: self.keys,
156 },
157 })
158 }
159}
160impl RemoveStorageItems {
161 pub fn builder() -> RemoveStorageItemsBuilder {
162 <RemoveStorageItemsBuilder as Default>::default()
163 }
164}
165#[derive(Default, Clone)]
166pub struct RemoveStorageItemsBuilder {
167 id: Option<String>,
168 storage_area: Option<super::types::StorageArea>,
169 keys: Option<Vec<String>>,
170}
171impl RemoveStorageItemsBuilder {
172 pub fn id(mut self, id: impl Into<String>) -> Self {
173 self.id = Some(id.into());
174 self
175 }
176 pub fn storage_area(mut self, storage_area: impl Into<super::types::StorageArea>) -> Self {
177 self.storage_area = Some(storage_area.into());
178 self
179 }
180 pub fn key(mut self, key: impl Into<String>) -> Self {
181 let v = self.keys.get_or_insert(Vec::new());
182 v.push(key.into());
183 self
184 }
185 pub fn keys<I, S>(mut self, keys: I) -> Self
186 where
187 I: IntoIterator<Item = S>,
188 S: Into<String>,
189 {
190 let v = self.keys.get_or_insert(Vec::new());
191 for val in keys {
192 v.push(val.into());
193 }
194 self
195 }
196 pub fn build(self) -> Result<RemoveStorageItems, String> {
197 Ok(RemoveStorageItems {
198 method: RemoveStorageItemsMethod::RemoveStorageItems,
199 params: RemoveStorageItemsParams {
200 id: self
201 .id
202 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(id)))?,
203 storage_area: self.storage_area.ok_or_else(|| {
204 format!("Field `{}` is mandatory.", std::stringify!(storage_area))
205 })?,
206 keys: self
207 .keys
208 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(keys)))?,
209 },
210 })
211 }
212}
213impl ClearStorageItems {
214 pub fn builder() -> ClearStorageItemsBuilder {
215 <ClearStorageItemsBuilder as Default>::default()
216 }
217}
218#[derive(Default, Clone)]
219pub struct ClearStorageItemsBuilder {
220 id: Option<String>,
221 storage_area: Option<super::types::StorageArea>,
222}
223impl ClearStorageItemsBuilder {
224 pub fn id(mut self, id: impl Into<String>) -> Self {
225 self.id = Some(id.into());
226 self
227 }
228 pub fn storage_area(mut self, storage_area: impl Into<super::types::StorageArea>) -> Self {
229 self.storage_area = Some(storage_area.into());
230 self
231 }
232 pub fn build(self) -> Result<ClearStorageItems, String> {
233 Ok(ClearStorageItems {
234 method: ClearStorageItemsMethod::ClearStorageItems,
235 params: ClearStorageItemsParams {
236 id: self
237 .id
238 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(id)))?,
239 storage_area: self.storage_area.ok_or_else(|| {
240 format!("Field `{}` is mandatory.", std::stringify!(storage_area))
241 })?,
242 },
243 })
244 }
245}
246impl SetStorageItems {
247 pub fn builder() -> SetStorageItemsBuilder {
248 <SetStorageItemsBuilder as Default>::default()
249 }
250}
251#[derive(Default, Clone)]
252pub struct SetStorageItemsBuilder {
253 id: Option<String>,
254 storage_area: Option<super::types::StorageArea>,
255 values: Option<serde_json::Value>,
256}
257impl SetStorageItemsBuilder {
258 pub fn id(mut self, id: impl Into<String>) -> Self {
259 self.id = Some(id.into());
260 self
261 }
262 pub fn storage_area(mut self, storage_area: impl Into<super::types::StorageArea>) -> Self {
263 self.storage_area = Some(storage_area.into());
264 self
265 }
266 pub fn values(mut self, values: impl Into<serde_json::Value>) -> Self {
267 self.values = Some(values.into());
268 self
269 }
270 pub fn build(self) -> Result<SetStorageItems, String> {
271 Ok(SetStorageItems {
272 method: SetStorageItemsMethod::SetStorageItems,
273 params: SetStorageItemsParams {
274 id: self
275 .id
276 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(id)))?,
277 storage_area: self.storage_area.ok_or_else(|| {
278 format!("Field `{}` is mandatory.", std::stringify!(storage_area))
279 })?,
280 values: self
281 .values
282 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(values)))?,
283 },
284 })
285 }
286}