rustenium_cdp_definitions/browser_protocol/tracing/
command_builders.rs1use super::commands::*;
2#[derive(Debug, Clone, Default)]
3pub struct EndBuilder;
4impl EndBuilder {
5 pub fn new() -> Self {
6 Self
7 }
8 pub fn build(self) -> End {
9 End {
10 method: EndMethod::End,
11 params: EndParams {},
12 }
13 }
14}
15impl End {
16 pub fn builder() -> EndBuilder {
17 EndBuilder
18 }
19}
20#[derive(Debug, Clone, Default)]
21pub struct GetCategoriesBuilder;
22impl GetCategoriesBuilder {
23 pub fn new() -> Self {
24 Self
25 }
26 pub fn build(self) -> GetCategories {
27 GetCategories {
28 method: GetCategoriesMethod::GetCategories,
29 params: GetCategoriesParams {},
30 }
31 }
32}
33impl GetCategories {
34 pub fn builder() -> GetCategoriesBuilder {
35 GetCategoriesBuilder
36 }
37}
38#[derive(Debug, Clone, Default)]
39pub struct GetTrackEventDescriptorBuilder;
40impl GetTrackEventDescriptorBuilder {
41 pub fn new() -> Self {
42 Self
43 }
44 pub fn build(self) -> GetTrackEventDescriptor {
45 GetTrackEventDescriptor {
46 method: GetTrackEventDescriptorMethod::GetTrackEventDescriptor,
47 params: GetTrackEventDescriptorParams {},
48 }
49 }
50}
51impl GetTrackEventDescriptor {
52 pub fn builder() -> GetTrackEventDescriptorBuilder {
53 GetTrackEventDescriptorBuilder
54 }
55}
56impl RecordClockSyncMarker {
57 pub fn builder() -> RecordClockSyncMarkerBuilder {
58 <RecordClockSyncMarkerBuilder as Default>::default()
59 }
60}
61#[derive(Default, Clone)]
62pub struct RecordClockSyncMarkerBuilder {
63 sync_id: Option<String>,
64}
65impl RecordClockSyncMarkerBuilder {
66 pub fn sync_id(mut self, sync_id: impl Into<String>) -> Self {
67 self.sync_id = Some(sync_id.into());
68 self
69 }
70 pub fn build(self) -> Result<RecordClockSyncMarker, String> {
71 Ok(RecordClockSyncMarker {
72 method: RecordClockSyncMarkerMethod::RecordClockSyncMarker,
73 params: RecordClockSyncMarkerParams {
74 sync_id: self
75 .sync_id
76 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(sync_id)))?,
77 },
78 })
79 }
80}
81impl RequestMemoryDump {
82 pub fn builder() -> RequestMemoryDumpBuilder {
83 <RequestMemoryDumpBuilder as Default>::default()
84 }
85}
86#[derive(Default, Clone)]
87pub struct RequestMemoryDumpBuilder {
88 deterministic: Option<bool>,
89 level_of_detail: Option<super::types::MemoryDumpLevelOfDetail>,
90}
91impl RequestMemoryDumpBuilder {
92 pub fn deterministic(mut self, deterministic: impl Into<bool>) -> Self {
93 self.deterministic = Some(deterministic.into());
94 self
95 }
96 pub fn level_of_detail(
97 mut self,
98 level_of_detail: impl Into<super::types::MemoryDumpLevelOfDetail>,
99 ) -> Self {
100 self.level_of_detail = Some(level_of_detail.into());
101 self
102 }
103 pub fn build(self) -> RequestMemoryDump {
104 RequestMemoryDump {
105 method: RequestMemoryDumpMethod::RequestMemoryDump,
106 params: RequestMemoryDumpParams {
107 deterministic: self.deterministic,
108 level_of_detail: self.level_of_detail,
109 },
110 }
111 }
112}
113impl Start {
114 pub fn builder() -> StartBuilder {
115 <StartBuilder as Default>::default()
116 }
117}
118#[derive(Default, Clone)]
119pub struct StartBuilder {
120 buffer_usage_reporting_interval: Option<f64>,
121 transfer_mode: Option<StartTransferMode>,
122 stream_format: Option<super::types::StreamFormat>,
123 stream_compression: Option<super::types::StreamCompression>,
124 trace_config: Option<super::types::TraceConfig>,
125 perfetto_config: Option<crate::Binary>,
126 tracing_backend: Option<super::types::TracingBackend>,
127}
128impl StartBuilder {
129 pub fn buffer_usage_reporting_interval(
130 mut self,
131 buffer_usage_reporting_interval: impl Into<f64>,
132 ) -> Self {
133 self.buffer_usage_reporting_interval = Some(buffer_usage_reporting_interval.into());
134 self
135 }
136 pub fn transfer_mode(mut self, transfer_mode: impl Into<StartTransferMode>) -> Self {
137 self.transfer_mode = Some(transfer_mode.into());
138 self
139 }
140 pub fn stream_format(mut self, stream_format: impl Into<super::types::StreamFormat>) -> Self {
141 self.stream_format = Some(stream_format.into());
142 self
143 }
144 pub fn stream_compression(
145 mut self,
146 stream_compression: impl Into<super::types::StreamCompression>,
147 ) -> Self {
148 self.stream_compression = Some(stream_compression.into());
149 self
150 }
151 pub fn trace_config(mut self, trace_config: impl Into<super::types::TraceConfig>) -> Self {
152 self.trace_config = Some(trace_config.into());
153 self
154 }
155 pub fn perfetto_config(mut self, perfetto_config: impl Into<crate::Binary>) -> Self {
156 self.perfetto_config = Some(perfetto_config.into());
157 self
158 }
159 pub fn tracing_backend(
160 mut self,
161 tracing_backend: impl Into<super::types::TracingBackend>,
162 ) -> Self {
163 self.tracing_backend = Some(tracing_backend.into());
164 self
165 }
166 pub fn build(self) -> Start {
167 Start {
168 method: StartMethod::Start,
169 params: StartParams {
170 buffer_usage_reporting_interval: self.buffer_usage_reporting_interval,
171 transfer_mode: self.transfer_mode,
172 stream_format: self.stream_format,
173 stream_compression: self.stream_compression,
174 trace_config: self.trace_config,
175 perfetto_config: self.perfetto_config,
176 tracing_backend: self.tracing_backend,
177 },
178 }
179 }
180}