1use super::commands::*;
2impl SetPermission {
3 pub fn builder() -> SetPermissionBuilder {
4 <SetPermissionBuilder as Default>::default()
5 }
6}
7#[derive(Default, Clone)]
8pub struct SetPermissionBuilder {
9 permission: Option<super::types::PermissionDescriptor>,
10 setting: Option<super::types::PermissionSetting>,
11 origin: Option<String>,
12 embedded_origin: Option<String>,
13 browser_context_id: Option<super::types::BrowserContextId>,
14}
15impl SetPermissionBuilder {
16 pub fn permission(mut self, permission: impl Into<super::types::PermissionDescriptor>) -> Self {
17 self.permission = Some(permission.into());
18 self
19 }
20 pub fn setting(mut self, setting: impl Into<super::types::PermissionSetting>) -> Self {
21 self.setting = Some(setting.into());
22 self
23 }
24 pub fn origin(mut self, origin: impl Into<String>) -> Self {
25 self.origin = Some(origin.into());
26 self
27 }
28 pub fn embedded_origin(mut self, embedded_origin: impl Into<String>) -> Self {
29 self.embedded_origin = Some(embedded_origin.into());
30 self
31 }
32 pub fn browser_context_id(
33 mut self,
34 browser_context_id: impl Into<super::types::BrowserContextId>,
35 ) -> Self {
36 self.browser_context_id = Some(browser_context_id.into());
37 self
38 }
39 pub fn build(self) -> Result<SetPermission, String> {
40 Ok(SetPermission {
41 method: SetPermissionMethod::SetPermission,
42 params: SetPermissionParams {
43 permission: self.permission.ok_or_else(|| {
44 format!("Field `{}` is mandatory.", std::stringify!(permission))
45 })?,
46 setting: self
47 .setting
48 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(setting)))?,
49 origin: self.origin,
50 embedded_origin: self.embedded_origin,
51 browser_context_id: self.browser_context_id.map(Box::new),
52 },
53 })
54 }
55}
56impl ResetPermissions {
57 pub fn builder() -> ResetPermissionsBuilder {
58 <ResetPermissionsBuilder as Default>::default()
59 }
60}
61#[derive(Default, Clone)]
62pub struct ResetPermissionsBuilder {
63 browser_context_id: Option<super::types::BrowserContextId>,
64}
65impl ResetPermissionsBuilder {
66 pub fn browser_context_id(
67 mut self,
68 browser_context_id: impl Into<super::types::BrowserContextId>,
69 ) -> Self {
70 self.browser_context_id = Some(browser_context_id.into());
71 self
72 }
73 pub fn build(self) -> ResetPermissions {
74 ResetPermissions {
75 method: ResetPermissionsMethod::ResetPermissions,
76 params: ResetPermissionsParams {
77 browser_context_id: self.browser_context_id.map(Box::new),
78 },
79 }
80 }
81}
82impl SetDownloadBehavior {
83 pub fn builder() -> SetDownloadBehaviorBuilder {
84 <SetDownloadBehaviorBuilder as Default>::default()
85 }
86}
87#[derive(Default, Clone)]
88pub struct SetDownloadBehaviorBuilder {
89 behavior: Option<SetDownloadBehaviorBehavior>,
90 browser_context_id: Option<super::types::BrowserContextId>,
91 download_path: Option<String>,
92 events_enabled: Option<bool>,
93}
94impl SetDownloadBehaviorBuilder {
95 pub fn behavior(mut self, behavior: impl Into<SetDownloadBehaviorBehavior>) -> Self {
96 self.behavior = Some(behavior.into());
97 self
98 }
99 pub fn browser_context_id(
100 mut self,
101 browser_context_id: impl Into<super::types::BrowserContextId>,
102 ) -> Self {
103 self.browser_context_id = Some(browser_context_id.into());
104 self
105 }
106 pub fn download_path(mut self, download_path: impl Into<String>) -> Self {
107 self.download_path = Some(download_path.into());
108 self
109 }
110 pub fn events_enabled(mut self, events_enabled: impl Into<bool>) -> Self {
111 self.events_enabled = Some(events_enabled.into());
112 self
113 }
114 pub fn build(self) -> Result<SetDownloadBehavior, String> {
115 Ok(SetDownloadBehavior {
116 method: SetDownloadBehaviorMethod::SetDownloadBehavior,
117 params: SetDownloadBehaviorParams {
118 behavior: self.behavior.ok_or_else(|| {
119 format!("Field `{}` is mandatory.", std::stringify!(behavior))
120 })?,
121 browser_context_id: self.browser_context_id.map(Box::new),
122 download_path: self.download_path,
123 events_enabled: self.events_enabled,
124 },
125 })
126 }
127}
128impl CancelDownload {
129 pub fn builder() -> CancelDownloadBuilder {
130 <CancelDownloadBuilder as Default>::default()
131 }
132}
133#[derive(Default, Clone)]
134pub struct CancelDownloadBuilder {
135 guid: Option<String>,
136 browser_context_id: Option<super::types::BrowserContextId>,
137}
138impl CancelDownloadBuilder {
139 pub fn guid(mut self, guid: impl Into<String>) -> Self {
140 self.guid = Some(guid.into());
141 self
142 }
143 pub fn browser_context_id(
144 mut self,
145 browser_context_id: impl Into<super::types::BrowserContextId>,
146 ) -> Self {
147 self.browser_context_id = Some(browser_context_id.into());
148 self
149 }
150 pub fn build(self) -> Result<CancelDownload, String> {
151 Ok(CancelDownload {
152 method: CancelDownloadMethod::CancelDownload,
153 params: CancelDownloadParams {
154 guid: self
155 .guid
156 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(guid)))?,
157 browser_context_id: self.browser_context_id.map(Box::new),
158 },
159 })
160 }
161}
162#[derive(Debug, Clone, Default)]
163pub struct CloseBuilder;
164impl CloseBuilder {
165 pub fn new() -> Self {
166 Self
167 }
168 pub fn build(self) -> Close {
169 Close {
170 method: CloseMethod::Close,
171 params: CloseParams {},
172 }
173 }
174}
175impl Close {
176 pub fn builder() -> CloseBuilder {
177 CloseBuilder
178 }
179}
180#[derive(Debug, Clone, Default)]
181pub struct CrashBuilder;
182impl CrashBuilder {
183 pub fn new() -> Self {
184 Self
185 }
186 pub fn build(self) -> Crash {
187 Crash {
188 method: CrashMethod::Crash,
189 params: CrashParams {},
190 }
191 }
192}
193impl Crash {
194 pub fn builder() -> CrashBuilder {
195 CrashBuilder
196 }
197}
198#[derive(Debug, Clone, Default)]
199pub struct CrashGpuProcessBuilder;
200impl CrashGpuProcessBuilder {
201 pub fn new() -> Self {
202 Self
203 }
204 pub fn build(self) -> CrashGpuProcess {
205 CrashGpuProcess {
206 method: CrashGpuProcessMethod::CrashGpuProcess,
207 params: CrashGpuProcessParams {},
208 }
209 }
210}
211impl CrashGpuProcess {
212 pub fn builder() -> CrashGpuProcessBuilder {
213 CrashGpuProcessBuilder
214 }
215}
216#[derive(Debug, Clone, Default)]
217pub struct GetVersionBuilder;
218impl GetVersionBuilder {
219 pub fn new() -> Self {
220 Self
221 }
222 pub fn build(self) -> GetVersion {
223 GetVersion {
224 method: GetVersionMethod::GetVersion,
225 params: GetVersionParams {},
226 }
227 }
228}
229impl GetVersion {
230 pub fn builder() -> GetVersionBuilder {
231 GetVersionBuilder
232 }
233}
234#[derive(Debug, Clone, Default)]
235pub struct GetBrowserCommandLineBuilder;
236impl GetBrowserCommandLineBuilder {
237 pub fn new() -> Self {
238 Self
239 }
240 pub fn build(self) -> GetBrowserCommandLine {
241 GetBrowserCommandLine {
242 method: GetBrowserCommandLineMethod::GetBrowserCommandLine,
243 params: GetBrowserCommandLineParams {},
244 }
245 }
246}
247impl GetBrowserCommandLine {
248 pub fn builder() -> GetBrowserCommandLineBuilder {
249 GetBrowserCommandLineBuilder
250 }
251}
252impl GetHistograms {
253 pub fn builder() -> GetHistogramsBuilder {
254 <GetHistogramsBuilder as Default>::default()
255 }
256}
257#[derive(Default, Clone)]
258pub struct GetHistogramsBuilder {
259 query: Option<String>,
260 delta: Option<bool>,
261}
262impl GetHistogramsBuilder {
263 pub fn query(mut self, query: impl Into<String>) -> Self {
264 self.query = Some(query.into());
265 self
266 }
267 pub fn delta(mut self, delta: impl Into<bool>) -> Self {
268 self.delta = Some(delta.into());
269 self
270 }
271 pub fn build(self) -> GetHistograms {
272 GetHistograms {
273 method: GetHistogramsMethod::GetHistograms,
274 params: GetHistogramsParams {
275 query: self.query,
276 delta: self.delta,
277 },
278 }
279 }
280}
281impl GetHistogram {
282 pub fn builder() -> GetHistogramBuilder {
283 <GetHistogramBuilder as Default>::default()
284 }
285}
286#[derive(Default, Clone)]
287pub struct GetHistogramBuilder {
288 name: Option<String>,
289 delta: Option<bool>,
290}
291impl GetHistogramBuilder {
292 pub fn name(mut self, name: impl Into<String>) -> Self {
293 self.name = Some(name.into());
294 self
295 }
296 pub fn delta(mut self, delta: impl Into<bool>) -> Self {
297 self.delta = Some(delta.into());
298 self
299 }
300 pub fn build(self) -> Result<GetHistogram, String> {
301 Ok(GetHistogram {
302 method: GetHistogramMethod::GetHistogram,
303 params: GetHistogramParams {
304 name: self
305 .name
306 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(name)))?,
307 delta: self.delta,
308 },
309 })
310 }
311}
312impl GetWindowBounds {
313 pub fn builder() -> GetWindowBoundsBuilder {
314 <GetWindowBoundsBuilder as Default>::default()
315 }
316}
317#[derive(Default, Clone)]
318pub struct GetWindowBoundsBuilder {
319 window_id: Option<super::types::WindowId>,
320}
321impl GetWindowBoundsBuilder {
322 pub fn window_id(mut self, window_id: impl Into<super::types::WindowId>) -> Self {
323 self.window_id = Some(window_id.into());
324 self
325 }
326 pub fn build(self) -> Result<GetWindowBounds, String> {
327 Ok(GetWindowBounds {
328 method: GetWindowBoundsMethod::GetWindowBounds,
329 params: GetWindowBoundsParams {
330 window_id: self.window_id.ok_or_else(|| {
331 format!("Field `{}` is mandatory.", std::stringify!(window_id))
332 })?,
333 },
334 })
335 }
336}
337impl GetWindowForTarget {
338 pub fn builder() -> GetWindowForTargetBuilder {
339 <GetWindowForTargetBuilder as Default>::default()
340 }
341}
342#[derive(Default, Clone)]
343pub struct GetWindowForTargetBuilder {
344 target_id: Option<crate::browser_protocol::target::types::TargetId>,
345}
346impl GetWindowForTargetBuilder {
347 pub fn target_id(
348 mut self,
349 target_id: impl Into<crate::browser_protocol::target::types::TargetId>,
350 ) -> Self {
351 self.target_id = Some(target_id.into());
352 self
353 }
354 pub fn build(self) -> GetWindowForTarget {
355 GetWindowForTarget {
356 method: GetWindowForTargetMethod::GetWindowForTarget,
357 params: GetWindowForTargetParams {
358 target_id: self.target_id,
359 },
360 }
361 }
362}
363impl SetWindowBounds {
364 pub fn builder() -> SetWindowBoundsBuilder {
365 <SetWindowBoundsBuilder as Default>::default()
366 }
367}
368#[derive(Default, Clone)]
369pub struct SetWindowBoundsBuilder {
370 window_id: Option<super::types::WindowId>,
371 bounds: Option<super::types::Bounds>,
372}
373impl SetWindowBoundsBuilder {
374 pub fn window_id(mut self, window_id: impl Into<super::types::WindowId>) -> Self {
375 self.window_id = Some(window_id.into());
376 self
377 }
378 pub fn bounds(mut self, bounds: impl Into<super::types::Bounds>) -> Self {
379 self.bounds = Some(bounds.into());
380 self
381 }
382 pub fn build(self) -> Result<SetWindowBounds, String> {
383 Ok(SetWindowBounds {
384 method: SetWindowBoundsMethod::SetWindowBounds,
385 params: SetWindowBoundsParams {
386 window_id: self.window_id.ok_or_else(|| {
387 format!("Field `{}` is mandatory.", std::stringify!(window_id))
388 })?,
389 bounds: self
390 .bounds
391 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(bounds)))?,
392 },
393 })
394 }
395}
396impl SetContentsSize {
397 pub fn builder() -> SetContentsSizeBuilder {
398 <SetContentsSizeBuilder as Default>::default()
399 }
400}
401#[derive(Default, Clone)]
402pub struct SetContentsSizeBuilder {
403 window_id: Option<super::types::WindowId>,
404 width: Option<i64>,
405 height: Option<i64>,
406}
407impl SetContentsSizeBuilder {
408 pub fn window_id(mut self, window_id: impl Into<super::types::WindowId>) -> Self {
409 self.window_id = Some(window_id.into());
410 self
411 }
412 pub fn width(mut self, width: impl Into<i64>) -> Self {
413 self.width = Some(width.into());
414 self
415 }
416 pub fn height(mut self, height: impl Into<i64>) -> Self {
417 self.height = Some(height.into());
418 self
419 }
420 pub fn build(self) -> Result<SetContentsSize, String> {
421 Ok(SetContentsSize {
422 method: SetContentsSizeMethod::SetContentsSize,
423 params: SetContentsSizeParams {
424 window_id: self.window_id.ok_or_else(|| {
425 format!("Field `{}` is mandatory.", std::stringify!(window_id))
426 })?,
427 width: self.width,
428 height: self.height,
429 },
430 })
431 }
432}
433impl SetDockTile {
434 pub fn builder() -> SetDockTileBuilder {
435 <SetDockTileBuilder as Default>::default()
436 }
437}
438#[derive(Default, Clone)]
439pub struct SetDockTileBuilder {
440 badge_label: Option<String>,
441 image: Option<crate::Binary>,
442}
443impl SetDockTileBuilder {
444 pub fn badge_label(mut self, badge_label: impl Into<String>) -> Self {
445 self.badge_label = Some(badge_label.into());
446 self
447 }
448 pub fn image(mut self, image: impl Into<crate::Binary>) -> Self {
449 self.image = Some(image.into());
450 self
451 }
452 pub fn build(self) -> SetDockTile {
453 SetDockTile {
454 method: SetDockTileMethod::SetDockTile,
455 params: SetDockTileParams {
456 badge_label: self.badge_label,
457 image: self.image,
458 },
459 }
460 }
461}
462impl ExecuteBrowserCommand {
463 pub fn builder() -> ExecuteBrowserCommandBuilder {
464 <ExecuteBrowserCommandBuilder as Default>::default()
465 }
466}
467#[derive(Default, Clone)]
468pub struct ExecuteBrowserCommandBuilder {
469 command_id: Option<super::types::BrowserCommandId>,
470}
471impl ExecuteBrowserCommandBuilder {
472 pub fn command_id(mut self, command_id: impl Into<super::types::BrowserCommandId>) -> Self {
473 self.command_id = Some(command_id.into());
474 self
475 }
476 pub fn build(self) -> Result<ExecuteBrowserCommand, String> {
477 Ok(ExecuteBrowserCommand {
478 method: ExecuteBrowserCommandMethod::ExecuteBrowserCommand,
479 params: ExecuteBrowserCommandParams {
480 command_id: self.command_id.ok_or_else(|| {
481 format!("Field `{}` is mandatory.", std::stringify!(command_id))
482 })?,
483 },
484 })
485 }
486}
487impl AddPrivacySandboxEnrollmentOverride {
488 pub fn builder() -> AddPrivacySandboxEnrollmentOverrideBuilder {
489 <AddPrivacySandboxEnrollmentOverrideBuilder as Default>::default()
490 }
491}
492#[derive(Default, Clone)]
493pub struct AddPrivacySandboxEnrollmentOverrideBuilder {
494 url: Option<String>,
495}
496impl AddPrivacySandboxEnrollmentOverrideBuilder {
497 pub fn url(mut self, url: impl Into<String>) -> Self {
498 self.url = Some(url.into());
499 self
500 }
501 pub fn build(self) -> Result<AddPrivacySandboxEnrollmentOverride, String> {
502 Ok(AddPrivacySandboxEnrollmentOverride {
503 method: AddPrivacySandboxEnrollmentOverrideMethod::AddPrivacySandboxEnrollmentOverride,
504 params: AddPrivacySandboxEnrollmentOverrideParams {
505 url: self
506 .url
507 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(url)))?,
508 },
509 })
510 }
511}
512impl AddPrivacySandboxCoordinatorKeyConfig {
513 pub fn builder() -> AddPrivacySandboxCoordinatorKeyConfigBuilder {
514 <AddPrivacySandboxCoordinatorKeyConfigBuilder as Default>::default()
515 }
516}
517#[derive(Default, Clone)]
518pub struct AddPrivacySandboxCoordinatorKeyConfigBuilder {
519 api: Option<super::types::PrivacySandboxApi>,
520 coordinator_origin: Option<String>,
521 key_config: Option<String>,
522 browser_context_id: Option<super::types::BrowserContextId>,
523}
524impl AddPrivacySandboxCoordinatorKeyConfigBuilder {
525 pub fn api(mut self, api: impl Into<super::types::PrivacySandboxApi>) -> Self {
526 self.api = Some(api.into());
527 self
528 }
529 pub fn coordinator_origin(mut self, coordinator_origin: impl Into<String>) -> Self {
530 self.coordinator_origin = Some(coordinator_origin.into());
531 self
532 }
533 pub fn key_config(mut self, key_config: impl Into<String>) -> Self {
534 self.key_config = Some(key_config.into());
535 self
536 }
537 pub fn browser_context_id(
538 mut self,
539 browser_context_id: impl Into<super::types::BrowserContextId>,
540 ) -> Self {
541 self.browser_context_id = Some(browser_context_id.into());
542 self
543 }
544 pub fn build(self) -> Result<AddPrivacySandboxCoordinatorKeyConfig, String> {
545 Ok(AddPrivacySandboxCoordinatorKeyConfig {
546 method:
547 AddPrivacySandboxCoordinatorKeyConfigMethod::AddPrivacySandboxCoordinatorKeyConfig,
548 params: AddPrivacySandboxCoordinatorKeyConfigParams {
549 api: self
550 .api
551 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(api)))?,
552 coordinator_origin: self.coordinator_origin.ok_or_else(|| {
553 format!(
554 "Field `{}` is mandatory.",
555 std::stringify!(coordinator_origin)
556 )
557 })?,
558 key_config: self.key_config.ok_or_else(|| {
559 format!("Field `{}` is mandatory.", std::stringify!(key_config))
560 })?,
561 browser_context_id: self.browser_context_id.map(Box::new),
562 },
563 })
564 }
565}