#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(transparent)]
pub struct MemoryDumpConfig(std::collections::BTreeMap<String, serde_json::Value>);
impl MemoryDumpConfig {
pub fn new(value: std::collections::BTreeMap<String, serde_json::Value>) -> Self {
Self(value)
}
pub fn into_inner(self) -> std::collections::BTreeMap<String, serde_json::Value> {
self.0
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum MemoryDumpLevelOfDetail {
Background,
Light,
Detailed,
Unknown(String),
}
impl MemoryDumpLevelOfDetail {
pub fn as_str(&self) -> &str {
match self {
Self::Background => "background",
Self::Light => "light",
Self::Detailed => "detailed",
Self::Unknown(value) => value,
}
}
}
impl AsRef<str> for MemoryDumpLevelOfDetail {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl From<String> for MemoryDumpLevelOfDetail {
fn from(value: String) -> Self {
match value.as_str() {
"background" => MemoryDumpLevelOfDetail::Background,
"light" => MemoryDumpLevelOfDetail::Light,
"detailed" => MemoryDumpLevelOfDetail::Detailed,
_ => Self::Unknown(value),
}
}
}
impl serde::Serialize for MemoryDumpLevelOfDetail {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> serde::Deserialize<'de> for MemoryDumpLevelOfDetail {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = MemoryDumpLevelOfDetail;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议字符串枚举")
}
fn visit_str<E: serde::de::Error>(self, v: &str) -> Result<Self::Value, E> {
Ok(match v {
"background" => MemoryDumpLevelOfDetail::Background,
"light" => MemoryDumpLevelOfDetail::Light,
"detailed" => MemoryDumpLevelOfDetail::Detailed,
_ => MemoryDumpLevelOfDetail::Unknown(v.to_owned()),
})
}
fn visit_string<E: serde::de::Error>(self, v: String) -> Result<Self::Value, E> {
Ok(MemoryDumpLevelOfDetail::from(v))
}
}
d.deserialize_str(Visitor)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum StreamCompression {
None,
Gzip,
Unknown(String),
}
impl StreamCompression {
pub fn as_str(&self) -> &str {
match self {
Self::None => "none",
Self::Gzip => "gzip",
Self::Unknown(value) => value,
}
}
}
impl AsRef<str> for StreamCompression {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl From<String> for StreamCompression {
fn from(value: String) -> Self {
match value.as_str() {
"none" => StreamCompression::None,
"gzip" => StreamCompression::Gzip,
_ => Self::Unknown(value),
}
}
}
impl serde::Serialize for StreamCompression {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> serde::Deserialize<'de> for StreamCompression {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = StreamCompression;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议字符串枚举")
}
fn visit_str<E: serde::de::Error>(self, v: &str) -> Result<Self::Value, E> {
Ok(match v {
"none" => StreamCompression::None,
"gzip" => StreamCompression::Gzip,
_ => StreamCompression::Unknown(v.to_owned()),
})
}
fn visit_string<E: serde::de::Error>(self, v: String) -> Result<Self::Value, E> {
Ok(StreamCompression::from(v))
}
}
d.deserialize_str(Visitor)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum StreamFormat {
Json,
Proto,
Unknown(String),
}
impl StreamFormat {
pub fn as_str(&self) -> &str {
match self {
Self::Json => "json",
Self::Proto => "proto",
Self::Unknown(value) => value,
}
}
}
impl AsRef<str> for StreamFormat {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl From<String> for StreamFormat {
fn from(value: String) -> Self {
match value.as_str() {
"json" => StreamFormat::Json,
"proto" => StreamFormat::Proto,
_ => Self::Unknown(value),
}
}
}
impl serde::Serialize for StreamFormat {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> serde::Deserialize<'de> for StreamFormat {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = StreamFormat;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议字符串枚举")
}
fn visit_str<E: serde::de::Error>(self, v: &str) -> Result<Self::Value, E> {
Ok(match v {
"json" => StreamFormat::Json,
"proto" => StreamFormat::Proto,
_ => StreamFormat::Unknown(v.to_owned()),
})
}
fn visit_string<E: serde::de::Error>(self, v: String) -> Result<Self::Value, E> {
Ok(StreamFormat::from(v))
}
}
d.deserialize_str(Visitor)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum TraceConfigRecordMode {
RecordUntilFull,
RecordContinuously,
RecordAsMuchAsPossible,
EchoToConsole,
Unknown(String),
}
impl TraceConfigRecordMode {
pub fn as_str(&self) -> &str {
match self {
Self::RecordUntilFull => "recordUntilFull",
Self::RecordContinuously => "recordContinuously",
Self::RecordAsMuchAsPossible => "recordAsMuchAsPossible",
Self::EchoToConsole => "echoToConsole",
Self::Unknown(value) => value,
}
}
}
impl AsRef<str> for TraceConfigRecordMode {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl From<String> for TraceConfigRecordMode {
fn from(value: String) -> Self {
match value.as_str() {
"recordUntilFull" => TraceConfigRecordMode::RecordUntilFull,
"recordContinuously" => TraceConfigRecordMode::RecordContinuously,
"recordAsMuchAsPossible" => TraceConfigRecordMode::RecordAsMuchAsPossible,
"echoToConsole" => TraceConfigRecordMode::EchoToConsole,
_ => Self::Unknown(value),
}
}
}
impl serde::Serialize for TraceConfigRecordMode {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> serde::Deserialize<'de> for TraceConfigRecordMode {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = TraceConfigRecordMode;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议字符串枚举")
}
fn visit_str<E: serde::de::Error>(self, v: &str) -> Result<Self::Value, E> {
Ok(match v {
"recordUntilFull" => TraceConfigRecordMode::RecordUntilFull,
"recordContinuously" => TraceConfigRecordMode::RecordContinuously,
"recordAsMuchAsPossible" => TraceConfigRecordMode::RecordAsMuchAsPossible,
"echoToConsole" => TraceConfigRecordMode::EchoToConsole,
_ => TraceConfigRecordMode::Unknown(v.to_owned()),
})
}
fn visit_string<E: serde::de::Error>(self, v: String) -> Result<Self::Value, E> {
Ok(TraceConfigRecordMode::from(v))
}
}
d.deserialize_str(Visitor)
}
}
#[derive(Debug, Clone, serde::Serialize)]
pub struct TraceConfig {
#[serde(rename = "recordMode")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub record_mode: Option<TraceConfigRecordMode>,
#[serde(rename = "traceBufferSizeInKb")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub trace_buffer_size_in_kb: Option<ydp_core::FiniteF64>,
#[serde(rename = "enableSampling")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub enable_sampling: Option<bool>,
#[serde(rename = "enableSystrace")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub enable_systrace: Option<bool>,
#[serde(rename = "enableArgumentFilter")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub enable_argument_filter: Option<bool>,
#[serde(rename = "includedCategories")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub included_categories: Option<Vec<String>>,
#[serde(rename = "excludedCategories")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub excluded_categories: Option<Vec<String>>,
#[serde(rename = "syntheticDelays")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub synthetic_delays: Option<Vec<String>>,
#[serde(rename = "memoryDumpConfig")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub memory_dump_config: Option<crate::tracing::types::MemoryDumpConfig>,
}
impl<'de> serde::Deserialize<'de> for TraceConfig {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = TraceConfig;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议 object")
}
fn visit_map<A: serde::de::MapAccess<'de>>(
self,
a: A,
) -> Result<Self::Value, A::Error> {
#[derive(serde::Deserialize)]
struct Fields {
#[serde(rename = "recordMode")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub record_mode: Option<TraceConfigRecordMode>,
#[serde(rename = "traceBufferSizeInKb")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub trace_buffer_size_in_kb: Option<ydp_core::FiniteF64>,
#[serde(rename = "enableSampling")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub enable_sampling: Option<bool>,
#[serde(rename = "enableSystrace")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub enable_systrace: Option<bool>,
#[serde(rename = "enableArgumentFilter")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub enable_argument_filter: Option<bool>,
#[serde(rename = "includedCategories")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub included_categories: Option<Vec<String>>,
#[serde(rename = "excludedCategories")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub excluded_categories: Option<Vec<String>>,
#[serde(rename = "syntheticDelays")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub synthetic_delays: Option<Vec<String>>,
#[serde(rename = "memoryDumpConfig")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub memory_dump_config: Option<crate::tracing::types::MemoryDumpConfig>,
}
let fields = <Fields as serde::Deserialize>::deserialize(
serde::de::value::MapAccessDeserializer::new(a),
)?;
Ok(TraceConfig {
record_mode: fields.record_mode,
trace_buffer_size_in_kb: fields.trace_buffer_size_in_kb,
enable_sampling: fields.enable_sampling,
enable_systrace: fields.enable_systrace,
enable_argument_filter: fields.enable_argument_filter,
included_categories: fields.included_categories,
excluded_categories: fields.excluded_categories,
synthetic_delays: fields.synthetic_delays,
memory_dump_config: fields.memory_dump_config,
})
}
}
d.deserialize_map(Visitor)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum TracingBackend {
Auto,
Chrome,
System,
Unknown(String),
}
impl TracingBackend {
pub fn as_str(&self) -> &str {
match self {
Self::Auto => "auto",
Self::Chrome => "chrome",
Self::System => "system",
Self::Unknown(value) => value,
}
}
}
impl AsRef<str> for TracingBackend {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl From<String> for TracingBackend {
fn from(value: String) -> Self {
match value.as_str() {
"auto" => TracingBackend::Auto,
"chrome" => TracingBackend::Chrome,
"system" => TracingBackend::System,
_ => Self::Unknown(value),
}
}
}
impl serde::Serialize for TracingBackend {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> serde::Deserialize<'de> for TracingBackend {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = TracingBackend;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议字符串枚举")
}
fn visit_str<E: serde::de::Error>(self, v: &str) -> Result<Self::Value, E> {
Ok(match v {
"auto" => TracingBackend::Auto,
"chrome" => TracingBackend::Chrome,
"system" => TracingBackend::System,
_ => TracingBackend::Unknown(v.to_owned()),
})
}
fn visit_string<E: serde::de::Error>(self, v: String) -> Result<Self::Value, E> {
Ok(TracingBackend::from(v))
}
}
d.deserialize_str(Visitor)
}
}