Skip to main content

browser_protocol/tracing/
mod.rs

1use serde::{Serialize, Deserialize};
2use serde_json::Value as JsonValue;
3use std::borrow::Cow;
4
5/// Configuration for memory dump. Used only when "memory-infra" category is enabled.
6
7pub type MemoryDumpConfig = serde_json::Map<String, JsonValue>;
8
9
10#[derive(Debug, Clone, Serialize, Deserialize, Default)]
11#[serde(rename_all = "camelCase")]
12pub struct TraceConfig<'a> {
13    /// Controls how the trace buffer stores data. The default is 'recordUntilFull'.
14    #[serde(skip_serializing_if = "Option::is_none", rename = "recordMode")]
15    record_mode: Option<Cow<'a, str>>,
16    /// Size of the trace buffer in kilobytes. If not specified or zero is passed, a default value
17    /// of 200 MB would be used.
18    #[serde(skip_serializing_if = "Option::is_none", rename = "traceBufferSizeInKb")]
19    trace_buffer_size_in_kb: Option<f64>,
20    /// Turns on JavaScript stack sampling.
21    #[serde(skip_serializing_if = "Option::is_none", rename = "enableSampling")]
22    enable_sampling: Option<bool>,
23    /// Turns on system tracing.
24    #[serde(skip_serializing_if = "Option::is_none", rename = "enableSystrace")]
25    enable_systrace: Option<bool>,
26    /// Turns on argument filter.
27    #[serde(skip_serializing_if = "Option::is_none", rename = "enableArgumentFilter")]
28    enable_argument_filter: Option<bool>,
29    /// Included category filters.
30    #[serde(skip_serializing_if = "Option::is_none", rename = "includedCategories")]
31    included_categories: Option<Vec<Cow<'a, str>>>,
32    /// Excluded category filters.
33    #[serde(skip_serializing_if = "Option::is_none", rename = "excludedCategories")]
34    excluded_categories: Option<Vec<Cow<'a, str>>>,
35    /// Configuration to synthesize the delays in tracing.
36    #[serde(skip_serializing_if = "Option::is_none", rename = "syntheticDelays")]
37    synthetic_delays: Option<Vec<Cow<'a, str>>>,
38    /// Configuration for memory dump triggers. Used only when "memory-infra" category is enabled.
39    #[serde(skip_serializing_if = "Option::is_none", rename = "memoryDumpConfig")]
40    memory_dump_config: Option<MemoryDumpConfig>,
41}
42
43impl<'a> TraceConfig<'a> {
44    /// Creates a builder for this type.
45    pub fn builder() -> TraceConfigBuilder<'a> {
46        TraceConfigBuilder {
47            record_mode: None,
48            trace_buffer_size_in_kb: None,
49            enable_sampling: None,
50            enable_systrace: None,
51            enable_argument_filter: None,
52            included_categories: None,
53            excluded_categories: None,
54            synthetic_delays: None,
55            memory_dump_config: None,
56        }
57    }
58    /// Controls how the trace buffer stores data. The default is 'recordUntilFull'.
59    pub fn record_mode(&self) -> Option<&str> { self.record_mode.as_deref() }
60    /// Size of the trace buffer in kilobytes. If not specified or zero is passed, a default value
61    /// of 200 MB would be used.
62    pub fn trace_buffer_size_in_kb(&self) -> Option<f64> { self.trace_buffer_size_in_kb }
63    /// Turns on JavaScript stack sampling.
64    pub fn enable_sampling(&self) -> Option<bool> { self.enable_sampling }
65    /// Turns on system tracing.
66    pub fn enable_systrace(&self) -> Option<bool> { self.enable_systrace }
67    /// Turns on argument filter.
68    pub fn enable_argument_filter(&self) -> Option<bool> { self.enable_argument_filter }
69    /// Included category filters.
70    pub fn included_categories(&self) -> Option<&[Cow<'a, str>]> { self.included_categories.as_deref() }
71    /// Excluded category filters.
72    pub fn excluded_categories(&self) -> Option<&[Cow<'a, str>]> { self.excluded_categories.as_deref() }
73    /// Configuration to synthesize the delays in tracing.
74    pub fn synthetic_delays(&self) -> Option<&[Cow<'a, str>]> { self.synthetic_delays.as_deref() }
75    /// Configuration for memory dump triggers. Used only when "memory-infra" category is enabled.
76    pub fn memory_dump_config(&self) -> Option<&MemoryDumpConfig> { self.memory_dump_config.as_ref() }
77}
78
79#[derive(Default)]
80pub struct TraceConfigBuilder<'a> {
81    record_mode: Option<Cow<'a, str>>,
82    trace_buffer_size_in_kb: Option<f64>,
83    enable_sampling: Option<bool>,
84    enable_systrace: Option<bool>,
85    enable_argument_filter: Option<bool>,
86    included_categories: Option<Vec<Cow<'a, str>>>,
87    excluded_categories: Option<Vec<Cow<'a, str>>>,
88    synthetic_delays: Option<Vec<Cow<'a, str>>>,
89    memory_dump_config: Option<MemoryDumpConfig>,
90}
91
92impl<'a> TraceConfigBuilder<'a> {
93    /// Controls how the trace buffer stores data. The default is 'recordUntilFull'.
94    pub fn record_mode(mut self, record_mode: impl Into<Cow<'a, str>>) -> Self { self.record_mode = Some(record_mode.into()); self }
95    /// Size of the trace buffer in kilobytes. If not specified or zero is passed, a default value
96    /// of 200 MB would be used.
97    pub fn trace_buffer_size_in_kb(mut self, trace_buffer_size_in_kb: f64) -> Self { self.trace_buffer_size_in_kb = Some(trace_buffer_size_in_kb); self }
98    /// Turns on JavaScript stack sampling.
99    pub fn enable_sampling(mut self, enable_sampling: bool) -> Self { self.enable_sampling = Some(enable_sampling); self }
100    /// Turns on system tracing.
101    pub fn enable_systrace(mut self, enable_systrace: bool) -> Self { self.enable_systrace = Some(enable_systrace); self }
102    /// Turns on argument filter.
103    pub fn enable_argument_filter(mut self, enable_argument_filter: bool) -> Self { self.enable_argument_filter = Some(enable_argument_filter); self }
104    /// Included category filters.
105    pub fn included_categories(mut self, included_categories: Vec<Cow<'a, str>>) -> Self { self.included_categories = Some(included_categories); self }
106    /// Excluded category filters.
107    pub fn excluded_categories(mut self, excluded_categories: Vec<Cow<'a, str>>) -> Self { self.excluded_categories = Some(excluded_categories); self }
108    /// Configuration to synthesize the delays in tracing.
109    pub fn synthetic_delays(mut self, synthetic_delays: Vec<Cow<'a, str>>) -> Self { self.synthetic_delays = Some(synthetic_delays); self }
110    /// Configuration for memory dump triggers. Used only when "memory-infra" category is enabled.
111    pub fn memory_dump_config(mut self, memory_dump_config: MemoryDumpConfig) -> Self { self.memory_dump_config = Some(memory_dump_config); self }
112    pub fn build(self) -> TraceConfig<'a> {
113        TraceConfig {
114            record_mode: self.record_mode,
115            trace_buffer_size_in_kb: self.trace_buffer_size_in_kb,
116            enable_sampling: self.enable_sampling,
117            enable_systrace: self.enable_systrace,
118            enable_argument_filter: self.enable_argument_filter,
119            included_categories: self.included_categories,
120            excluded_categories: self.excluded_categories,
121            synthetic_delays: self.synthetic_delays,
122            memory_dump_config: self.memory_dump_config,
123        }
124    }
125}
126
127/// Data format of a trace. Can be either the legacy JSON format or the
128/// protocol buffer format. Note that the JSON format will be deprecated soon.
129
130#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
131pub enum StreamFormat {
132    #[default]
133    #[serde(rename = "json")]
134    Json,
135    #[serde(rename = "proto")]
136    Proto,
137}
138
139/// Compression type to use for traces returned via streams.
140
141#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
142pub enum StreamCompression {
143    #[default]
144    #[serde(rename = "none")]
145    None,
146    #[serde(rename = "gzip")]
147    Gzip,
148}
149
150/// Details exposed when memory request explicitly declared.
151/// Keep consistent with memory_dump_request_args.h and
152/// memory_instrumentation.mojom
153
154#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
155pub enum MemoryDumpLevelOfDetail {
156    #[default]
157    #[serde(rename = "background")]
158    Background,
159    #[serde(rename = "light")]
160    Light,
161    #[serde(rename = "detailed")]
162    Detailed,
163}
164
165/// Backend type to use for tracing. 'chrome' uses the Chrome-integrated
166/// tracing service and is supported on all platforms. 'system' is only
167/// supported on Chrome OS and uses the Perfetto system tracing service.
168/// 'auto' chooses 'system' when the perfettoConfig provided to Tracing.start
169/// specifies at least one non-Chrome data source; otherwise uses 'chrome'.
170
171#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
172pub enum TracingBackend {
173    #[default]
174    #[serde(rename = "auto")]
175    Auto,
176    #[serde(rename = "chrome")]
177    Chrome,
178    #[serde(rename = "system")]
179    System,
180}
181
182#[derive(Debug, Clone, Serialize, Deserialize, Default)]
183pub struct EndParams {}
184
185impl EndParams { pub const METHOD: &'static str = "Tracing.end"; }
186
187impl<'a> crate::CdpCommand<'a> for EndParams {
188    const METHOD: &'static str = "Tracing.end";
189    type Response = crate::EmptyReturns;
190}
191
192/// Gets supported tracing categories.
193
194#[derive(Debug, Clone, Serialize, Deserialize, Default)]
195#[serde(rename_all = "camelCase")]
196pub struct GetCategoriesReturns<'a> {
197    /// A list of supported tracing categories.
198    categories: Vec<Cow<'a, str>>,
199}
200
201impl<'a> GetCategoriesReturns<'a> {
202    /// Creates a builder for this type with the required parameters:
203    /// * `categories`: A list of supported tracing categories.
204    pub fn builder(categories: Vec<Cow<'a, str>>) -> GetCategoriesReturnsBuilder<'a> {
205        GetCategoriesReturnsBuilder {
206            categories: categories,
207        }
208    }
209    /// A list of supported tracing categories.
210    pub fn categories(&self) -> &[Cow<'a, str>] { &self.categories }
211}
212
213
214pub struct GetCategoriesReturnsBuilder<'a> {
215    categories: Vec<Cow<'a, str>>,
216}
217
218impl<'a> GetCategoriesReturnsBuilder<'a> {
219    pub fn build(self) -> GetCategoriesReturns<'a> {
220        GetCategoriesReturns {
221            categories: self.categories,
222        }
223    }
224}
225
226#[derive(Debug, Clone, Serialize, Deserialize, Default)]
227pub struct GetCategoriesParams {}
228
229impl GetCategoriesParams { pub const METHOD: &'static str = "Tracing.getCategories"; }
230
231impl<'a> crate::CdpCommand<'a> for GetCategoriesParams {
232    const METHOD: &'static str = "Tracing.getCategories";
233    type Response = GetCategoriesReturns<'a>;
234}
235
236/// Return a descriptor for all available tracing categories.
237
238#[derive(Debug, Clone, Serialize, Deserialize, Default)]
239#[serde(rename_all = "camelCase")]
240pub struct GetTrackEventDescriptorReturns<'a> {
241    /// Base64-encoded serialized perfetto.protos.TrackEventDescriptor protobuf message. (Encoded as a base64 string when passed over JSON)
242    descriptor: Cow<'a, str>,
243}
244
245impl<'a> GetTrackEventDescriptorReturns<'a> {
246    /// Creates a builder for this type with the required parameters:
247    /// * `descriptor`: Base64-encoded serialized perfetto.protos.TrackEventDescriptor protobuf message. (Encoded as a base64 string when passed over JSON)
248    pub fn builder(descriptor: impl Into<Cow<'a, str>>) -> GetTrackEventDescriptorReturnsBuilder<'a> {
249        GetTrackEventDescriptorReturnsBuilder {
250            descriptor: descriptor.into(),
251        }
252    }
253    /// Base64-encoded serialized perfetto.protos.TrackEventDescriptor protobuf message. (Encoded as a base64 string when passed over JSON)
254    pub fn descriptor(&self) -> &str { self.descriptor.as_ref() }
255}
256
257
258pub struct GetTrackEventDescriptorReturnsBuilder<'a> {
259    descriptor: Cow<'a, str>,
260}
261
262impl<'a> GetTrackEventDescriptorReturnsBuilder<'a> {
263    pub fn build(self) -> GetTrackEventDescriptorReturns<'a> {
264        GetTrackEventDescriptorReturns {
265            descriptor: self.descriptor,
266        }
267    }
268}
269
270#[derive(Debug, Clone, Serialize, Deserialize, Default)]
271pub struct GetTrackEventDescriptorParams {}
272
273impl GetTrackEventDescriptorParams { pub const METHOD: &'static str = "Tracing.getTrackEventDescriptor"; }
274
275impl<'a> crate::CdpCommand<'a> for GetTrackEventDescriptorParams {
276    const METHOD: &'static str = "Tracing.getTrackEventDescriptor";
277    type Response = GetTrackEventDescriptorReturns<'a>;
278}
279
280/// Record a clock sync marker in the trace.
281
282#[derive(Debug, Clone, Serialize, Deserialize, Default)]
283#[serde(rename_all = "camelCase")]
284pub struct RecordClockSyncMarkerParams<'a> {
285    /// The ID of this clock sync marker
286    #[serde(rename = "syncId")]
287    sync_id: Cow<'a, str>,
288}
289
290impl<'a> RecordClockSyncMarkerParams<'a> {
291    /// Creates a builder for this type with the required parameters:
292    /// * `sync_id`: The ID of this clock sync marker
293    pub fn builder(sync_id: impl Into<Cow<'a, str>>) -> RecordClockSyncMarkerParamsBuilder<'a> {
294        RecordClockSyncMarkerParamsBuilder {
295            sync_id: sync_id.into(),
296        }
297    }
298    /// The ID of this clock sync marker
299    pub fn sync_id(&self) -> &str { self.sync_id.as_ref() }
300}
301
302
303pub struct RecordClockSyncMarkerParamsBuilder<'a> {
304    sync_id: Cow<'a, str>,
305}
306
307impl<'a> RecordClockSyncMarkerParamsBuilder<'a> {
308    pub fn build(self) -> RecordClockSyncMarkerParams<'a> {
309        RecordClockSyncMarkerParams {
310            sync_id: self.sync_id,
311        }
312    }
313}
314
315impl<'a> RecordClockSyncMarkerParams<'a> { pub const METHOD: &'static str = "Tracing.recordClockSyncMarker"; }
316
317impl<'a> crate::CdpCommand<'a> for RecordClockSyncMarkerParams<'a> {
318    const METHOD: &'static str = "Tracing.recordClockSyncMarker";
319    type Response = crate::EmptyReturns;
320}
321
322/// Request a global memory dump.
323
324#[derive(Debug, Clone, Serialize, Deserialize, Default)]
325#[serde(rename_all = "camelCase")]
326pub struct RequestMemoryDumpParams {
327    /// Enables more deterministic results by forcing garbage collection
328    #[serde(skip_serializing_if = "Option::is_none")]
329    deterministic: Option<bool>,
330    /// Specifies level of details in memory dump. Defaults to "detailed".
331    #[serde(skip_serializing_if = "Option::is_none", rename = "levelOfDetail")]
332    level_of_detail: Option<MemoryDumpLevelOfDetail>,
333}
334
335impl RequestMemoryDumpParams {
336    /// Creates a builder for this type.
337    pub fn builder() -> RequestMemoryDumpParamsBuilder {
338        RequestMemoryDumpParamsBuilder {
339            deterministic: None,
340            level_of_detail: None,
341        }
342    }
343    /// Enables more deterministic results by forcing garbage collection
344    pub fn deterministic(&self) -> Option<bool> { self.deterministic }
345    /// Specifies level of details in memory dump. Defaults to "detailed".
346    pub fn level_of_detail(&self) -> Option<&MemoryDumpLevelOfDetail> { self.level_of_detail.as_ref() }
347}
348
349#[derive(Default)]
350pub struct RequestMemoryDumpParamsBuilder {
351    deterministic: Option<bool>,
352    level_of_detail: Option<MemoryDumpLevelOfDetail>,
353}
354
355impl RequestMemoryDumpParamsBuilder {
356    /// Enables more deterministic results by forcing garbage collection
357    pub fn deterministic(mut self, deterministic: bool) -> Self { self.deterministic = Some(deterministic); self }
358    /// Specifies level of details in memory dump. Defaults to "detailed".
359    pub fn level_of_detail(mut self, level_of_detail: impl Into<MemoryDumpLevelOfDetail>) -> Self { self.level_of_detail = Some(level_of_detail.into()); self }
360    pub fn build(self) -> RequestMemoryDumpParams {
361        RequestMemoryDumpParams {
362            deterministic: self.deterministic,
363            level_of_detail: self.level_of_detail,
364        }
365    }
366}
367
368/// Request a global memory dump.
369
370#[derive(Debug, Clone, Serialize, Deserialize, Default)]
371#[serde(rename_all = "camelCase")]
372pub struct RequestMemoryDumpReturns<'a> {
373    /// GUID of the resulting global memory dump.
374    #[serde(rename = "dumpGuid")]
375    dump_guid: Cow<'a, str>,
376    /// True iff the global memory dump succeeded.
377    success: bool,
378}
379
380impl<'a> RequestMemoryDumpReturns<'a> {
381    /// Creates a builder for this type with the required parameters:
382    /// * `dump_guid`: GUID of the resulting global memory dump.
383    /// * `success`: True iff the global memory dump succeeded.
384    pub fn builder(dump_guid: impl Into<Cow<'a, str>>, success: bool) -> RequestMemoryDumpReturnsBuilder<'a> {
385        RequestMemoryDumpReturnsBuilder {
386            dump_guid: dump_guid.into(),
387            success: success,
388        }
389    }
390    /// GUID of the resulting global memory dump.
391    pub fn dump_guid(&self) -> &str { self.dump_guid.as_ref() }
392    /// True iff the global memory dump succeeded.
393    pub fn success(&self) -> bool { self.success }
394}
395
396
397pub struct RequestMemoryDumpReturnsBuilder<'a> {
398    dump_guid: Cow<'a, str>,
399    success: bool,
400}
401
402impl<'a> RequestMemoryDumpReturnsBuilder<'a> {
403    pub fn build(self) -> RequestMemoryDumpReturns<'a> {
404        RequestMemoryDumpReturns {
405            dump_guid: self.dump_guid,
406            success: self.success,
407        }
408    }
409}
410
411impl RequestMemoryDumpParams { pub const METHOD: &'static str = "Tracing.requestMemoryDump"; }
412
413impl<'a> crate::CdpCommand<'a> for RequestMemoryDumpParams {
414    const METHOD: &'static str = "Tracing.requestMemoryDump";
415    type Response = RequestMemoryDumpReturns<'a>;
416}
417
418/// Start trace events collection.
419
420#[derive(Debug, Clone, Serialize, Deserialize, Default)]
421#[serde(rename_all = "camelCase")]
422pub struct StartParams<'a> {
423    /// Category/tag filter
424    #[serde(skip_serializing_if = "Option::is_none")]
425    categories: Option<Cow<'a, str>>,
426    /// Tracing options
427    #[serde(skip_serializing_if = "Option::is_none")]
428    options: Option<Cow<'a, str>>,
429    /// If set, the agent will issue bufferUsage events at this interval, specified in milliseconds
430    #[serde(skip_serializing_if = "Option::is_none", rename = "bufferUsageReportingInterval")]
431    buffer_usage_reporting_interval: Option<f64>,
432    /// Whether to report trace events as series of dataCollected events or to save trace to a
433    /// stream (defaults to 'ReportEvents').
434    #[serde(skip_serializing_if = "Option::is_none", rename = "transferMode")]
435    transfer_mode: Option<Cow<'a, str>>,
436    /// Trace data format to use. This only applies when using 'ReturnAsStream'
437    /// transfer mode (defaults to 'json').
438    #[serde(skip_serializing_if = "Option::is_none", rename = "streamFormat")]
439    stream_format: Option<StreamFormat>,
440    /// Compression format to use. This only applies when using 'ReturnAsStream'
441    /// transfer mode (defaults to 'none')
442    #[serde(skip_serializing_if = "Option::is_none", rename = "streamCompression")]
443    stream_compression: Option<StreamCompression>,
444    #[serde(skip_serializing_if = "Option::is_none", rename = "traceConfig")]
445    trace_config: Option<TraceConfig<'a>>,
446    /// Base64-encoded serialized perfetto.protos.TraceConfig protobuf message
447    /// When specified, the parameters 'categories', 'options', 'traceConfig'
448    /// are ignored. (Encoded as a base64 string when passed over JSON)
449    #[serde(skip_serializing_if = "Option::is_none", rename = "perfettoConfig")]
450    perfetto_config: Option<Cow<'a, str>>,
451    /// Backend type (defaults to 'auto')
452    #[serde(skip_serializing_if = "Option::is_none", rename = "tracingBackend")]
453    tracing_backend: Option<TracingBackend>,
454}
455
456impl<'a> StartParams<'a> {
457    /// Creates a builder for this type.
458    pub fn builder() -> StartParamsBuilder<'a> {
459        StartParamsBuilder {
460            categories: None,
461            options: None,
462            buffer_usage_reporting_interval: None,
463            transfer_mode: None,
464            stream_format: None,
465            stream_compression: None,
466            trace_config: None,
467            perfetto_config: None,
468            tracing_backend: None,
469        }
470    }
471    /// Category/tag filter
472    pub fn categories(&self) -> Option<&str> { self.categories.as_deref() }
473    /// Tracing options
474    pub fn options(&self) -> Option<&str> { self.options.as_deref() }
475    /// If set, the agent will issue bufferUsage events at this interval, specified in milliseconds
476    pub fn buffer_usage_reporting_interval(&self) -> Option<f64> { self.buffer_usage_reporting_interval }
477    /// Whether to report trace events as series of dataCollected events or to save trace to a
478    /// stream (defaults to 'ReportEvents').
479    pub fn transfer_mode(&self) -> Option<&str> { self.transfer_mode.as_deref() }
480    /// Trace data format to use. This only applies when using 'ReturnAsStream'
481    /// transfer mode (defaults to 'json').
482    pub fn stream_format(&self) -> Option<&StreamFormat> { self.stream_format.as_ref() }
483    /// Compression format to use. This only applies when using 'ReturnAsStream'
484    /// transfer mode (defaults to 'none')
485    pub fn stream_compression(&self) -> Option<&StreamCompression> { self.stream_compression.as_ref() }
486    pub fn trace_config(&self) -> Option<&TraceConfig<'a>> { self.trace_config.as_ref() }
487    /// Base64-encoded serialized perfetto.protos.TraceConfig protobuf message
488    /// When specified, the parameters 'categories', 'options', 'traceConfig'
489    /// are ignored. (Encoded as a base64 string when passed over JSON)
490    pub fn perfetto_config(&self) -> Option<&str> { self.perfetto_config.as_deref() }
491    /// Backend type (defaults to 'auto')
492    pub fn tracing_backend(&self) -> Option<&TracingBackend> { self.tracing_backend.as_ref() }
493}
494
495#[derive(Default)]
496pub struct StartParamsBuilder<'a> {
497    categories: Option<Cow<'a, str>>,
498    options: Option<Cow<'a, str>>,
499    buffer_usage_reporting_interval: Option<f64>,
500    transfer_mode: Option<Cow<'a, str>>,
501    stream_format: Option<StreamFormat>,
502    stream_compression: Option<StreamCompression>,
503    trace_config: Option<TraceConfig<'a>>,
504    perfetto_config: Option<Cow<'a, str>>,
505    tracing_backend: Option<TracingBackend>,
506}
507
508impl<'a> StartParamsBuilder<'a> {
509    /// Category/tag filter
510    pub fn categories(mut self, categories: impl Into<Cow<'a, str>>) -> Self { self.categories = Some(categories.into()); self }
511    /// Tracing options
512    pub fn options(mut self, options: impl Into<Cow<'a, str>>) -> Self { self.options = Some(options.into()); self }
513    /// If set, the agent will issue bufferUsage events at this interval, specified in milliseconds
514    pub fn buffer_usage_reporting_interval(mut self, buffer_usage_reporting_interval: f64) -> Self { self.buffer_usage_reporting_interval = Some(buffer_usage_reporting_interval); self }
515    /// Whether to report trace events as series of dataCollected events or to save trace to a
516    /// stream (defaults to 'ReportEvents').
517    pub fn transfer_mode(mut self, transfer_mode: impl Into<Cow<'a, str>>) -> Self { self.transfer_mode = Some(transfer_mode.into()); self }
518    /// Trace data format to use. This only applies when using 'ReturnAsStream'
519    /// transfer mode (defaults to 'json').
520    pub fn stream_format(mut self, stream_format: impl Into<StreamFormat>) -> Self { self.stream_format = Some(stream_format.into()); self }
521    /// Compression format to use. This only applies when using 'ReturnAsStream'
522    /// transfer mode (defaults to 'none')
523    pub fn stream_compression(mut self, stream_compression: impl Into<StreamCompression>) -> Self { self.stream_compression = Some(stream_compression.into()); self }
524    pub fn trace_config(mut self, trace_config: TraceConfig<'a>) -> Self { self.trace_config = Some(trace_config); self }
525    /// Base64-encoded serialized perfetto.protos.TraceConfig protobuf message
526    /// When specified, the parameters 'categories', 'options', 'traceConfig'
527    /// are ignored. (Encoded as a base64 string when passed over JSON)
528    pub fn perfetto_config(mut self, perfetto_config: impl Into<Cow<'a, str>>) -> Self { self.perfetto_config = Some(perfetto_config.into()); self }
529    /// Backend type (defaults to 'auto')
530    pub fn tracing_backend(mut self, tracing_backend: impl Into<TracingBackend>) -> Self { self.tracing_backend = Some(tracing_backend.into()); self }
531    pub fn build(self) -> StartParams<'a> {
532        StartParams {
533            categories: self.categories,
534            options: self.options,
535            buffer_usage_reporting_interval: self.buffer_usage_reporting_interval,
536            transfer_mode: self.transfer_mode,
537            stream_format: self.stream_format,
538            stream_compression: self.stream_compression,
539            trace_config: self.trace_config,
540            perfetto_config: self.perfetto_config,
541            tracing_backend: self.tracing_backend,
542        }
543    }
544}
545
546impl<'a> StartParams<'a> { pub const METHOD: &'static str = "Tracing.start"; }
547
548impl<'a> crate::CdpCommand<'a> for StartParams<'a> {
549    const METHOD: &'static str = "Tracing.start";
550    type Response = crate::EmptyReturns;
551}