rustenium_cdp_definitions/browser_protocol/audits/
command_builders.rs1use super::commands::*;
2impl GetEncodedResponse {
3 pub fn builder() -> GetEncodedResponseBuilder {
4 <GetEncodedResponseBuilder as Default>::default()
5 }
6}
7#[derive(Default, Clone)]
8pub struct GetEncodedResponseBuilder {
9 request_id: Option<crate::browser_protocol::network::types::RequestId>,
10 encoding: Option<GetEncodedResponseEncoding>,
11 quality: Option<f64>,
12 size_only: Option<bool>,
13}
14impl GetEncodedResponseBuilder {
15 pub fn request_id(
16 mut self,
17 request_id: impl Into<crate::browser_protocol::network::types::RequestId>,
18 ) -> Self {
19 self.request_id = Some(request_id.into());
20 self
21 }
22 pub fn encoding(mut self, encoding: impl Into<GetEncodedResponseEncoding>) -> Self {
23 self.encoding = Some(encoding.into());
24 self
25 }
26 pub fn quality(mut self, quality: impl Into<f64>) -> Self {
27 self.quality = Some(quality.into());
28 self
29 }
30 pub fn size_only(mut self, size_only: impl Into<bool>) -> Self {
31 self.size_only = Some(size_only.into());
32 self
33 }
34 pub fn build(self) -> Result<GetEncodedResponse, String> {
35 Ok(GetEncodedResponse {
36 method: GetEncodedResponseMethod::GetEncodedResponse,
37 params: GetEncodedResponseParams {
38 request_id: self.request_id.ok_or_else(|| {
39 format!("Field `{}` is mandatory.", std::stringify!(request_id))
40 })?,
41 encoding: self.encoding.ok_or_else(|| {
42 format!("Field `{}` is mandatory.", std::stringify!(encoding))
43 })?,
44 quality: self.quality,
45 size_only: self.size_only,
46 },
47 })
48 }
49}
50#[derive(Debug, Clone, Default)]
51pub struct DisableBuilder;
52impl DisableBuilder {
53 pub fn new() -> Self {
54 Self
55 }
56 pub fn build(self) -> Disable {
57 Disable {
58 method: DisableMethod::Disable,
59 params: DisableParams {},
60 }
61 }
62}
63impl Disable {
64 pub fn builder() -> DisableBuilder {
65 DisableBuilder
66 }
67}
68#[derive(Debug, Clone, Default)]
69pub struct EnableBuilder;
70impl EnableBuilder {
71 pub fn new() -> Self {
72 Self
73 }
74 pub fn build(self) -> Enable {
75 Enable {
76 method: EnableMethod::Enable,
77 params: EnableParams {},
78 }
79 }
80}
81impl Enable {
82 pub fn builder() -> EnableBuilder {
83 EnableBuilder
84 }
85}
86impl CheckContrast {
87 pub fn builder() -> CheckContrastBuilder {
88 <CheckContrastBuilder as Default>::default()
89 }
90}
91#[derive(Default, Clone)]
92pub struct CheckContrastBuilder {
93 report_aaa: Option<bool>,
94}
95impl CheckContrastBuilder {
96 pub fn report_aaa(mut self, report_aaa: impl Into<bool>) -> Self {
97 self.report_aaa = Some(report_aaa.into());
98 self
99 }
100 pub fn build(self) -> CheckContrast {
101 CheckContrast {
102 method: CheckContrastMethod::CheckContrast,
103 params: CheckContrastParams {
104 report_aaa: self.report_aaa,
105 },
106 }
107 }
108}
109#[derive(Debug, Clone, Default)]
110pub struct CheckFormsIssuesBuilder;
111impl CheckFormsIssuesBuilder {
112 pub fn new() -> Self {
113 Self
114 }
115 pub fn build(self) -> CheckFormsIssues {
116 CheckFormsIssues {
117 method: CheckFormsIssuesMethod::CheckFormsIssues,
118 params: CheckFormsIssuesParams {},
119 }
120 }
121}
122impl CheckFormsIssues {
123 pub fn builder() -> CheckFormsIssuesBuilder {
124 CheckFormsIssuesBuilder
125 }
126}