use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue;
use std::borrow::Cow;
pub type MemoryDumpConfig = serde_json::Map<String, JsonValue>;
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct TraceConfig<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
recordMode: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
traceBufferSizeInKb: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
enableSampling: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
enableSystrace: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
enableArgumentFilter: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
includedCategories: Option<Vec<Cow<'a, str>>>,
#[serde(skip_serializing_if = "Option::is_none")]
excludedCategories: Option<Vec<Cow<'a, str>>>,
#[serde(skip_serializing_if = "Option::is_none")]
syntheticDelays: Option<Vec<Cow<'a, str>>>,
#[serde(skip_serializing_if = "Option::is_none")]
memoryDumpConfig: Option<MemoryDumpConfig>,
}
impl<'a> TraceConfig<'a> {
pub fn builder() -> TraceConfigBuilder<'a> {
TraceConfigBuilder {
recordMode: None,
traceBufferSizeInKb: None,
enableSampling: None,
enableSystrace: None,
enableArgumentFilter: None,
includedCategories: None,
excludedCategories: None,
syntheticDelays: None,
memoryDumpConfig: None,
}
}
pub fn recordMode(&self) -> Option<&str> { self.recordMode.as_deref() }
pub fn traceBufferSizeInKb(&self) -> Option<f64> { self.traceBufferSizeInKb }
pub fn enableSampling(&self) -> Option<bool> { self.enableSampling }
pub fn enableSystrace(&self) -> Option<bool> { self.enableSystrace }
pub fn enableArgumentFilter(&self) -> Option<bool> { self.enableArgumentFilter }
pub fn includedCategories(&self) -> Option<&[Cow<'a, str>]> { self.includedCategories.as_deref() }
pub fn excludedCategories(&self) -> Option<&[Cow<'a, str>]> { self.excludedCategories.as_deref() }
pub fn syntheticDelays(&self) -> Option<&[Cow<'a, str>]> { self.syntheticDelays.as_deref() }
pub fn memoryDumpConfig(&self) -> Option<&MemoryDumpConfig> { self.memoryDumpConfig.as_ref() }
}
#[derive(Default)]
pub struct TraceConfigBuilder<'a> {
recordMode: Option<Cow<'a, str>>,
traceBufferSizeInKb: Option<f64>,
enableSampling: Option<bool>,
enableSystrace: Option<bool>,
enableArgumentFilter: Option<bool>,
includedCategories: Option<Vec<Cow<'a, str>>>,
excludedCategories: Option<Vec<Cow<'a, str>>>,
syntheticDelays: Option<Vec<Cow<'a, str>>>,
memoryDumpConfig: Option<MemoryDumpConfig>,
}
impl<'a> TraceConfigBuilder<'a> {
pub fn recordMode(mut self, recordMode: impl Into<Cow<'a, str>>) -> Self { self.recordMode = Some(recordMode.into()); self }
pub fn traceBufferSizeInKb(mut self, traceBufferSizeInKb: f64) -> Self { self.traceBufferSizeInKb = Some(traceBufferSizeInKb); self }
pub fn enableSampling(mut self, enableSampling: bool) -> Self { self.enableSampling = Some(enableSampling); self }
pub fn enableSystrace(mut self, enableSystrace: bool) -> Self { self.enableSystrace = Some(enableSystrace); self }
pub fn enableArgumentFilter(mut self, enableArgumentFilter: bool) -> Self { self.enableArgumentFilter = Some(enableArgumentFilter); self }
pub fn includedCategories(mut self, includedCategories: Vec<Cow<'a, str>>) -> Self { self.includedCategories = Some(includedCategories); self }
pub fn excludedCategories(mut self, excludedCategories: Vec<Cow<'a, str>>) -> Self { self.excludedCategories = Some(excludedCategories); self }
pub fn syntheticDelays(mut self, syntheticDelays: Vec<Cow<'a, str>>) -> Self { self.syntheticDelays = Some(syntheticDelays); self }
pub fn memoryDumpConfig(mut self, memoryDumpConfig: MemoryDumpConfig) -> Self { self.memoryDumpConfig = Some(memoryDumpConfig); self }
pub fn build(self) -> TraceConfig<'a> {
TraceConfig {
recordMode: self.recordMode,
traceBufferSizeInKb: self.traceBufferSizeInKb,
enableSampling: self.enableSampling,
enableSystrace: self.enableSystrace,
enableArgumentFilter: self.enableArgumentFilter,
includedCategories: self.includedCategories,
excludedCategories: self.excludedCategories,
syntheticDelays: self.syntheticDelays,
memoryDumpConfig: self.memoryDumpConfig,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum StreamFormat {
#[default]
#[serde(rename = "json")]
Json,
#[serde(rename = "proto")]
Proto,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum StreamCompression {
#[default]
#[serde(rename = "none")]
None,
#[serde(rename = "gzip")]
Gzip,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum MemoryDumpLevelOfDetail {
#[default]
#[serde(rename = "background")]
Background,
#[serde(rename = "light")]
Light,
#[serde(rename = "detailed")]
Detailed,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum TracingBackend {
#[default]
#[serde(rename = "auto")]
Auto,
#[serde(rename = "chrome")]
Chrome,
#[serde(rename = "system")]
System,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct EndParams {}
impl EndParams { pub const METHOD: &'static str = "Tracing.end"; }
impl<'a> crate::CdpCommand<'a> for EndParams {
const METHOD: &'static str = "Tracing.end";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetCategoriesReturns<'a> {
categories: Vec<Cow<'a, str>>,
}
impl<'a> GetCategoriesReturns<'a> {
pub fn builder(categories: Vec<Cow<'a, str>>) -> GetCategoriesReturnsBuilder<'a> {
GetCategoriesReturnsBuilder {
categories: categories,
}
}
pub fn categories(&self) -> &[Cow<'a, str>] { &self.categories }
}
pub struct GetCategoriesReturnsBuilder<'a> {
categories: Vec<Cow<'a, str>>,
}
impl<'a> GetCategoriesReturnsBuilder<'a> {
pub fn build(self) -> GetCategoriesReturns<'a> {
GetCategoriesReturns {
categories: self.categories,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct GetCategoriesParams {}
impl GetCategoriesParams { pub const METHOD: &'static str = "Tracing.getCategories"; }
impl<'a> crate::CdpCommand<'a> for GetCategoriesParams {
const METHOD: &'static str = "Tracing.getCategories";
type Response = GetCategoriesReturns<'a>;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetTrackEventDescriptorReturns<'a> {
descriptor: Cow<'a, str>,
}
impl<'a> GetTrackEventDescriptorReturns<'a> {
pub fn builder(descriptor: impl Into<Cow<'a, str>>) -> GetTrackEventDescriptorReturnsBuilder<'a> {
GetTrackEventDescriptorReturnsBuilder {
descriptor: descriptor.into(),
}
}
pub fn descriptor(&self) -> &str { self.descriptor.as_ref() }
}
pub struct GetTrackEventDescriptorReturnsBuilder<'a> {
descriptor: Cow<'a, str>,
}
impl<'a> GetTrackEventDescriptorReturnsBuilder<'a> {
pub fn build(self) -> GetTrackEventDescriptorReturns<'a> {
GetTrackEventDescriptorReturns {
descriptor: self.descriptor,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct GetTrackEventDescriptorParams {}
impl GetTrackEventDescriptorParams { pub const METHOD: &'static str = "Tracing.getTrackEventDescriptor"; }
impl<'a> crate::CdpCommand<'a> for GetTrackEventDescriptorParams {
const METHOD: &'static str = "Tracing.getTrackEventDescriptor";
type Response = GetTrackEventDescriptorReturns<'a>;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RecordClockSyncMarkerParams<'a> {
syncId: Cow<'a, str>,
}
impl<'a> RecordClockSyncMarkerParams<'a> {
pub fn builder(syncId: impl Into<Cow<'a, str>>) -> RecordClockSyncMarkerParamsBuilder<'a> {
RecordClockSyncMarkerParamsBuilder {
syncId: syncId.into(),
}
}
pub fn syncId(&self) -> &str { self.syncId.as_ref() }
}
pub struct RecordClockSyncMarkerParamsBuilder<'a> {
syncId: Cow<'a, str>,
}
impl<'a> RecordClockSyncMarkerParamsBuilder<'a> {
pub fn build(self) -> RecordClockSyncMarkerParams<'a> {
RecordClockSyncMarkerParams {
syncId: self.syncId,
}
}
}
impl<'a> RecordClockSyncMarkerParams<'a> { pub const METHOD: &'static str = "Tracing.recordClockSyncMarker"; }
impl<'a> crate::CdpCommand<'a> for RecordClockSyncMarkerParams<'a> {
const METHOD: &'static str = "Tracing.recordClockSyncMarker";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RequestMemoryDumpParams {
#[serde(skip_serializing_if = "Option::is_none")]
deterministic: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
levelOfDetail: Option<MemoryDumpLevelOfDetail>,
}
impl RequestMemoryDumpParams {
pub fn builder() -> RequestMemoryDumpParamsBuilder {
RequestMemoryDumpParamsBuilder {
deterministic: None,
levelOfDetail: None,
}
}
pub fn deterministic(&self) -> Option<bool> { self.deterministic }
pub fn levelOfDetail(&self) -> Option<&MemoryDumpLevelOfDetail> { self.levelOfDetail.as_ref() }
}
#[derive(Default)]
pub struct RequestMemoryDumpParamsBuilder {
deterministic: Option<bool>,
levelOfDetail: Option<MemoryDumpLevelOfDetail>,
}
impl RequestMemoryDumpParamsBuilder {
pub fn deterministic(mut self, deterministic: bool) -> Self { self.deterministic = Some(deterministic); self }
pub fn levelOfDetail(mut self, levelOfDetail: MemoryDumpLevelOfDetail) -> Self { self.levelOfDetail = Some(levelOfDetail); self }
pub fn build(self) -> RequestMemoryDumpParams {
RequestMemoryDumpParams {
deterministic: self.deterministic,
levelOfDetail: self.levelOfDetail,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RequestMemoryDumpReturns<'a> {
dumpGuid: Cow<'a, str>,
success: bool,
}
impl<'a> RequestMemoryDumpReturns<'a> {
pub fn builder(dumpGuid: impl Into<Cow<'a, str>>, success: bool) -> RequestMemoryDumpReturnsBuilder<'a> {
RequestMemoryDumpReturnsBuilder {
dumpGuid: dumpGuid.into(),
success: success,
}
}
pub fn dumpGuid(&self) -> &str { self.dumpGuid.as_ref() }
pub fn success(&self) -> bool { self.success }
}
pub struct RequestMemoryDumpReturnsBuilder<'a> {
dumpGuid: Cow<'a, str>,
success: bool,
}
impl<'a> RequestMemoryDumpReturnsBuilder<'a> {
pub fn build(self) -> RequestMemoryDumpReturns<'a> {
RequestMemoryDumpReturns {
dumpGuid: self.dumpGuid,
success: self.success,
}
}
}
impl RequestMemoryDumpParams { pub const METHOD: &'static str = "Tracing.requestMemoryDump"; }
impl<'a> crate::CdpCommand<'a> for RequestMemoryDumpParams {
const METHOD: &'static str = "Tracing.requestMemoryDump";
type Response = RequestMemoryDumpReturns<'a>;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct StartParams<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
categories: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
options: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
bufferUsageReportingInterval: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
transferMode: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
streamFormat: Option<StreamFormat>,
#[serde(skip_serializing_if = "Option::is_none")]
streamCompression: Option<StreamCompression>,
#[serde(skip_serializing_if = "Option::is_none")]
traceConfig: Option<TraceConfig<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
perfettoConfig: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
tracingBackend: Option<TracingBackend>,
}
impl<'a> StartParams<'a> {
pub fn builder() -> StartParamsBuilder<'a> {
StartParamsBuilder {
categories: None,
options: None,
bufferUsageReportingInterval: None,
transferMode: None,
streamFormat: None,
streamCompression: None,
traceConfig: None,
perfettoConfig: None,
tracingBackend: None,
}
}
pub fn categories(&self) -> Option<&str> { self.categories.as_deref() }
pub fn options(&self) -> Option<&str> { self.options.as_deref() }
pub fn bufferUsageReportingInterval(&self) -> Option<f64> { self.bufferUsageReportingInterval }
pub fn transferMode(&self) -> Option<&str> { self.transferMode.as_deref() }
pub fn streamFormat(&self) -> Option<&StreamFormat> { self.streamFormat.as_ref() }
pub fn streamCompression(&self) -> Option<&StreamCompression> { self.streamCompression.as_ref() }
pub fn traceConfig(&self) -> Option<&TraceConfig<'a>> { self.traceConfig.as_ref() }
pub fn perfettoConfig(&self) -> Option<&str> { self.perfettoConfig.as_deref() }
pub fn tracingBackend(&self) -> Option<&TracingBackend> { self.tracingBackend.as_ref() }
}
#[derive(Default)]
pub struct StartParamsBuilder<'a> {
categories: Option<Cow<'a, str>>,
options: Option<Cow<'a, str>>,
bufferUsageReportingInterval: Option<f64>,
transferMode: Option<Cow<'a, str>>,
streamFormat: Option<StreamFormat>,
streamCompression: Option<StreamCompression>,
traceConfig: Option<TraceConfig<'a>>,
perfettoConfig: Option<Cow<'a, str>>,
tracingBackend: Option<TracingBackend>,
}
impl<'a> StartParamsBuilder<'a> {
pub fn categories(mut self, categories: impl Into<Cow<'a, str>>) -> Self { self.categories = Some(categories.into()); self }
pub fn options(mut self, options: impl Into<Cow<'a, str>>) -> Self { self.options = Some(options.into()); self }
pub fn bufferUsageReportingInterval(mut self, bufferUsageReportingInterval: f64) -> Self { self.bufferUsageReportingInterval = Some(bufferUsageReportingInterval); self }
pub fn transferMode(mut self, transferMode: impl Into<Cow<'a, str>>) -> Self { self.transferMode = Some(transferMode.into()); self }
pub fn streamFormat(mut self, streamFormat: StreamFormat) -> Self { self.streamFormat = Some(streamFormat); self }
pub fn streamCompression(mut self, streamCompression: StreamCompression) -> Self { self.streamCompression = Some(streamCompression); self }
pub fn traceConfig(mut self, traceConfig: TraceConfig<'a>) -> Self { self.traceConfig = Some(traceConfig); self }
pub fn perfettoConfig(mut self, perfettoConfig: impl Into<Cow<'a, str>>) -> Self { self.perfettoConfig = Some(perfettoConfig.into()); self }
pub fn tracingBackend(mut self, tracingBackend: TracingBackend) -> Self { self.tracingBackend = Some(tracingBackend); self }
pub fn build(self) -> StartParams<'a> {
StartParams {
categories: self.categories,
options: self.options,
bufferUsageReportingInterval: self.bufferUsageReportingInterval,
transferMode: self.transferMode,
streamFormat: self.streamFormat,
streamCompression: self.streamCompression,
traceConfig: self.traceConfig,
perfettoConfig: self.perfettoConfig,
tracingBackend: self.tracingBackend,
}
}
}
impl<'a> StartParams<'a> { pub const METHOD: &'static str = "Tracing.start"; }
impl<'a> crate::CdpCommand<'a> for StartParams<'a> {
const METHOD: &'static str = "Tracing.start";
type Response = crate::EmptyReturns;
}