rustenium_cdp_definitions/js_protocol/profiler/
command_builders.rs1use super::commands::*;
2#[derive(Debug, Clone, Default)]
3pub struct DisableBuilder;
4impl DisableBuilder {
5 pub fn new() -> Self {
6 Self
7 }
8 pub fn build(self) -> Disable {
9 Disable {
10 method: DisableMethod::Disable,
11 params: DisableParams {},
12 }
13 }
14}
15impl Disable {
16 pub fn builder() -> DisableBuilder {
17 DisableBuilder
18 }
19}
20#[derive(Debug, Clone, Default)]
21pub struct EnableBuilder;
22impl EnableBuilder {
23 pub fn new() -> Self {
24 Self
25 }
26 pub fn build(self) -> Enable {
27 Enable {
28 method: EnableMethod::Enable,
29 params: EnableParams {},
30 }
31 }
32}
33impl Enable {
34 pub fn builder() -> EnableBuilder {
35 EnableBuilder
36 }
37}
38#[derive(Debug, Clone, Default)]
39pub struct GetBestEffortCoverageBuilder;
40impl GetBestEffortCoverageBuilder {
41 pub fn new() -> Self {
42 Self
43 }
44 pub fn build(self) -> GetBestEffortCoverage {
45 GetBestEffortCoverage {
46 method: GetBestEffortCoverageMethod::GetBestEffortCoverage,
47 params: GetBestEffortCoverageParams {},
48 }
49 }
50}
51impl GetBestEffortCoverage {
52 pub fn builder() -> GetBestEffortCoverageBuilder {
53 GetBestEffortCoverageBuilder
54 }
55}
56impl SetSamplingInterval {
57 pub fn builder() -> SetSamplingIntervalBuilder {
58 <SetSamplingIntervalBuilder as Default>::default()
59 }
60}
61#[derive(Default, Clone)]
62pub struct SetSamplingIntervalBuilder {
63 interval: Option<i64>,
64}
65impl SetSamplingIntervalBuilder {
66 pub fn interval(mut self, interval: impl Into<i64>) -> Self {
67 self.interval = Some(interval.into());
68 self
69 }
70 pub fn build(self) -> Result<SetSamplingInterval, String> {
71 Ok(SetSamplingInterval {
72 method: SetSamplingIntervalMethod::SetSamplingInterval,
73 params: SetSamplingIntervalParams {
74 interval: self.interval.ok_or_else(|| {
75 format!("Field `{}` is mandatory.", std::stringify!(interval))
76 })?,
77 },
78 })
79 }
80}
81#[derive(Debug, Clone, Default)]
82pub struct StartBuilder;
83impl StartBuilder {
84 pub fn new() -> Self {
85 Self
86 }
87 pub fn build(self) -> Start {
88 Start {
89 method: StartMethod::Start,
90 params: StartParams {},
91 }
92 }
93}
94impl Start {
95 pub fn builder() -> StartBuilder {
96 StartBuilder
97 }
98}
99impl StartPreciseCoverage {
100 pub fn builder() -> StartPreciseCoverageBuilder {
101 <StartPreciseCoverageBuilder as Default>::default()
102 }
103}
104#[derive(Default, Clone)]
105pub struct StartPreciseCoverageBuilder {
106 call_count: Option<bool>,
107 detailed: Option<bool>,
108 allow_triggered_updates: Option<bool>,
109}
110impl StartPreciseCoverageBuilder {
111 pub fn call_count(mut self, call_count: impl Into<bool>) -> Self {
112 self.call_count = Some(call_count.into());
113 self
114 }
115 pub fn detailed(mut self, detailed: impl Into<bool>) -> Self {
116 self.detailed = Some(detailed.into());
117 self
118 }
119 pub fn allow_triggered_updates(mut self, allow_triggered_updates: impl Into<bool>) -> Self {
120 self.allow_triggered_updates = Some(allow_triggered_updates.into());
121 self
122 }
123 pub fn build(self) -> StartPreciseCoverage {
124 StartPreciseCoverage {
125 method: StartPreciseCoverageMethod::StartPreciseCoverage,
126 params: StartPreciseCoverageParams {
127 call_count: self.call_count,
128 detailed: self.detailed,
129 allow_triggered_updates: self.allow_triggered_updates,
130 },
131 }
132 }
133}
134#[derive(Debug, Clone, Default)]
135pub struct StopBuilder;
136impl StopBuilder {
137 pub fn new() -> Self {
138 Self
139 }
140 pub fn build(self) -> Stop {
141 Stop {
142 method: StopMethod::Stop,
143 params: StopParams {},
144 }
145 }
146}
147impl Stop {
148 pub fn builder() -> StopBuilder {
149 StopBuilder
150 }
151}
152#[derive(Debug, Clone, Default)]
153pub struct StopPreciseCoverageBuilder;
154impl StopPreciseCoverageBuilder {
155 pub fn new() -> Self {
156 Self
157 }
158 pub fn build(self) -> StopPreciseCoverage {
159 StopPreciseCoverage {
160 method: StopPreciseCoverageMethod::StopPreciseCoverage,
161 params: StopPreciseCoverageParams {},
162 }
163 }
164}
165impl StopPreciseCoverage {
166 pub fn builder() -> StopPreciseCoverageBuilder {
167 StopPreciseCoverageBuilder
168 }
169}
170#[derive(Debug, Clone, Default)]
171pub struct TakePreciseCoverageBuilder;
172impl TakePreciseCoverageBuilder {
173 pub fn new() -> Self {
174 Self
175 }
176 pub fn build(self) -> TakePreciseCoverage {
177 TakePreciseCoverage {
178 method: TakePreciseCoverageMethod::TakePreciseCoverage,
179 params: TakePreciseCoverageParams {},
180 }
181 }
182}
183impl TakePreciseCoverage {
184 pub fn builder() -> TakePreciseCoverageBuilder {
185 TakePreciseCoverageBuilder
186 }
187}