// @generated impl serde::Serialize for DubboFilter { #[allow(deprecated)] fn serialize(&self, serializer: S) -> std::result::Result where S: serde::Serializer, { use serde::ser::SerializeStruct; let mut len = 0; if !self.name.is_empty() { len += 1; } if self.config.is_some() { len += 1; } let mut struct_ser = serializer.serialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.DubboFilter", len)?; if !self.name.is_empty() { struct_ser.serialize_field("name", &self.name)?; } if let Some(v) = self.config.as_ref() { struct_ser.serialize_field("config", v)?; } struct_ser.end() } } impl<'de> serde::Deserialize<'de> for DubboFilter { #[allow(deprecated)] fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { const FIELDS: &[&str] = &[ "name", "config", ]; #[allow(clippy::enum_variant_names)] enum GeneratedField { Name, Config, } impl<'de> serde::Deserialize<'de> for GeneratedField { fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = GeneratedField; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(formatter, "expected one of: {:?}", &FIELDS) } #[allow(unused_variables)] fn visit_str(self, value: &str) -> std::result::Result where E: serde::de::Error, { match value { "name" => Ok(GeneratedField::Name), "config" => Ok(GeneratedField::Config), _ => Err(serde::de::Error::unknown_field(value, FIELDS)), } } } deserializer.deserialize_identifier(GeneratedVisitor) } } struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = DubboFilter; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { formatter.write_str("struct envoy.config.filter.network.dubbo_proxy.v2alpha1.DubboFilter") } fn visit_map(self, mut map: V) -> std::result::Result where V: serde::de::MapAccess<'de>, { let mut name__ = None; let mut config__ = None; while let Some(k) = map.next_key()? { match k { GeneratedField::Name => { if name__.is_some() { return Err(serde::de::Error::duplicate_field("name")); } name__ = Some(map.next_value()?); } GeneratedField::Config => { if config__.is_some() { return Err(serde::de::Error::duplicate_field("config")); } config__ = map.next_value()?; } } } Ok(DubboFilter { name: name__.unwrap_or_default(), config: config__, }) } } deserializer.deserialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.DubboFilter", FIELDS, GeneratedVisitor) } } impl serde::Serialize for DubboProxy { #[allow(deprecated)] fn serialize(&self, serializer: S) -> std::result::Result where S: serde::Serializer, { use serde::ser::SerializeStruct; let mut len = 0; if !self.stat_prefix.is_empty() { len += 1; } if self.protocol_type != 0 { len += 1; } if self.serialization_type != 0 { len += 1; } if !self.route_config.is_empty() { len += 1; } if !self.dubbo_filters.is_empty() { len += 1; } let mut struct_ser = serializer.serialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.DubboProxy", len)?; if !self.stat_prefix.is_empty() { struct_ser.serialize_field("statPrefix", &self.stat_prefix)?; } if self.protocol_type != 0 { let v = ProtocolType::from_i32(self.protocol_type) .ok_or_else(|| serde::ser::Error::custom(format!("Invalid variant {}", self.protocol_type)))?; struct_ser.serialize_field("protocolType", &v)?; } if self.serialization_type != 0 { let v = SerializationType::from_i32(self.serialization_type) .ok_or_else(|| serde::ser::Error::custom(format!("Invalid variant {}", self.serialization_type)))?; struct_ser.serialize_field("serializationType", &v)?; } if !self.route_config.is_empty() { struct_ser.serialize_field("routeConfig", &self.route_config)?; } if !self.dubbo_filters.is_empty() { struct_ser.serialize_field("dubboFilters", &self.dubbo_filters)?; } struct_ser.end() } } impl<'de> serde::Deserialize<'de> for DubboProxy { #[allow(deprecated)] fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { const FIELDS: &[&str] = &[ "stat_prefix", "statPrefix", "protocol_type", "protocolType", "serialization_type", "serializationType", "route_config", "routeConfig", "dubbo_filters", "dubboFilters", ]; #[allow(clippy::enum_variant_names)] enum GeneratedField { StatPrefix, ProtocolType, SerializationType, RouteConfig, DubboFilters, } impl<'de> serde::Deserialize<'de> for GeneratedField { fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = GeneratedField; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(formatter, "expected one of: {:?}", &FIELDS) } #[allow(unused_variables)] fn visit_str(self, value: &str) -> std::result::Result where E: serde::de::Error, { match value { "statPrefix" | "stat_prefix" => Ok(GeneratedField::StatPrefix), "protocolType" | "protocol_type" => Ok(GeneratedField::ProtocolType), "serializationType" | "serialization_type" => Ok(GeneratedField::SerializationType), "routeConfig" | "route_config" => Ok(GeneratedField::RouteConfig), "dubboFilters" | "dubbo_filters" => Ok(GeneratedField::DubboFilters), _ => Err(serde::de::Error::unknown_field(value, FIELDS)), } } } deserializer.deserialize_identifier(GeneratedVisitor) } } struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = DubboProxy; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { formatter.write_str("struct envoy.config.filter.network.dubbo_proxy.v2alpha1.DubboProxy") } fn visit_map(self, mut map: V) -> std::result::Result where V: serde::de::MapAccess<'de>, { let mut stat_prefix__ = None; let mut protocol_type__ = None; let mut serialization_type__ = None; let mut route_config__ = None; let mut dubbo_filters__ = None; while let Some(k) = map.next_key()? { match k { GeneratedField::StatPrefix => { if stat_prefix__.is_some() { return Err(serde::de::Error::duplicate_field("statPrefix")); } stat_prefix__ = Some(map.next_value()?); } GeneratedField::ProtocolType => { if protocol_type__.is_some() { return Err(serde::de::Error::duplicate_field("protocolType")); } protocol_type__ = Some(map.next_value::()? as i32); } GeneratedField::SerializationType => { if serialization_type__.is_some() { return Err(serde::de::Error::duplicate_field("serializationType")); } serialization_type__ = Some(map.next_value::()? as i32); } GeneratedField::RouteConfig => { if route_config__.is_some() { return Err(serde::de::Error::duplicate_field("routeConfig")); } route_config__ = Some(map.next_value()?); } GeneratedField::DubboFilters => { if dubbo_filters__.is_some() { return Err(serde::de::Error::duplicate_field("dubboFilters")); } dubbo_filters__ = Some(map.next_value()?); } } } Ok(DubboProxy { stat_prefix: stat_prefix__.unwrap_or_default(), protocol_type: protocol_type__.unwrap_or_default(), serialization_type: serialization_type__.unwrap_or_default(), route_config: route_config__.unwrap_or_default(), dubbo_filters: dubbo_filters__.unwrap_or_default(), }) } } deserializer.deserialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.DubboProxy", FIELDS, GeneratedVisitor) } } impl serde::Serialize for MethodMatch { #[allow(deprecated)] fn serialize(&self, serializer: S) -> std::result::Result where S: serde::Serializer, { use serde::ser::SerializeStruct; let mut len = 0; if self.name.is_some() { len += 1; } if !self.params_match.is_empty() { len += 1; } let mut struct_ser = serializer.serialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.MethodMatch", len)?; if let Some(v) = self.name.as_ref() { struct_ser.serialize_field("name", v)?; } if !self.params_match.is_empty() { struct_ser.serialize_field("paramsMatch", &self.params_match)?; } struct_ser.end() } } impl<'de> serde::Deserialize<'de> for MethodMatch { #[allow(deprecated)] fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { const FIELDS: &[&str] = &[ "name", "params_match", "paramsMatch", ]; #[allow(clippy::enum_variant_names)] enum GeneratedField { Name, ParamsMatch, } impl<'de> serde::Deserialize<'de> for GeneratedField { fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = GeneratedField; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(formatter, "expected one of: {:?}", &FIELDS) } #[allow(unused_variables)] fn visit_str(self, value: &str) -> std::result::Result where E: serde::de::Error, { match value { "name" => Ok(GeneratedField::Name), "paramsMatch" | "params_match" => Ok(GeneratedField::ParamsMatch), _ => Err(serde::de::Error::unknown_field(value, FIELDS)), } } } deserializer.deserialize_identifier(GeneratedVisitor) } } struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = MethodMatch; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { formatter.write_str("struct envoy.config.filter.network.dubbo_proxy.v2alpha1.MethodMatch") } fn visit_map(self, mut map: V) -> std::result::Result where V: serde::de::MapAccess<'de>, { let mut name__ = None; let mut params_match__ = None; while let Some(k) = map.next_key()? { match k { GeneratedField::Name => { if name__.is_some() { return Err(serde::de::Error::duplicate_field("name")); } name__ = map.next_value()?; } GeneratedField::ParamsMatch => { if params_match__.is_some() { return Err(serde::de::Error::duplicate_field("paramsMatch")); } params_match__ = Some( map.next_value::, _>>()? .into_iter().map(|(k,v)| (k.0, v)).collect() ); } } } Ok(MethodMatch { name: name__, params_match: params_match__.unwrap_or_default(), }) } } deserializer.deserialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.MethodMatch", FIELDS, GeneratedVisitor) } } impl serde::Serialize for method_match::ParameterMatchSpecifier { #[allow(deprecated)] fn serialize(&self, serializer: S) -> std::result::Result where S: serde::Serializer, { use serde::ser::SerializeStruct; let mut len = 0; if self.parameter_match_specifier.is_some() { len += 1; } let mut struct_ser = serializer.serialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.MethodMatch.ParameterMatchSpecifier", len)?; if let Some(v) = self.parameter_match_specifier.as_ref() { match v { method_match::parameter_match_specifier::ParameterMatchSpecifier::ExactMatch(v) => { struct_ser.serialize_field("exactMatch", v)?; } method_match::parameter_match_specifier::ParameterMatchSpecifier::RangeMatch(v) => { struct_ser.serialize_field("rangeMatch", v)?; } } } struct_ser.end() } } impl<'de> serde::Deserialize<'de> for method_match::ParameterMatchSpecifier { #[allow(deprecated)] fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { const FIELDS: &[&str] = &[ "exact_match", "exactMatch", "range_match", "rangeMatch", ]; #[allow(clippy::enum_variant_names)] enum GeneratedField { ExactMatch, RangeMatch, } impl<'de> serde::Deserialize<'de> for GeneratedField { fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = GeneratedField; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(formatter, "expected one of: {:?}", &FIELDS) } #[allow(unused_variables)] fn visit_str(self, value: &str) -> std::result::Result where E: serde::de::Error, { match value { "exactMatch" | "exact_match" => Ok(GeneratedField::ExactMatch), "rangeMatch" | "range_match" => Ok(GeneratedField::RangeMatch), _ => Err(serde::de::Error::unknown_field(value, FIELDS)), } } } deserializer.deserialize_identifier(GeneratedVisitor) } } struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = method_match::ParameterMatchSpecifier; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { formatter.write_str("struct envoy.config.filter.network.dubbo_proxy.v2alpha1.MethodMatch.ParameterMatchSpecifier") } fn visit_map(self, mut map: V) -> std::result::Result where V: serde::de::MapAccess<'de>, { let mut parameter_match_specifier__ = None; while let Some(k) = map.next_key()? { match k { GeneratedField::ExactMatch => { if parameter_match_specifier__.is_some() { return Err(serde::de::Error::duplicate_field("exactMatch")); } parameter_match_specifier__ = map.next_value::<::std::option::Option<_>>()?.map(method_match::parameter_match_specifier::ParameterMatchSpecifier::ExactMatch); } GeneratedField::RangeMatch => { if parameter_match_specifier__.is_some() { return Err(serde::de::Error::duplicate_field("rangeMatch")); } parameter_match_specifier__ = map.next_value::<::std::option::Option<_>>()?.map(method_match::parameter_match_specifier::ParameterMatchSpecifier::RangeMatch) ; } } } Ok(method_match::ParameterMatchSpecifier { parameter_match_specifier: parameter_match_specifier__, }) } } deserializer.deserialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.MethodMatch.ParameterMatchSpecifier", FIELDS, GeneratedVisitor) } } impl serde::Serialize for ProtocolType { #[allow(deprecated)] fn serialize(&self, serializer: S) -> std::result::Result where S: serde::Serializer, { let variant = match self { Self::Dubbo => "Dubbo", }; serializer.serialize_str(variant) } } impl<'de> serde::Deserialize<'de> for ProtocolType { #[allow(deprecated)] fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { const FIELDS: &[&str] = &[ "Dubbo", ]; struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = ProtocolType; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(formatter, "expected one of: {:?}", &FIELDS) } fn visit_i64(self, v: i64) -> std::result::Result where E: serde::de::Error, { use std::convert::TryFrom; i32::try_from(v) .ok() .and_then(ProtocolType::from_i32) .ok_or_else(|| { serde::de::Error::invalid_value(serde::de::Unexpected::Signed(v), &self) }) } fn visit_u64(self, v: u64) -> std::result::Result where E: serde::de::Error, { use std::convert::TryFrom; i32::try_from(v) .ok() .and_then(ProtocolType::from_i32) .ok_or_else(|| { serde::de::Error::invalid_value(serde::de::Unexpected::Unsigned(v), &self) }) } fn visit_str(self, value: &str) -> std::result::Result where E: serde::de::Error, { match value { "Dubbo" => Ok(ProtocolType::Dubbo), _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), } } } deserializer.deserialize_any(GeneratedVisitor) } } impl serde::Serialize for Route { #[allow(deprecated)] fn serialize(&self, serializer: S) -> std::result::Result where S: serde::Serializer, { use serde::ser::SerializeStruct; let mut len = 0; if self.r#match.is_some() { len += 1; } if self.route.is_some() { len += 1; } let mut struct_ser = serializer.serialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.Route", len)?; if let Some(v) = self.r#match.as_ref() { struct_ser.serialize_field("match", v)?; } if let Some(v) = self.route.as_ref() { struct_ser.serialize_field("route", v)?; } struct_ser.end() } } impl<'de> serde::Deserialize<'de> for Route { #[allow(deprecated)] fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { const FIELDS: &[&str] = &[ "match", "route", ]; #[allow(clippy::enum_variant_names)] enum GeneratedField { Match, Route, } impl<'de> serde::Deserialize<'de> for GeneratedField { fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = GeneratedField; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(formatter, "expected one of: {:?}", &FIELDS) } #[allow(unused_variables)] fn visit_str(self, value: &str) -> std::result::Result where E: serde::de::Error, { match value { "match" => Ok(GeneratedField::Match), "route" => Ok(GeneratedField::Route), _ => Err(serde::de::Error::unknown_field(value, FIELDS)), } } } deserializer.deserialize_identifier(GeneratedVisitor) } } struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = Route; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { formatter.write_str("struct envoy.config.filter.network.dubbo_proxy.v2alpha1.Route") } fn visit_map(self, mut map: V) -> std::result::Result where V: serde::de::MapAccess<'de>, { let mut r#match__ = None; let mut route__ = None; while let Some(k) = map.next_key()? { match k { GeneratedField::Match => { if r#match__.is_some() { return Err(serde::de::Error::duplicate_field("match")); } r#match__ = map.next_value()?; } GeneratedField::Route => { if route__.is_some() { return Err(serde::de::Error::duplicate_field("route")); } route__ = map.next_value()?; } } } Ok(Route { r#match: r#match__, route: route__, }) } } deserializer.deserialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.Route", FIELDS, GeneratedVisitor) } } impl serde::Serialize for RouteAction { #[allow(deprecated)] fn serialize(&self, serializer: S) -> std::result::Result where S: serde::Serializer, { use serde::ser::SerializeStruct; let mut len = 0; if self.cluster_specifier.is_some() { len += 1; } let mut struct_ser = serializer.serialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.RouteAction", len)?; if let Some(v) = self.cluster_specifier.as_ref() { match v { route_action::ClusterSpecifier::Cluster(v) => { struct_ser.serialize_field("cluster", v)?; } route_action::ClusterSpecifier::WeightedClusters(v) => { struct_ser.serialize_field("weightedClusters", v)?; } } } struct_ser.end() } } impl<'de> serde::Deserialize<'de> for RouteAction { #[allow(deprecated)] fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { const FIELDS: &[&str] = &[ "cluster", "weighted_clusters", "weightedClusters", ]; #[allow(clippy::enum_variant_names)] enum GeneratedField { Cluster, WeightedClusters, } impl<'de> serde::Deserialize<'de> for GeneratedField { fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = GeneratedField; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(formatter, "expected one of: {:?}", &FIELDS) } #[allow(unused_variables)] fn visit_str(self, value: &str) -> std::result::Result where E: serde::de::Error, { match value { "cluster" => Ok(GeneratedField::Cluster), "weightedClusters" | "weighted_clusters" => Ok(GeneratedField::WeightedClusters), _ => Err(serde::de::Error::unknown_field(value, FIELDS)), } } } deserializer.deserialize_identifier(GeneratedVisitor) } } struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = RouteAction; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { formatter.write_str("struct envoy.config.filter.network.dubbo_proxy.v2alpha1.RouteAction") } fn visit_map(self, mut map: V) -> std::result::Result where V: serde::de::MapAccess<'de>, { let mut cluster_specifier__ = None; while let Some(k) = map.next_key()? { match k { GeneratedField::Cluster => { if cluster_specifier__.is_some() { return Err(serde::de::Error::duplicate_field("cluster")); } cluster_specifier__ = map.next_value::<::std::option::Option<_>>()?.map(route_action::ClusterSpecifier::Cluster); } GeneratedField::WeightedClusters => { if cluster_specifier__.is_some() { return Err(serde::de::Error::duplicate_field("weightedClusters")); } cluster_specifier__ = map.next_value::<::std::option::Option<_>>()?.map(route_action::ClusterSpecifier::WeightedClusters) ; } } } Ok(RouteAction { cluster_specifier: cluster_specifier__, }) } } deserializer.deserialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.RouteAction", FIELDS, GeneratedVisitor) } } impl serde::Serialize for RouteConfiguration { #[allow(deprecated)] fn serialize(&self, serializer: S) -> std::result::Result where S: serde::Serializer, { use serde::ser::SerializeStruct; let mut len = 0; if !self.name.is_empty() { len += 1; } if !self.interface.is_empty() { len += 1; } if !self.group.is_empty() { len += 1; } if !self.version.is_empty() { len += 1; } if !self.routes.is_empty() { len += 1; } let mut struct_ser = serializer.serialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.RouteConfiguration", len)?; if !self.name.is_empty() { struct_ser.serialize_field("name", &self.name)?; } if !self.interface.is_empty() { struct_ser.serialize_field("interface", &self.interface)?; } if !self.group.is_empty() { struct_ser.serialize_field("group", &self.group)?; } if !self.version.is_empty() { struct_ser.serialize_field("version", &self.version)?; } if !self.routes.is_empty() { struct_ser.serialize_field("routes", &self.routes)?; } struct_ser.end() } } impl<'de> serde::Deserialize<'de> for RouteConfiguration { #[allow(deprecated)] fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { const FIELDS: &[&str] = &[ "name", "interface", "group", "version", "routes", ]; #[allow(clippy::enum_variant_names)] enum GeneratedField { Name, Interface, Group, Version, Routes, } impl<'de> serde::Deserialize<'de> for GeneratedField { fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = GeneratedField; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(formatter, "expected one of: {:?}", &FIELDS) } #[allow(unused_variables)] fn visit_str(self, value: &str) -> std::result::Result where E: serde::de::Error, { match value { "name" => Ok(GeneratedField::Name), "interface" => Ok(GeneratedField::Interface), "group" => Ok(GeneratedField::Group), "version" => Ok(GeneratedField::Version), "routes" => Ok(GeneratedField::Routes), _ => Err(serde::de::Error::unknown_field(value, FIELDS)), } } } deserializer.deserialize_identifier(GeneratedVisitor) } } struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = RouteConfiguration; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { formatter.write_str("struct envoy.config.filter.network.dubbo_proxy.v2alpha1.RouteConfiguration") } fn visit_map(self, mut map: V) -> std::result::Result where V: serde::de::MapAccess<'de>, { let mut name__ = None; let mut interface__ = None; let mut group__ = None; let mut version__ = None; let mut routes__ = None; while let Some(k) = map.next_key()? { match k { GeneratedField::Name => { if name__.is_some() { return Err(serde::de::Error::duplicate_field("name")); } name__ = Some(map.next_value()?); } GeneratedField::Interface => { if interface__.is_some() { return Err(serde::de::Error::duplicate_field("interface")); } interface__ = Some(map.next_value()?); } GeneratedField::Group => { if group__.is_some() { return Err(serde::de::Error::duplicate_field("group")); } group__ = Some(map.next_value()?); } GeneratedField::Version => { if version__.is_some() { return Err(serde::de::Error::duplicate_field("version")); } version__ = Some(map.next_value()?); } GeneratedField::Routes => { if routes__.is_some() { return Err(serde::de::Error::duplicate_field("routes")); } routes__ = Some(map.next_value()?); } } } Ok(RouteConfiguration { name: name__.unwrap_or_default(), interface: interface__.unwrap_or_default(), group: group__.unwrap_or_default(), version: version__.unwrap_or_default(), routes: routes__.unwrap_or_default(), }) } } deserializer.deserialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.RouteConfiguration", FIELDS, GeneratedVisitor) } } impl serde::Serialize for RouteMatch { #[allow(deprecated)] fn serialize(&self, serializer: S) -> std::result::Result where S: serde::Serializer, { use serde::ser::SerializeStruct; let mut len = 0; if self.method.is_some() { len += 1; } if !self.headers.is_empty() { len += 1; } let mut struct_ser = serializer.serialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.RouteMatch", len)?; if let Some(v) = self.method.as_ref() { struct_ser.serialize_field("method", v)?; } if !self.headers.is_empty() { struct_ser.serialize_field("headers", &self.headers)?; } struct_ser.end() } } impl<'de> serde::Deserialize<'de> for RouteMatch { #[allow(deprecated)] fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { const FIELDS: &[&str] = &[ "method", "headers", ]; #[allow(clippy::enum_variant_names)] enum GeneratedField { Method, Headers, } impl<'de> serde::Deserialize<'de> for GeneratedField { fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = GeneratedField; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(formatter, "expected one of: {:?}", &FIELDS) } #[allow(unused_variables)] fn visit_str(self, value: &str) -> std::result::Result where E: serde::de::Error, { match value { "method" => Ok(GeneratedField::Method), "headers" => Ok(GeneratedField::Headers), _ => Err(serde::de::Error::unknown_field(value, FIELDS)), } } } deserializer.deserialize_identifier(GeneratedVisitor) } } struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = RouteMatch; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { formatter.write_str("struct envoy.config.filter.network.dubbo_proxy.v2alpha1.RouteMatch") } fn visit_map(self, mut map: V) -> std::result::Result where V: serde::de::MapAccess<'de>, { let mut method__ = None; let mut headers__ = None; while let Some(k) = map.next_key()? { match k { GeneratedField::Method => { if method__.is_some() { return Err(serde::de::Error::duplicate_field("method")); } method__ = map.next_value()?; } GeneratedField::Headers => { if headers__.is_some() { return Err(serde::de::Error::duplicate_field("headers")); } headers__ = Some(map.next_value()?); } } } Ok(RouteMatch { method: method__, headers: headers__.unwrap_or_default(), }) } } deserializer.deserialize_struct("envoy.config.filter.network.dubbo_proxy.v2alpha1.RouteMatch", FIELDS, GeneratedVisitor) } } impl serde::Serialize for SerializationType { #[allow(deprecated)] fn serialize(&self, serializer: S) -> std::result::Result where S: serde::Serializer, { let variant = match self { Self::Hessian2 => "Hessian2", }; serializer.serialize_str(variant) } } impl<'de> serde::Deserialize<'de> for SerializationType { #[allow(deprecated)] fn deserialize(deserializer: D) -> std::result::Result where D: serde::Deserializer<'de>, { const FIELDS: &[&str] = &[ "Hessian2", ]; struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { type Value = SerializationType; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(formatter, "expected one of: {:?}", &FIELDS) } fn visit_i64(self, v: i64) -> std::result::Result where E: serde::de::Error, { use std::convert::TryFrom; i32::try_from(v) .ok() .and_then(SerializationType::from_i32) .ok_or_else(|| { serde::de::Error::invalid_value(serde::de::Unexpected::Signed(v), &self) }) } fn visit_u64(self, v: u64) -> std::result::Result where E: serde::de::Error, { use std::convert::TryFrom; i32::try_from(v) .ok() .and_then(SerializationType::from_i32) .ok_or_else(|| { serde::de::Error::invalid_value(serde::de::Unexpected::Unsigned(v), &self) }) } fn visit_str(self, value: &str) -> std::result::Result where E: serde::de::Error, { match value { "Hessian2" => Ok(SerializationType::Hessian2), _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), } } } deserializer.deserialize_any(GeneratedVisitor) } }