From 5b5cf8492689fc89540a633998bae8ace62ff078 Mon Sep 17 00:00:00 2001 From: Campbell He Date: Sat, 10 Aug 2024 15:31:34 +0000 Subject: [PATCH] Remove support of serde This commit remove the use of protoc-prost-serde, and the support of serde is deleted. Since serde and json is not necessary, this commit is considered reasonable. --- codegen/compile_protos.sh | 1 - rust/src/google.rpc.rs | 1 - rust/src/google.rpc.serde.rs | 244 - rust/src/p4.config.v1.rs | 1 - rust/src/p4.config.v1.serde.rs | 8608 ----------------------------- rust/src/p4.v1.rs | 1 - rust/src/p4.v1.serde.rs | 9346 -------------------------------- 7 files changed, 18202 deletions(-) delete mode 100644 rust/src/google.rpc.serde.rs delete mode 100644 rust/src/p4.config.v1.serde.rs delete mode 100644 rust/src/p4.v1.serde.rs diff --git a/codegen/compile_protos.sh b/codegen/compile_protos.sh index 82ff7c72..486e21f9 100755 --- a/codegen/compile_protos.sh +++ b/codegen/compile_protos.sh @@ -70,7 +70,6 @@ $PROTOC $PROTOS $PROTOFLAGS \ --prost_out="$BUILD_DIR/rust_out/src" \ --prost_opt=compile_well_known_types \ --prost_opt=extern_path=.google.protobuf=::pbjson_types \ - --prost-serde_out="$BUILD_DIR/rust_out/src" \ --tonic_out="$BUILD_DIR/rust_out/src" \ --tonic_opt=compile_well_known_types \ --tonic_opt=extern_path=.google.protobuf=::pbjson_types \ diff --git a/rust/src/google.rpc.rs b/rust/src/google.rpc.rs index df3c2389..cfb26b3f 100644 --- a/rust/src/google.rpc.rs +++ b/rust/src/google.rpc.rs @@ -223,5 +223,4 @@ impl Code { } } } -include!("google.rpc.serde.rs"); // @@protoc_insertion_point(module) diff --git a/rust/src/google.rpc.serde.rs b/rust/src/google.rpc.serde.rs deleted file mode 100644 index d6527e63..00000000 --- a/rust/src/google.rpc.serde.rs +++ /dev/null @@ -1,244 +0,0 @@ -// @generated -impl serde::Serialize for Code { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - let variant = match self { - Self::Ok => "OK", - Self::Cancelled => "CANCELLED", - Self::Unknown => "UNKNOWN", - Self::InvalidArgument => "INVALID_ARGUMENT", - Self::DeadlineExceeded => "DEADLINE_EXCEEDED", - Self::NotFound => "NOT_FOUND", - Self::AlreadyExists => "ALREADY_EXISTS", - Self::PermissionDenied => "PERMISSION_DENIED", - Self::Unauthenticated => "UNAUTHENTICATED", - Self::ResourceExhausted => "RESOURCE_EXHAUSTED", - Self::FailedPrecondition => "FAILED_PRECONDITION", - Self::Aborted => "ABORTED", - Self::OutOfRange => "OUT_OF_RANGE", - Self::Unimplemented => "UNIMPLEMENTED", - Self::Internal => "INTERNAL", - Self::Unavailable => "UNAVAILABLE", - Self::DataLoss => "DATA_LOSS", - }; - serializer.serialize_str(variant) - } -} -impl<'de> serde::Deserialize<'de> for Code { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "OK", - "CANCELLED", - "UNKNOWN", - "INVALID_ARGUMENT", - "DEADLINE_EXCEEDED", - "NOT_FOUND", - "ALREADY_EXISTS", - "PERMISSION_DENIED", - "UNAUTHENTICATED", - "RESOURCE_EXHAUSTED", - "FAILED_PRECONDITION", - "ABORTED", - "OUT_OF_RANGE", - "UNIMPLEMENTED", - "INTERNAL", - "UNAVAILABLE", - "DATA_LOSS", - ]; - - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Code; - - 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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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 { - "OK" => Ok(Code::Ok), - "CANCELLED" => Ok(Code::Cancelled), - "UNKNOWN" => Ok(Code::Unknown), - "INVALID_ARGUMENT" => Ok(Code::InvalidArgument), - "DEADLINE_EXCEEDED" => Ok(Code::DeadlineExceeded), - "NOT_FOUND" => Ok(Code::NotFound), - "ALREADY_EXISTS" => Ok(Code::AlreadyExists), - "PERMISSION_DENIED" => Ok(Code::PermissionDenied), - "UNAUTHENTICATED" => Ok(Code::Unauthenticated), - "RESOURCE_EXHAUSTED" => Ok(Code::ResourceExhausted), - "FAILED_PRECONDITION" => Ok(Code::FailedPrecondition), - "ABORTED" => Ok(Code::Aborted), - "OUT_OF_RANGE" => Ok(Code::OutOfRange), - "UNIMPLEMENTED" => Ok(Code::Unimplemented), - "INTERNAL" => Ok(Code::Internal), - "UNAVAILABLE" => Ok(Code::Unavailable), - "DATA_LOSS" => Ok(Code::DataLoss), - _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), - } - } - } - deserializer.deserialize_any(GeneratedVisitor) - } -} -impl serde::Serialize for Status { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.code != 0 { - len += 1; - } - if !self.message.is_empty() { - len += 1; - } - if !self.details.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("google.rpc.Status", len)?; - if self.code != 0 { - struct_ser.serialize_field("code", &self.code)?; - } - if !self.message.is_empty() { - struct_ser.serialize_field("message", &self.message)?; - } - if !self.details.is_empty() { - struct_ser.serialize_field("details", &self.details)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Status { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "code", - "message", - "details", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Code, - Message, - Details, - } - 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 { - "code" => Ok(GeneratedField::Code), - "message" => Ok(GeneratedField::Message), - "details" => Ok(GeneratedField::Details), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Status; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct google.rpc.Status") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut code__ = None; - let mut message__ = None; - let mut details__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Code => { - if code__.is_some() { - return Err(serde::de::Error::duplicate_field("code")); - } - code__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Message => { - if message__.is_some() { - return Err(serde::de::Error::duplicate_field("message")); - } - message__ = Some(map_.next_value()?); - } - GeneratedField::Details => { - if details__.is_some() { - return Err(serde::de::Error::duplicate_field("details")); - } - details__ = Some(map_.next_value()?); - } - } - } - Ok(Status { - code: code__.unwrap_or_default(), - message: message__.unwrap_or_default(), - details: details__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("google.rpc.Status", FIELDS, GeneratedVisitor) - } -} diff --git a/rust/src/p4.config.v1.rs b/rust/src/p4.config.v1.rs index f8eb504f..b8c2c3db 100644 --- a/rust/src/p4.config.v1.rs +++ b/rust/src/p4.config.v1.rs @@ -1228,5 +1228,4 @@ pub struct Digest { #[prost(message, optional, tag="2")] pub type_spec: ::core::option::Option, } -include!("p4.config.v1.serde.rs"); // @@protoc_insertion_point(module) diff --git a/rust/src/p4.config.v1.serde.rs b/rust/src/p4.config.v1.serde.rs deleted file mode 100644 index 29d1e69c..00000000 --- a/rust/src/p4.config.v1.serde.rs +++ /dev/null @@ -1,8608 +0,0 @@ -// @generated -impl serde::Serialize for Action { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.preamble.is_some() { - len += 1; - } - if !self.params.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.Action", len)?; - if let Some(v) = self.preamble.as_ref() { - struct_ser.serialize_field("preamble", v)?; - } - if !self.params.is_empty() { - struct_ser.serialize_field("params", &self.params)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Action { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "preamble", - "params", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Preamble, - Params, - } - 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 { - "preamble" => Ok(GeneratedField::Preamble), - "params" => Ok(GeneratedField::Params), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Action; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.Action") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut preamble__ = None; - let mut params__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Preamble => { - if preamble__.is_some() { - return Err(serde::de::Error::duplicate_field("preamble")); - } - preamble__ = map_.next_value()?; - } - GeneratedField::Params => { - if params__.is_some() { - return Err(serde::de::Error::duplicate_field("params")); - } - params__ = Some(map_.next_value()?); - } - } - } - Ok(Action { - preamble: preamble__, - params: params__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.Action", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for action::Param { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.id != 0 { - len += 1; - } - if !self.name.is_empty() { - len += 1; - } - if !self.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if self.bitwidth != 0 { - len += 1; - } - if self.doc.is_some() { - len += 1; - } - if self.type_name.is_some() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.Action.Param", len)?; - if self.id != 0 { - struct_ser.serialize_field("id", &self.id)?; - } - if !self.name.is_empty() { - struct_ser.serialize_field("name", &self.name)?; - } - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if self.bitwidth != 0 { - struct_ser.serialize_field("bitwidth", &self.bitwidth)?; - } - if let Some(v) = self.doc.as_ref() { - struct_ser.serialize_field("doc", v)?; - } - if let Some(v) = self.type_name.as_ref() { - struct_ser.serialize_field("typeName", v)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for action::Param { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "id", - "name", - "annotations", - "annotation_locations", - "annotationLocations", - "bitwidth", - "doc", - "type_name", - "typeName", - "structured_annotations", - "structuredAnnotations", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Id, - Name, - Annotations, - AnnotationLocations, - Bitwidth, - Doc, - TypeName, - StructuredAnnotations, - } - 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 { - "id" => Ok(GeneratedField::Id), - "name" => Ok(GeneratedField::Name), - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "bitwidth" => Ok(GeneratedField::Bitwidth), - "doc" => Ok(GeneratedField::Doc), - "typeName" | "type_name" => Ok(GeneratedField::TypeName), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = action::Param; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.Action.Param") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut id__ = None; - let mut name__ = None; - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut bitwidth__ = None; - let mut doc__ = None; - let mut type_name__ = None; - let mut structured_annotations__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Id => { - if id__.is_some() { - return Err(serde::de::Error::duplicate_field("id")); - } - id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Name => { - if name__.is_some() { - return Err(serde::de::Error::duplicate_field("name")); - } - name__ = Some(map_.next_value()?); - } - GeneratedField::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::Bitwidth => { - if bitwidth__.is_some() { - return Err(serde::de::Error::duplicate_field("bitwidth")); - } - bitwidth__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Doc => { - if doc__.is_some() { - return Err(serde::de::Error::duplicate_field("doc")); - } - doc__ = map_.next_value()?; - } - GeneratedField::TypeName => { - if type_name__.is_some() { - return Err(serde::de::Error::duplicate_field("typeName")); - } - type_name__ = map_.next_value()?; - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - } - } - Ok(action::Param { - id: id__.unwrap_or_default(), - name: name__.unwrap_or_default(), - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - bitwidth: bitwidth__.unwrap_or_default(), - doc: doc__, - type_name: type_name__, - structured_annotations: structured_annotations__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.Action.Param", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ActionProfile { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.preamble.is_some() { - len += 1; - } - if !self.table_ids.is_empty() { - len += 1; - } - if self.with_selector { - len += 1; - } - if self.size != 0 { - len += 1; - } - if self.max_group_size != 0 { - len += 1; - } - if self.selector_size_semantics.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.ActionProfile", len)?; - if let Some(v) = self.preamble.as_ref() { - struct_ser.serialize_field("preamble", v)?; - } - if !self.table_ids.is_empty() { - struct_ser.serialize_field("tableIds", &self.table_ids)?; - } - if self.with_selector { - struct_ser.serialize_field("withSelector", &self.with_selector)?; - } - if self.size != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("size", ToString::to_string(&self.size).as_str())?; - } - if self.max_group_size != 0 { - struct_ser.serialize_field("maxGroupSize", &self.max_group_size)?; - } - if let Some(v) = self.selector_size_semantics.as_ref() { - match v { - action_profile::SelectorSizeSemantics::SumOfWeights(v) => { - struct_ser.serialize_field("sumOfWeights", v)?; - } - action_profile::SelectorSizeSemantics::SumOfMembers(v) => { - struct_ser.serialize_field("sumOfMembers", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ActionProfile { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "preamble", - "table_ids", - "tableIds", - "with_selector", - "withSelector", - "size", - "max_group_size", - "maxGroupSize", - "sum_of_weights", - "sumOfWeights", - "sum_of_members", - "sumOfMembers", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Preamble, - TableIds, - WithSelector, - Size, - MaxGroupSize, - SumOfWeights, - SumOfMembers, - } - 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 { - "preamble" => Ok(GeneratedField::Preamble), - "tableIds" | "table_ids" => Ok(GeneratedField::TableIds), - "withSelector" | "with_selector" => Ok(GeneratedField::WithSelector), - "size" => Ok(GeneratedField::Size), - "maxGroupSize" | "max_group_size" => Ok(GeneratedField::MaxGroupSize), - "sumOfWeights" | "sum_of_weights" => Ok(GeneratedField::SumOfWeights), - "sumOfMembers" | "sum_of_members" => Ok(GeneratedField::SumOfMembers), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ActionProfile; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.ActionProfile") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut preamble__ = None; - let mut table_ids__ = None; - let mut with_selector__ = None; - let mut size__ = None; - let mut max_group_size__ = None; - let mut selector_size_semantics__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Preamble => { - if preamble__.is_some() { - return Err(serde::de::Error::duplicate_field("preamble")); - } - preamble__ = map_.next_value()?; - } - GeneratedField::TableIds => { - if table_ids__.is_some() { - return Err(serde::de::Error::duplicate_field("tableIds")); - } - table_ids__ = - Some(map_.next_value::>>()? - .into_iter().map(|x| x.0).collect()) - ; - } - GeneratedField::WithSelector => { - if with_selector__.is_some() { - return Err(serde::de::Error::duplicate_field("withSelector")); - } - with_selector__ = Some(map_.next_value()?); - } - GeneratedField::Size => { - if size__.is_some() { - return Err(serde::de::Error::duplicate_field("size")); - } - size__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::MaxGroupSize => { - if max_group_size__.is_some() { - return Err(serde::de::Error::duplicate_field("maxGroupSize")); - } - max_group_size__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::SumOfWeights => { - if selector_size_semantics__.is_some() { - return Err(serde::de::Error::duplicate_field("sumOfWeights")); - } - selector_size_semantics__ = map_.next_value::<::std::option::Option<_>>()?.map(action_profile::SelectorSizeSemantics::SumOfWeights) -; - } - GeneratedField::SumOfMembers => { - if selector_size_semantics__.is_some() { - return Err(serde::de::Error::duplicate_field("sumOfMembers")); - } - selector_size_semantics__ = map_.next_value::<::std::option::Option<_>>()?.map(action_profile::SelectorSizeSemantics::SumOfMembers) -; - } - } - } - Ok(ActionProfile { - preamble: preamble__, - table_ids: table_ids__.unwrap_or_default(), - with_selector: with_selector__.unwrap_or_default(), - size: size__.unwrap_or_default(), - max_group_size: max_group_size__.unwrap_or_default(), - selector_size_semantics: selector_size_semantics__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.ActionProfile", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for action_profile::SumOfMembers { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.max_member_weight.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.ActionProfile.SumOfMembers", len)?; - if let Some(v) = self.max_member_weight.as_ref() { - struct_ser.serialize_field("maxMemberWeight", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for action_profile::SumOfMembers { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "max_member_weight", - "maxMemberWeight", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - MaxMemberWeight, - } - 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 { - "maxMemberWeight" | "max_member_weight" => Ok(GeneratedField::MaxMemberWeight), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = action_profile::SumOfMembers; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.ActionProfile.SumOfMembers") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut max_member_weight__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::MaxMemberWeight => { - if max_member_weight__.is_some() { - return Err(serde::de::Error::duplicate_field("maxMemberWeight")); - } - max_member_weight__ = - map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| x.0) - ; - } - } - } - Ok(action_profile::SumOfMembers { - max_member_weight: max_member_weight__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.ActionProfile.SumOfMembers", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for action_profile::SumOfWeights { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let len = 0; - let struct_ser = serializer.serialize_struct("p4.config.v1.ActionProfile.SumOfWeights", len)?; - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for action_profile::SumOfWeights { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - } - 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, - { - Err(serde::de::Error::unknown_field(value, FIELDS)) - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = action_profile::SumOfWeights; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.ActionProfile.SumOfWeights") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - while map_.next_key::()?.is_some() { - let _ = map_.next_value::()?; - } - Ok(action_profile::SumOfWeights { - }) - } - } - deserializer.deserialize_struct("p4.config.v1.ActionProfile.SumOfWeights", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ActionRef { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.id != 0 { - len += 1; - } - if self.scope != 0 { - len += 1; - } - if !self.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.ActionRef", len)?; - if self.id != 0 { - struct_ser.serialize_field("id", &self.id)?; - } - if self.scope != 0 { - let v = action_ref::Scope::try_from(self.scope) - .map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.scope)))?; - struct_ser.serialize_field("scope", &v)?; - } - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ActionRef { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "id", - "scope", - "annotations", - "annotation_locations", - "annotationLocations", - "structured_annotations", - "structuredAnnotations", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Id, - Scope, - Annotations, - AnnotationLocations, - StructuredAnnotations, - } - 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 { - "id" => Ok(GeneratedField::Id), - "scope" => Ok(GeneratedField::Scope), - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ActionRef; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.ActionRef") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut id__ = None; - let mut scope__ = None; - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut structured_annotations__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Id => { - if id__.is_some() { - return Err(serde::de::Error::duplicate_field("id")); - } - id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Scope => { - if scope__.is_some() { - return Err(serde::de::Error::duplicate_field("scope")); - } - scope__ = Some(map_.next_value::()? as i32); - } - GeneratedField::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - } - } - Ok(ActionRef { - id: id__.unwrap_or_default(), - scope: scope__.unwrap_or_default(), - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - structured_annotations: structured_annotations__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.ActionRef", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for action_ref::Scope { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - let variant = match self { - Self::TableAndDefault => "TABLE_AND_DEFAULT", - Self::TableOnly => "TABLE_ONLY", - Self::DefaultOnly => "DEFAULT_ONLY", - }; - serializer.serialize_str(variant) - } -} -impl<'de> serde::Deserialize<'de> for action_ref::Scope { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "TABLE_AND_DEFAULT", - "TABLE_ONLY", - "DEFAULT_ONLY", - ]; - - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = action_ref::Scope; - - 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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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 { - "TABLE_AND_DEFAULT" => Ok(action_ref::Scope::TableAndDefault), - "TABLE_ONLY" => Ok(action_ref::Scope::TableOnly), - "DEFAULT_ONLY" => Ok(action_ref::Scope::DefaultOnly), - _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), - } - } - } - deserializer.deserialize_any(GeneratedVisitor) - } -} -impl serde::Serialize for ControllerPacketMetadata { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.preamble.is_some() { - len += 1; - } - if !self.metadata.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.ControllerPacketMetadata", len)?; - if let Some(v) = self.preamble.as_ref() { - struct_ser.serialize_field("preamble", v)?; - } - if !self.metadata.is_empty() { - struct_ser.serialize_field("metadata", &self.metadata)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ControllerPacketMetadata { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "preamble", - "metadata", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Preamble, - Metadata, - } - 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 { - "preamble" => Ok(GeneratedField::Preamble), - "metadata" => Ok(GeneratedField::Metadata), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ControllerPacketMetadata; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.ControllerPacketMetadata") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut preamble__ = None; - let mut metadata__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Preamble => { - if preamble__.is_some() { - return Err(serde::de::Error::duplicate_field("preamble")); - } - preamble__ = map_.next_value()?; - } - GeneratedField::Metadata => { - if metadata__.is_some() { - return Err(serde::de::Error::duplicate_field("metadata")); - } - metadata__ = Some(map_.next_value()?); - } - } - } - Ok(ControllerPacketMetadata { - preamble: preamble__, - metadata: metadata__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.ControllerPacketMetadata", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for controller_packet_metadata::Metadata { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.id != 0 { - len += 1; - } - if !self.name.is_empty() { - len += 1; - } - if !self.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if self.bitwidth != 0 { - len += 1; - } - if self.type_name.is_some() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.ControllerPacketMetadata.Metadata", len)?; - if self.id != 0 { - struct_ser.serialize_field("id", &self.id)?; - } - if !self.name.is_empty() { - struct_ser.serialize_field("name", &self.name)?; - } - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if self.bitwidth != 0 { - struct_ser.serialize_field("bitwidth", &self.bitwidth)?; - } - if let Some(v) = self.type_name.as_ref() { - struct_ser.serialize_field("typeName", v)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for controller_packet_metadata::Metadata { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "id", - "name", - "annotations", - "annotation_locations", - "annotationLocations", - "bitwidth", - "type_name", - "typeName", - "structured_annotations", - "structuredAnnotations", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Id, - Name, - Annotations, - AnnotationLocations, - Bitwidth, - TypeName, - StructuredAnnotations, - } - 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 { - "id" => Ok(GeneratedField::Id), - "name" => Ok(GeneratedField::Name), - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "bitwidth" => Ok(GeneratedField::Bitwidth), - "typeName" | "type_name" => Ok(GeneratedField::TypeName), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = controller_packet_metadata::Metadata; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.ControllerPacketMetadata.Metadata") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut id__ = None; - let mut name__ = None; - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut bitwidth__ = None; - let mut type_name__ = None; - let mut structured_annotations__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Id => { - if id__.is_some() { - return Err(serde::de::Error::duplicate_field("id")); - } - id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Name => { - if name__.is_some() { - return Err(serde::de::Error::duplicate_field("name")); - } - name__ = Some(map_.next_value()?); - } - GeneratedField::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::Bitwidth => { - if bitwidth__.is_some() { - return Err(serde::de::Error::duplicate_field("bitwidth")); - } - bitwidth__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::TypeName => { - if type_name__.is_some() { - return Err(serde::de::Error::duplicate_field("typeName")); - } - type_name__ = map_.next_value()?; - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - } - } - Ok(controller_packet_metadata::Metadata { - id: id__.unwrap_or_default(), - name: name__.unwrap_or_default(), - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - bitwidth: bitwidth__.unwrap_or_default(), - type_name: type_name__, - structured_annotations: structured_annotations__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.ControllerPacketMetadata.Metadata", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Counter { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.preamble.is_some() { - len += 1; - } - if self.spec.is_some() { - len += 1; - } - if self.size != 0 { - len += 1; - } - if self.index_type_name.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.Counter", len)?; - if let Some(v) = self.preamble.as_ref() { - struct_ser.serialize_field("preamble", v)?; - } - if let Some(v) = self.spec.as_ref() { - struct_ser.serialize_field("spec", v)?; - } - if self.size != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("size", ToString::to_string(&self.size).as_str())?; - } - if let Some(v) = self.index_type_name.as_ref() { - struct_ser.serialize_field("indexTypeName", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Counter { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "preamble", - "spec", - "size", - "index_type_name", - "indexTypeName", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Preamble, - Spec, - Size, - IndexTypeName, - } - 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 { - "preamble" => Ok(GeneratedField::Preamble), - "spec" => Ok(GeneratedField::Spec), - "size" => Ok(GeneratedField::Size), - "indexTypeName" | "index_type_name" => Ok(GeneratedField::IndexTypeName), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Counter; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.Counter") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut preamble__ = None; - let mut spec__ = None; - let mut size__ = None; - let mut index_type_name__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Preamble => { - if preamble__.is_some() { - return Err(serde::de::Error::duplicate_field("preamble")); - } - preamble__ = map_.next_value()?; - } - GeneratedField::Spec => { - if spec__.is_some() { - return Err(serde::de::Error::duplicate_field("spec")); - } - spec__ = map_.next_value()?; - } - GeneratedField::Size => { - if size__.is_some() { - return Err(serde::de::Error::duplicate_field("size")); - } - size__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::IndexTypeName => { - if index_type_name__.is_some() { - return Err(serde::de::Error::duplicate_field("indexTypeName")); - } - index_type_name__ = map_.next_value()?; - } - } - } - Ok(Counter { - preamble: preamble__, - spec: spec__, - size: size__.unwrap_or_default(), - index_type_name: index_type_name__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.Counter", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for CounterSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.unit != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.CounterSpec", len)?; - if self.unit != 0 { - let v = counter_spec::Unit::try_from(self.unit) - .map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.unit)))?; - struct_ser.serialize_field("unit", &v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for CounterSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "unit", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Unit, - } - 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 { - "unit" => Ok(GeneratedField::Unit), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = CounterSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.CounterSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut unit__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Unit => { - if unit__.is_some() { - return Err(serde::de::Error::duplicate_field("unit")); - } - unit__ = Some(map_.next_value::()? as i32); - } - } - } - Ok(CounterSpec { - unit: unit__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.CounterSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for counter_spec::Unit { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - let variant = match self { - Self::Unspecified => "UNSPECIFIED", - Self::Bytes => "BYTES", - Self::Packets => "PACKETS", - Self::Both => "BOTH", - }; - serializer.serialize_str(variant) - } -} -impl<'de> serde::Deserialize<'de> for counter_spec::Unit { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "UNSPECIFIED", - "BYTES", - "PACKETS", - "BOTH", - ]; - - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = counter_spec::Unit; - - 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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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 { - "UNSPECIFIED" => Ok(counter_spec::Unit::Unspecified), - "BYTES" => Ok(counter_spec::Unit::Bytes), - "PACKETS" => Ok(counter_spec::Unit::Packets), - "BOTH" => Ok(counter_spec::Unit::Both), - _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), - } - } - } - deserializer.deserialize_any(GeneratedVisitor) - } -} -impl serde::Serialize for Digest { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.preamble.is_some() { - len += 1; - } - if self.type_spec.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.Digest", len)?; - if let Some(v) = self.preamble.as_ref() { - struct_ser.serialize_field("preamble", v)?; - } - if let Some(v) = self.type_spec.as_ref() { - struct_ser.serialize_field("typeSpec", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Digest { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "preamble", - "type_spec", - "typeSpec", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Preamble, - TypeSpec, - } - 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 { - "preamble" => Ok(GeneratedField::Preamble), - "typeSpec" | "type_spec" => Ok(GeneratedField::TypeSpec), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Digest; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.Digest") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut preamble__ = None; - let mut type_spec__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Preamble => { - if preamble__.is_some() { - return Err(serde::de::Error::duplicate_field("preamble")); - } - preamble__ = map_.next_value()?; - } - GeneratedField::TypeSpec => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("typeSpec")); - } - type_spec__ = map_.next_value()?; - } - } - } - Ok(Digest { - preamble: preamble__, - type_spec: type_spec__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.Digest", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for DirectCounter { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.preamble.is_some() { - len += 1; - } - if self.spec.is_some() { - len += 1; - } - if self.direct_table_id != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.DirectCounter", len)?; - if let Some(v) = self.preamble.as_ref() { - struct_ser.serialize_field("preamble", v)?; - } - if let Some(v) = self.spec.as_ref() { - struct_ser.serialize_field("spec", v)?; - } - if self.direct_table_id != 0 { - struct_ser.serialize_field("directTableId", &self.direct_table_id)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for DirectCounter { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "preamble", - "spec", - "direct_table_id", - "directTableId", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Preamble, - Spec, - DirectTableId, - } - 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 { - "preamble" => Ok(GeneratedField::Preamble), - "spec" => Ok(GeneratedField::Spec), - "directTableId" | "direct_table_id" => Ok(GeneratedField::DirectTableId), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = DirectCounter; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.DirectCounter") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut preamble__ = None; - let mut spec__ = None; - let mut direct_table_id__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Preamble => { - if preamble__.is_some() { - return Err(serde::de::Error::duplicate_field("preamble")); - } - preamble__ = map_.next_value()?; - } - GeneratedField::Spec => { - if spec__.is_some() { - return Err(serde::de::Error::duplicate_field("spec")); - } - spec__ = map_.next_value()?; - } - GeneratedField::DirectTableId => { - if direct_table_id__.is_some() { - return Err(serde::de::Error::duplicate_field("directTableId")); - } - direct_table_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(DirectCounter { - preamble: preamble__, - spec: spec__, - direct_table_id: direct_table_id__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.DirectCounter", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for DirectMeter { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.preamble.is_some() { - len += 1; - } - if self.spec.is_some() { - len += 1; - } - if self.direct_table_id != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.DirectMeter", len)?; - if let Some(v) = self.preamble.as_ref() { - struct_ser.serialize_field("preamble", v)?; - } - if let Some(v) = self.spec.as_ref() { - struct_ser.serialize_field("spec", v)?; - } - if self.direct_table_id != 0 { - struct_ser.serialize_field("directTableId", &self.direct_table_id)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for DirectMeter { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "preamble", - "spec", - "direct_table_id", - "directTableId", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Preamble, - Spec, - DirectTableId, - } - 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 { - "preamble" => Ok(GeneratedField::Preamble), - "spec" => Ok(GeneratedField::Spec), - "directTableId" | "direct_table_id" => Ok(GeneratedField::DirectTableId), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = DirectMeter; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.DirectMeter") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut preamble__ = None; - let mut spec__ = None; - let mut direct_table_id__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Preamble => { - if preamble__.is_some() { - return Err(serde::de::Error::duplicate_field("preamble")); - } - preamble__ = map_.next_value()?; - } - GeneratedField::Spec => { - if spec__.is_some() { - return Err(serde::de::Error::duplicate_field("spec")); - } - spec__ = map_.next_value()?; - } - GeneratedField::DirectTableId => { - if direct_table_id__.is_some() { - return Err(serde::de::Error::duplicate_field("directTableId")); - } - direct_table_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(DirectMeter { - preamble: preamble__, - spec: spec__, - direct_table_id: direct_table_id__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.DirectMeter", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Documentation { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.brief.is_empty() { - len += 1; - } - if !self.description.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.Documentation", len)?; - if !self.brief.is_empty() { - struct_ser.serialize_field("brief", &self.brief)?; - } - if !self.description.is_empty() { - struct_ser.serialize_field("description", &self.description)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Documentation { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "brief", - "description", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Brief, - Description, - } - 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 { - "brief" => Ok(GeneratedField::Brief), - "description" => Ok(GeneratedField::Description), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Documentation; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.Documentation") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut brief__ = None; - let mut description__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Brief => { - if brief__.is_some() { - return Err(serde::de::Error::duplicate_field("brief")); - } - brief__ = Some(map_.next_value()?); - } - GeneratedField::Description => { - if description__.is_some() { - return Err(serde::de::Error::duplicate_field("description")); - } - description__ = Some(map_.next_value()?); - } - } - } - Ok(Documentation { - brief: brief__.unwrap_or_default(), - description: description__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.Documentation", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Expression { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.value.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.Expression", len)?; - if let Some(v) = self.value.as_ref() { - match v { - expression::Value::StringValue(v) => { - struct_ser.serialize_field("stringValue", v)?; - } - expression::Value::Int64Value(v) => { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("int64Value", ToString::to_string(&v).as_str())?; - } - expression::Value::BoolValue(v) => { - struct_ser.serialize_field("boolValue", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Expression { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "string_value", - "stringValue", - "int64_value", - "int64Value", - "bool_value", - "boolValue", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - StringValue, - Int64Value, - BoolValue, - } - 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 { - "stringValue" | "string_value" => Ok(GeneratedField::StringValue), - "int64Value" | "int64_value" => Ok(GeneratedField::Int64Value), - "boolValue" | "bool_value" => Ok(GeneratedField::BoolValue), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Expression; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.Expression") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut value__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::StringValue => { - if value__.is_some() { - return Err(serde::de::Error::duplicate_field("stringValue")); - } - value__ = map_.next_value::<::std::option::Option<_>>()?.map(expression::Value::StringValue); - } - GeneratedField::Int64Value => { - if value__.is_some() { - return Err(serde::de::Error::duplicate_field("int64Value")); - } - value__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| expression::Value::Int64Value(x.0)); - } - GeneratedField::BoolValue => { - if value__.is_some() { - return Err(serde::de::Error::duplicate_field("boolValue")); - } - value__ = map_.next_value::<::std::option::Option<_>>()?.map(expression::Value::BoolValue); - } - } - } - Ok(Expression { - value: value__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.Expression", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ExpressionList { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.expressions.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.ExpressionList", len)?; - if !self.expressions.is_empty() { - struct_ser.serialize_field("expressions", &self.expressions)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ExpressionList { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "expressions", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Expressions, - } - 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 { - "expressions" => Ok(GeneratedField::Expressions), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ExpressionList; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.ExpressionList") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut expressions__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Expressions => { - if expressions__.is_some() { - return Err(serde::de::Error::duplicate_field("expressions")); - } - expressions__ = Some(map_.next_value()?); - } - } - } - Ok(ExpressionList { - expressions: expressions__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.ExpressionList", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Extern { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.extern_type_id != 0 { - len += 1; - } - if !self.extern_type_name.is_empty() { - len += 1; - } - if !self.instances.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.Extern", len)?; - if self.extern_type_id != 0 { - struct_ser.serialize_field("externTypeId", &self.extern_type_id)?; - } - if !self.extern_type_name.is_empty() { - struct_ser.serialize_field("externTypeName", &self.extern_type_name)?; - } - if !self.instances.is_empty() { - struct_ser.serialize_field("instances", &self.instances)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Extern { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "extern_type_id", - "externTypeId", - "extern_type_name", - "externTypeName", - "instances", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - ExternTypeId, - ExternTypeName, - Instances, - } - 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 { - "externTypeId" | "extern_type_id" => Ok(GeneratedField::ExternTypeId), - "externTypeName" | "extern_type_name" => Ok(GeneratedField::ExternTypeName), - "instances" => Ok(GeneratedField::Instances), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Extern; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.Extern") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut extern_type_id__ = None; - let mut extern_type_name__ = None; - let mut instances__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::ExternTypeId => { - if extern_type_id__.is_some() { - return Err(serde::de::Error::duplicate_field("externTypeId")); - } - extern_type_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::ExternTypeName => { - if extern_type_name__.is_some() { - return Err(serde::de::Error::duplicate_field("externTypeName")); - } - extern_type_name__ = Some(map_.next_value()?); - } - GeneratedField::Instances => { - if instances__.is_some() { - return Err(serde::de::Error::duplicate_field("instances")); - } - instances__ = Some(map_.next_value()?); - } - } - } - Ok(Extern { - extern_type_id: extern_type_id__.unwrap_or_default(), - extern_type_name: extern_type_name__.unwrap_or_default(), - instances: instances__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.Extern", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ExternInstance { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.preamble.is_some() { - len += 1; - } - if self.info.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.ExternInstance", len)?; - if let Some(v) = self.preamble.as_ref() { - struct_ser.serialize_field("preamble", v)?; - } - if let Some(v) = self.info.as_ref() { - struct_ser.serialize_field("info", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ExternInstance { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "preamble", - "info", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Preamble, - Info, - } - 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 { - "preamble" => Ok(GeneratedField::Preamble), - "info" => Ok(GeneratedField::Info), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ExternInstance; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.ExternInstance") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut preamble__ = None; - let mut info__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Preamble => { - if preamble__.is_some() { - return Err(serde::de::Error::duplicate_field("preamble")); - } - preamble__ = map_.next_value()?; - } - GeneratedField::Info => { - if info__.is_some() { - return Err(serde::de::Error::duplicate_field("info")); - } - info__ = map_.next_value()?; - } - } - } - Ok(ExternInstance { - preamble: preamble__, - info: info__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.ExternInstance", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for KeyValuePair { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.key.is_empty() { - len += 1; - } - if self.value.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.KeyValuePair", len)?; - if !self.key.is_empty() { - struct_ser.serialize_field("key", &self.key)?; - } - if let Some(v) = self.value.as_ref() { - struct_ser.serialize_field("value", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for KeyValuePair { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "key", - "value", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Key, - Value, - } - 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 { - "key" => Ok(GeneratedField::Key), - "value" => Ok(GeneratedField::Value), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = KeyValuePair; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.KeyValuePair") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut key__ = None; - let mut value__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Key => { - if key__.is_some() { - return Err(serde::de::Error::duplicate_field("key")); - } - key__ = Some(map_.next_value()?); - } - GeneratedField::Value => { - if value__.is_some() { - return Err(serde::de::Error::duplicate_field("value")); - } - value__ = map_.next_value()?; - } - } - } - Ok(KeyValuePair { - key: key__.unwrap_or_default(), - value: value__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.KeyValuePair", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for KeyValuePairList { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.kv_pairs.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.KeyValuePairList", len)?; - if !self.kv_pairs.is_empty() { - struct_ser.serialize_field("kvPairs", &self.kv_pairs)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for KeyValuePairList { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "kv_pairs", - "kvPairs", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - KvPairs, - } - 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 { - "kvPairs" | "kv_pairs" => Ok(GeneratedField::KvPairs), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = KeyValuePairList; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.KeyValuePairList") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut kv_pairs__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::KvPairs => { - if kv_pairs__.is_some() { - return Err(serde::de::Error::duplicate_field("kvPairs")); - } - kv_pairs__ = Some(map_.next_value()?); - } - } - } - Ok(KeyValuePairList { - kv_pairs: kv_pairs__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.KeyValuePairList", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for MatchField { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.id != 0 { - len += 1; - } - if !self.name.is_empty() { - len += 1; - } - if !self.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if self.bitwidth != 0 { - len += 1; - } - if self.doc.is_some() { - len += 1; - } - if self.type_name.is_some() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - if self.r#match.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.MatchField", len)?; - if self.id != 0 { - struct_ser.serialize_field("id", &self.id)?; - } - if !self.name.is_empty() { - struct_ser.serialize_field("name", &self.name)?; - } - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if self.bitwidth != 0 { - struct_ser.serialize_field("bitwidth", &self.bitwidth)?; - } - if let Some(v) = self.doc.as_ref() { - struct_ser.serialize_field("doc", v)?; - } - if let Some(v) = self.type_name.as_ref() { - struct_ser.serialize_field("typeName", v)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - if let Some(v) = self.r#match.as_ref() { - match v { - match_field::Match::MatchType(v) => { - let v = match_field::MatchType::try_from(*v) - .map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", *v)))?; - struct_ser.serialize_field("matchType", &v)?; - } - match_field::Match::OtherMatchType(v) => { - struct_ser.serialize_field("otherMatchType", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for MatchField { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "id", - "name", - "annotations", - "annotation_locations", - "annotationLocations", - "bitwidth", - "doc", - "type_name", - "typeName", - "structured_annotations", - "structuredAnnotations", - "match_type", - "matchType", - "other_match_type", - "otherMatchType", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Id, - Name, - Annotations, - AnnotationLocations, - Bitwidth, - Doc, - TypeName, - StructuredAnnotations, - MatchType, - OtherMatchType, - } - 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 { - "id" => Ok(GeneratedField::Id), - "name" => Ok(GeneratedField::Name), - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "bitwidth" => Ok(GeneratedField::Bitwidth), - "doc" => Ok(GeneratedField::Doc), - "typeName" | "type_name" => Ok(GeneratedField::TypeName), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - "matchType" | "match_type" => Ok(GeneratedField::MatchType), - "otherMatchType" | "other_match_type" => Ok(GeneratedField::OtherMatchType), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = MatchField; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.MatchField") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut id__ = None; - let mut name__ = None; - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut bitwidth__ = None; - let mut doc__ = None; - let mut type_name__ = None; - let mut structured_annotations__ = None; - let mut r#match__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Id => { - if id__.is_some() { - return Err(serde::de::Error::duplicate_field("id")); - } - id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Name => { - if name__.is_some() { - return Err(serde::de::Error::duplicate_field("name")); - } - name__ = Some(map_.next_value()?); - } - GeneratedField::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::Bitwidth => { - if bitwidth__.is_some() { - return Err(serde::de::Error::duplicate_field("bitwidth")); - } - bitwidth__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Doc => { - if doc__.is_some() { - return Err(serde::de::Error::duplicate_field("doc")); - } - doc__ = map_.next_value()?; - } - GeneratedField::TypeName => { - if type_name__.is_some() { - return Err(serde::de::Error::duplicate_field("typeName")); - } - type_name__ = map_.next_value()?; - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - GeneratedField::MatchType => { - if r#match__.is_some() { - return Err(serde::de::Error::duplicate_field("matchType")); - } - r#match__ = map_.next_value::<::std::option::Option>()?.map(|x| match_field::Match::MatchType(x as i32)); - } - GeneratedField::OtherMatchType => { - if r#match__.is_some() { - return Err(serde::de::Error::duplicate_field("otherMatchType")); - } - r#match__ = map_.next_value::<::std::option::Option<_>>()?.map(match_field::Match::OtherMatchType); - } - } - } - Ok(MatchField { - id: id__.unwrap_or_default(), - name: name__.unwrap_or_default(), - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - bitwidth: bitwidth__.unwrap_or_default(), - doc: doc__, - type_name: type_name__, - structured_annotations: structured_annotations__.unwrap_or_default(), - r#match: r#match__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.MatchField", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for match_field::MatchType { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - let variant = match self { - Self::Unspecified => "UNSPECIFIED", - Self::Exact => "EXACT", - Self::Lpm => "LPM", - Self::Ternary => "TERNARY", - Self::Range => "RANGE", - Self::Optional => "OPTIONAL", - }; - serializer.serialize_str(variant) - } -} -impl<'de> serde::Deserialize<'de> for match_field::MatchType { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "UNSPECIFIED", - "EXACT", - "LPM", - "TERNARY", - "RANGE", - "OPTIONAL", - ]; - - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = match_field::MatchType; - - 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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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 { - "UNSPECIFIED" => Ok(match_field::MatchType::Unspecified), - "EXACT" => Ok(match_field::MatchType::Exact), - "LPM" => Ok(match_field::MatchType::Lpm), - "TERNARY" => Ok(match_field::MatchType::Ternary), - "RANGE" => Ok(match_field::MatchType::Range), - "OPTIONAL" => Ok(match_field::MatchType::Optional), - _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), - } - } - } - deserializer.deserialize_any(GeneratedVisitor) - } -} -impl serde::Serialize for Meter { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.preamble.is_some() { - len += 1; - } - if self.spec.is_some() { - len += 1; - } - if self.size != 0 { - len += 1; - } - if self.index_type_name.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.Meter", len)?; - if let Some(v) = self.preamble.as_ref() { - struct_ser.serialize_field("preamble", v)?; - } - if let Some(v) = self.spec.as_ref() { - struct_ser.serialize_field("spec", v)?; - } - if self.size != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("size", ToString::to_string(&self.size).as_str())?; - } - if let Some(v) = self.index_type_name.as_ref() { - struct_ser.serialize_field("indexTypeName", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Meter { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "preamble", - "spec", - "size", - "index_type_name", - "indexTypeName", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Preamble, - Spec, - Size, - IndexTypeName, - } - 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 { - "preamble" => Ok(GeneratedField::Preamble), - "spec" => Ok(GeneratedField::Spec), - "size" => Ok(GeneratedField::Size), - "indexTypeName" | "index_type_name" => Ok(GeneratedField::IndexTypeName), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Meter; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.Meter") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut preamble__ = None; - let mut spec__ = None; - let mut size__ = None; - let mut index_type_name__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Preamble => { - if preamble__.is_some() { - return Err(serde::de::Error::duplicate_field("preamble")); - } - preamble__ = map_.next_value()?; - } - GeneratedField::Spec => { - if spec__.is_some() { - return Err(serde::de::Error::duplicate_field("spec")); - } - spec__ = map_.next_value()?; - } - GeneratedField::Size => { - if size__.is_some() { - return Err(serde::de::Error::duplicate_field("size")); - } - size__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::IndexTypeName => { - if index_type_name__.is_some() { - return Err(serde::de::Error::duplicate_field("indexTypeName")); - } - index_type_name__ = map_.next_value()?; - } - } - } - Ok(Meter { - preamble: preamble__, - spec: spec__, - size: size__.unwrap_or_default(), - index_type_name: index_type_name__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.Meter", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for MeterSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.unit != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.MeterSpec", len)?; - if self.unit != 0 { - let v = meter_spec::Unit::try_from(self.unit) - .map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.unit)))?; - struct_ser.serialize_field("unit", &v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for MeterSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "unit", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Unit, - } - 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 { - "unit" => Ok(GeneratedField::Unit), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = MeterSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.MeterSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut unit__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Unit => { - if unit__.is_some() { - return Err(serde::de::Error::duplicate_field("unit")); - } - unit__ = Some(map_.next_value::()? as i32); - } - } - } - Ok(MeterSpec { - unit: unit__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.MeterSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for meter_spec::Unit { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - let variant = match self { - Self::Unspecified => "UNSPECIFIED", - Self::Bytes => "BYTES", - Self::Packets => "PACKETS", - }; - serializer.serialize_str(variant) - } -} -impl<'de> serde::Deserialize<'de> for meter_spec::Unit { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "UNSPECIFIED", - "BYTES", - "PACKETS", - ]; - - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = meter_spec::Unit; - - 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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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 { - "UNSPECIFIED" => Ok(meter_spec::Unit::Unspecified), - "BYTES" => Ok(meter_spec::Unit::Bytes), - "PACKETS" => Ok(meter_spec::Unit::Packets), - _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), - } - } - } - deserializer.deserialize_any(GeneratedVisitor) - } -} -impl serde::Serialize for P4BitTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.bitwidth != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4BitTypeSpec", len)?; - if self.bitwidth != 0 { - struct_ser.serialize_field("bitwidth", &self.bitwidth)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4BitTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "bitwidth", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Bitwidth, - } - 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 { - "bitwidth" => Ok(GeneratedField::Bitwidth), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4BitTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4BitTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut bitwidth__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Bitwidth => { - if bitwidth__.is_some() { - return Err(serde::de::Error::duplicate_field("bitwidth")); - } - bitwidth__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(P4BitTypeSpec { - bitwidth: bitwidth__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4BitTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4BitstringLikeTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - if self.type_spec.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4BitstringLikeTypeSpec", len)?; - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - if let Some(v) = self.type_spec.as_ref() { - match v { - p4_bitstring_like_type_spec::TypeSpec::Bit(v) => { - struct_ser.serialize_field("bit", v)?; - } - p4_bitstring_like_type_spec::TypeSpec::Int(v) => { - struct_ser.serialize_field("int", v)?; - } - p4_bitstring_like_type_spec::TypeSpec::Varbit(v) => { - struct_ser.serialize_field("varbit", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4BitstringLikeTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "annotations", - "annotation_locations", - "annotationLocations", - "structured_annotations", - "structuredAnnotations", - "bit", - "int", - "varbit", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Annotations, - AnnotationLocations, - StructuredAnnotations, - Bit, - Int, - Varbit, - } - 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 { - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - "bit" => Ok(GeneratedField::Bit), - "int" => Ok(GeneratedField::Int), - "varbit" => Ok(GeneratedField::Varbit), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4BitstringLikeTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4BitstringLikeTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut structured_annotations__ = None; - let mut type_spec__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - GeneratedField::Bit => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("bit")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_bitstring_like_type_spec::TypeSpec::Bit) -; - } - GeneratedField::Int => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("int")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_bitstring_like_type_spec::TypeSpec::Int) -; - } - GeneratedField::Varbit => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("varbit")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_bitstring_like_type_spec::TypeSpec::Varbit) -; - } - } - } - Ok(P4BitstringLikeTypeSpec { - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - structured_annotations: structured_annotations__.unwrap_or_default(), - type_spec: type_spec__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4BitstringLikeTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4BoolType { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let len = 0; - let struct_ser = serializer.serialize_struct("p4.config.v1.P4BoolType", len)?; - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4BoolType { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - } - 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, - { - Err(serde::de::Error::unknown_field(value, FIELDS)) - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4BoolType; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4BoolType") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - while map_.next_key::()?.is_some() { - let _ = map_.next_value::()?; - } - Ok(P4BoolType { - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4BoolType", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4DataTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.type_spec.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4DataTypeSpec", len)?; - if let Some(v) = self.type_spec.as_ref() { - match v { - p4_data_type_spec::TypeSpec::Bitstring(v) => { - struct_ser.serialize_field("bitstring", v)?; - } - p4_data_type_spec::TypeSpec::Bool(v) => { - struct_ser.serialize_field("bool", v)?; - } - p4_data_type_spec::TypeSpec::Tuple(v) => { - struct_ser.serialize_field("tuple", v)?; - } - p4_data_type_spec::TypeSpec::Struct(v) => { - struct_ser.serialize_field("struct", v)?; - } - p4_data_type_spec::TypeSpec::Header(v) => { - struct_ser.serialize_field("header", v)?; - } - p4_data_type_spec::TypeSpec::HeaderUnion(v) => { - struct_ser.serialize_field("headerUnion", v)?; - } - p4_data_type_spec::TypeSpec::HeaderStack(v) => { - struct_ser.serialize_field("headerStack", v)?; - } - p4_data_type_spec::TypeSpec::HeaderUnionStack(v) => { - struct_ser.serialize_field("headerUnionStack", v)?; - } - p4_data_type_spec::TypeSpec::Enum(v) => { - struct_ser.serialize_field("enum", v)?; - } - p4_data_type_spec::TypeSpec::Error(v) => { - struct_ser.serialize_field("error", v)?; - } - p4_data_type_spec::TypeSpec::SerializableEnum(v) => { - struct_ser.serialize_field("serializableEnum", v)?; - } - p4_data_type_spec::TypeSpec::NewType(v) => { - struct_ser.serialize_field("newType", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4DataTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "bitstring", - "bool", - "tuple", - "struct", - "header", - "header_union", - "headerUnion", - "header_stack", - "headerStack", - "header_union_stack", - "headerUnionStack", - "enum", - "error", - "serializable_enum", - "serializableEnum", - "new_type", - "newType", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Bitstring, - Bool, - Tuple, - Struct, - Header, - HeaderUnion, - HeaderStack, - HeaderUnionStack, - Enum, - Error, - SerializableEnum, - NewType, - } - 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 { - "bitstring" => Ok(GeneratedField::Bitstring), - "bool" => Ok(GeneratedField::Bool), - "tuple" => Ok(GeneratedField::Tuple), - "struct" => Ok(GeneratedField::Struct), - "header" => Ok(GeneratedField::Header), - "headerUnion" | "header_union" => Ok(GeneratedField::HeaderUnion), - "headerStack" | "header_stack" => Ok(GeneratedField::HeaderStack), - "headerUnionStack" | "header_union_stack" => Ok(GeneratedField::HeaderUnionStack), - "enum" => Ok(GeneratedField::Enum), - "error" => Ok(GeneratedField::Error), - "serializableEnum" | "serializable_enum" => Ok(GeneratedField::SerializableEnum), - "newType" | "new_type" => Ok(GeneratedField::NewType), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4DataTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4DataTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut type_spec__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Bitstring => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("bitstring")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data_type_spec::TypeSpec::Bitstring) -; - } - GeneratedField::Bool => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("bool")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data_type_spec::TypeSpec::Bool) -; - } - GeneratedField::Tuple => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("tuple")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data_type_spec::TypeSpec::Tuple) -; - } - GeneratedField::Struct => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("struct")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data_type_spec::TypeSpec::Struct) -; - } - GeneratedField::Header => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("header")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data_type_spec::TypeSpec::Header) -; - } - GeneratedField::HeaderUnion => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("headerUnion")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data_type_spec::TypeSpec::HeaderUnion) -; - } - GeneratedField::HeaderStack => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("headerStack")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data_type_spec::TypeSpec::HeaderStack) -; - } - GeneratedField::HeaderUnionStack => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("headerUnionStack")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data_type_spec::TypeSpec::HeaderUnionStack) -; - } - GeneratedField::Enum => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("enum")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data_type_spec::TypeSpec::Enum) -; - } - GeneratedField::Error => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("error")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data_type_spec::TypeSpec::Error) -; - } - GeneratedField::SerializableEnum => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("serializableEnum")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data_type_spec::TypeSpec::SerializableEnum) -; - } - GeneratedField::NewType => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("newType")); - } - type_spec__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data_type_spec::TypeSpec::NewType) -; - } - } - } - Ok(P4DataTypeSpec { - type_spec: type_spec__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4DataTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4EnumTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.members.is_empty() { - len += 1; - } - if !self.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4EnumTypeSpec", len)?; - if !self.members.is_empty() { - struct_ser.serialize_field("members", &self.members)?; - } - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4EnumTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "members", - "annotations", - "annotation_locations", - "annotationLocations", - "structured_annotations", - "structuredAnnotations", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Members, - Annotations, - AnnotationLocations, - StructuredAnnotations, - } - 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 { - "members" => Ok(GeneratedField::Members), - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4EnumTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4EnumTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut members__ = None; - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut structured_annotations__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Members => { - if members__.is_some() { - return Err(serde::de::Error::duplicate_field("members")); - } - members__ = Some(map_.next_value()?); - } - GeneratedField::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - } - } - Ok(P4EnumTypeSpec { - members: members__.unwrap_or_default(), - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - structured_annotations: structured_annotations__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4EnumTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for p4_enum_type_spec::Member { - #[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.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4EnumTypeSpec.Member", len)?; - if !self.name.is_empty() { - struct_ser.serialize_field("name", &self.name)?; - } - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for p4_enum_type_spec::Member { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "name", - "annotations", - "annotation_locations", - "annotationLocations", - "structured_annotations", - "structuredAnnotations", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Name, - Annotations, - AnnotationLocations, - StructuredAnnotations, - } - 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), - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = p4_enum_type_spec::Member; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4EnumTypeSpec.Member") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut name__ = None; - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut structured_annotations__ = 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::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - } - } - Ok(p4_enum_type_spec::Member { - name: name__.unwrap_or_default(), - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - structured_annotations: structured_annotations__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4EnumTypeSpec.Member", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4ErrorType { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let len = 0; - let struct_ser = serializer.serialize_struct("p4.config.v1.P4ErrorType", len)?; - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4ErrorType { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - } - 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, - { - Err(serde::de::Error::unknown_field(value, FIELDS)) - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4ErrorType; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4ErrorType") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - while map_.next_key::()?.is_some() { - let _ = map_.next_value::()?; - } - Ok(P4ErrorType { - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4ErrorType", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4ErrorTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.members.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4ErrorTypeSpec", len)?; - if !self.members.is_empty() { - struct_ser.serialize_field("members", &self.members)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4ErrorTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "members", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Members, - } - 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 { - "members" => Ok(GeneratedField::Members), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4ErrorTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4ErrorTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut members__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Members => { - if members__.is_some() { - return Err(serde::de::Error::duplicate_field("members")); - } - members__ = Some(map_.next_value()?); - } - } - } - Ok(P4ErrorTypeSpec { - members: members__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4ErrorTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4HeaderStackTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.header.is_some() { - len += 1; - } - if self.size != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4HeaderStackTypeSpec", len)?; - if let Some(v) = self.header.as_ref() { - struct_ser.serialize_field("header", v)?; - } - if self.size != 0 { - struct_ser.serialize_field("size", &self.size)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4HeaderStackTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "header", - "size", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Header, - Size, - } - 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 { - "header" => Ok(GeneratedField::Header), - "size" => Ok(GeneratedField::Size), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4HeaderStackTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4HeaderStackTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut header__ = None; - let mut size__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Header => { - if header__.is_some() { - return Err(serde::de::Error::duplicate_field("header")); - } - header__ = map_.next_value()?; - } - GeneratedField::Size => { - if size__.is_some() { - return Err(serde::de::Error::duplicate_field("size")); - } - size__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(P4HeaderStackTypeSpec { - header: header__, - size: size__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4HeaderStackTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4HeaderTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.members.is_empty() { - len += 1; - } - if !self.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4HeaderTypeSpec", len)?; - if !self.members.is_empty() { - struct_ser.serialize_field("members", &self.members)?; - } - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4HeaderTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "members", - "annotations", - "annotation_locations", - "annotationLocations", - "structured_annotations", - "structuredAnnotations", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Members, - Annotations, - AnnotationLocations, - StructuredAnnotations, - } - 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 { - "members" => Ok(GeneratedField::Members), - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4HeaderTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4HeaderTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut members__ = None; - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut structured_annotations__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Members => { - if members__.is_some() { - return Err(serde::de::Error::duplicate_field("members")); - } - members__ = Some(map_.next_value()?); - } - GeneratedField::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - } - } - Ok(P4HeaderTypeSpec { - members: members__.unwrap_or_default(), - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - structured_annotations: structured_annotations__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4HeaderTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for p4_header_type_spec::Member { - #[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.type_spec.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4HeaderTypeSpec.Member", len)?; - if !self.name.is_empty() { - struct_ser.serialize_field("name", &self.name)?; - } - if let Some(v) = self.type_spec.as_ref() { - struct_ser.serialize_field("typeSpec", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for p4_header_type_spec::Member { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "name", - "type_spec", - "typeSpec", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Name, - TypeSpec, - } - 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), - "typeSpec" | "type_spec" => Ok(GeneratedField::TypeSpec), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = p4_header_type_spec::Member; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4HeaderTypeSpec.Member") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut name__ = None; - let mut type_spec__ = 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::TypeSpec => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("typeSpec")); - } - type_spec__ = map_.next_value()?; - } - } - } - Ok(p4_header_type_spec::Member { - name: name__.unwrap_or_default(), - type_spec: type_spec__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4HeaderTypeSpec.Member", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4HeaderUnionStackTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.header_union.is_some() { - len += 1; - } - if self.size != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4HeaderUnionStackTypeSpec", len)?; - if let Some(v) = self.header_union.as_ref() { - struct_ser.serialize_field("headerUnion", v)?; - } - if self.size != 0 { - struct_ser.serialize_field("size", &self.size)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4HeaderUnionStackTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "header_union", - "headerUnion", - "size", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - HeaderUnion, - Size, - } - 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 { - "headerUnion" | "header_union" => Ok(GeneratedField::HeaderUnion), - "size" => Ok(GeneratedField::Size), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4HeaderUnionStackTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4HeaderUnionStackTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut header_union__ = None; - let mut size__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::HeaderUnion => { - if header_union__.is_some() { - return Err(serde::de::Error::duplicate_field("headerUnion")); - } - header_union__ = map_.next_value()?; - } - GeneratedField::Size => { - if size__.is_some() { - return Err(serde::de::Error::duplicate_field("size")); - } - size__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(P4HeaderUnionStackTypeSpec { - header_union: header_union__, - size: size__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4HeaderUnionStackTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4HeaderUnionTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.members.is_empty() { - len += 1; - } - if !self.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4HeaderUnionTypeSpec", len)?; - if !self.members.is_empty() { - struct_ser.serialize_field("members", &self.members)?; - } - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4HeaderUnionTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "members", - "annotations", - "annotation_locations", - "annotationLocations", - "structured_annotations", - "structuredAnnotations", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Members, - Annotations, - AnnotationLocations, - StructuredAnnotations, - } - 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 { - "members" => Ok(GeneratedField::Members), - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4HeaderUnionTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4HeaderUnionTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut members__ = None; - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut structured_annotations__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Members => { - if members__.is_some() { - return Err(serde::de::Error::duplicate_field("members")); - } - members__ = Some(map_.next_value()?); - } - GeneratedField::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - } - } - Ok(P4HeaderUnionTypeSpec { - members: members__.unwrap_or_default(), - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - structured_annotations: structured_annotations__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4HeaderUnionTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for p4_header_union_type_spec::Member { - #[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.header.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4HeaderUnionTypeSpec.Member", len)?; - if !self.name.is_empty() { - struct_ser.serialize_field("name", &self.name)?; - } - if let Some(v) = self.header.as_ref() { - struct_ser.serialize_field("header", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for p4_header_union_type_spec::Member { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "name", - "header", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Name, - Header, - } - 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), - "header" => Ok(GeneratedField::Header), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = p4_header_union_type_spec::Member; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4HeaderUnionTypeSpec.Member") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut name__ = None; - let mut header__ = 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::Header => { - if header__.is_some() { - return Err(serde::de::Error::duplicate_field("header")); - } - header__ = map_.next_value()?; - } - } - } - Ok(p4_header_union_type_spec::Member { - name: name__.unwrap_or_default(), - header: header__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4HeaderUnionTypeSpec.Member", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4Ids { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let len = 0; - let struct_ser = serializer.serialize_struct("p4.config.v1.P4Ids", len)?; - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4Ids { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - } - 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, - { - Err(serde::de::Error::unknown_field(value, FIELDS)) - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4Ids; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4Ids") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - while map_.next_key::()?.is_some() { - let _ = map_.next_value::()?; - } - Ok(P4Ids { - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4Ids", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for p4_ids::Prefix { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - let variant = match self { - Self::Unspecified => "UNSPECIFIED", - Self::Action => "ACTION", - Self::Table => "TABLE", - Self::ValueSet => "VALUE_SET", - Self::ControllerHeader => "CONTROLLER_HEADER", - Self::PsaExternsStart => "PSA_EXTERNS_START", - Self::ActionProfile => "ACTION_PROFILE", - Self::Counter => "COUNTER", - Self::DirectCounter => "DIRECT_COUNTER", - Self::Meter => "METER", - Self::DirectMeter => "DIRECT_METER", - Self::Register => "REGISTER", - Self::Digest => "DIGEST", - Self::OtherExternsStart => "OTHER_EXTERNS_START", - Self::Max => "MAX", - }; - serializer.serialize_str(variant) - } -} -impl<'de> serde::Deserialize<'de> for p4_ids::Prefix { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "UNSPECIFIED", - "ACTION", - "TABLE", - "VALUE_SET", - "CONTROLLER_HEADER", - "PSA_EXTERNS_START", - "ACTION_PROFILE", - "COUNTER", - "DIRECT_COUNTER", - "METER", - "DIRECT_METER", - "REGISTER", - "DIGEST", - "OTHER_EXTERNS_START", - "MAX", - ]; - - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = p4_ids::Prefix; - - 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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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 { - "UNSPECIFIED" => Ok(p4_ids::Prefix::Unspecified), - "ACTION" => Ok(p4_ids::Prefix::Action), - "TABLE" => Ok(p4_ids::Prefix::Table), - "VALUE_SET" => Ok(p4_ids::Prefix::ValueSet), - "CONTROLLER_HEADER" => Ok(p4_ids::Prefix::ControllerHeader), - "PSA_EXTERNS_START" => Ok(p4_ids::Prefix::PsaExternsStart), - "ACTION_PROFILE" => Ok(p4_ids::Prefix::ActionProfile), - "COUNTER" => Ok(p4_ids::Prefix::Counter), - "DIRECT_COUNTER" => Ok(p4_ids::Prefix::DirectCounter), - "METER" => Ok(p4_ids::Prefix::Meter), - "DIRECT_METER" => Ok(p4_ids::Prefix::DirectMeter), - "REGISTER" => Ok(p4_ids::Prefix::Register), - "DIGEST" => Ok(p4_ids::Prefix::Digest), - "OTHER_EXTERNS_START" => Ok(p4_ids::Prefix::OtherExternsStart), - "MAX" => Ok(p4_ids::Prefix::Max), - _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), - } - } - } - deserializer.deserialize_any(GeneratedVisitor) - } -} -impl serde::Serialize for P4Info { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.pkg_info.is_some() { - len += 1; - } - if !self.tables.is_empty() { - len += 1; - } - if !self.actions.is_empty() { - len += 1; - } - if !self.action_profiles.is_empty() { - len += 1; - } - if !self.counters.is_empty() { - len += 1; - } - if !self.direct_counters.is_empty() { - len += 1; - } - if !self.meters.is_empty() { - len += 1; - } - if !self.direct_meters.is_empty() { - len += 1; - } - if !self.controller_packet_metadata.is_empty() { - len += 1; - } - if !self.value_sets.is_empty() { - len += 1; - } - if !self.registers.is_empty() { - len += 1; - } - if !self.digests.is_empty() { - len += 1; - } - if !self.externs.is_empty() { - len += 1; - } - if self.type_info.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4Info", len)?; - if let Some(v) = self.pkg_info.as_ref() { - struct_ser.serialize_field("pkgInfo", v)?; - } - if !self.tables.is_empty() { - struct_ser.serialize_field("tables", &self.tables)?; - } - if !self.actions.is_empty() { - struct_ser.serialize_field("actions", &self.actions)?; - } - if !self.action_profiles.is_empty() { - struct_ser.serialize_field("actionProfiles", &self.action_profiles)?; - } - if !self.counters.is_empty() { - struct_ser.serialize_field("counters", &self.counters)?; - } - if !self.direct_counters.is_empty() { - struct_ser.serialize_field("directCounters", &self.direct_counters)?; - } - if !self.meters.is_empty() { - struct_ser.serialize_field("meters", &self.meters)?; - } - if !self.direct_meters.is_empty() { - struct_ser.serialize_field("directMeters", &self.direct_meters)?; - } - if !self.controller_packet_metadata.is_empty() { - struct_ser.serialize_field("controllerPacketMetadata", &self.controller_packet_metadata)?; - } - if !self.value_sets.is_empty() { - struct_ser.serialize_field("valueSets", &self.value_sets)?; - } - if !self.registers.is_empty() { - struct_ser.serialize_field("registers", &self.registers)?; - } - if !self.digests.is_empty() { - struct_ser.serialize_field("digests", &self.digests)?; - } - if !self.externs.is_empty() { - struct_ser.serialize_field("externs", &self.externs)?; - } - if let Some(v) = self.type_info.as_ref() { - struct_ser.serialize_field("typeInfo", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4Info { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "pkg_info", - "pkgInfo", - "tables", - "actions", - "action_profiles", - "actionProfiles", - "counters", - "direct_counters", - "directCounters", - "meters", - "direct_meters", - "directMeters", - "controller_packet_metadata", - "controllerPacketMetadata", - "value_sets", - "valueSets", - "registers", - "digests", - "externs", - "type_info", - "typeInfo", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - PkgInfo, - Tables, - Actions, - ActionProfiles, - Counters, - DirectCounters, - Meters, - DirectMeters, - ControllerPacketMetadata, - ValueSets, - Registers, - Digests, - Externs, - TypeInfo, - } - 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 { - "pkgInfo" | "pkg_info" => Ok(GeneratedField::PkgInfo), - "tables" => Ok(GeneratedField::Tables), - "actions" => Ok(GeneratedField::Actions), - "actionProfiles" | "action_profiles" => Ok(GeneratedField::ActionProfiles), - "counters" => Ok(GeneratedField::Counters), - "directCounters" | "direct_counters" => Ok(GeneratedField::DirectCounters), - "meters" => Ok(GeneratedField::Meters), - "directMeters" | "direct_meters" => Ok(GeneratedField::DirectMeters), - "controllerPacketMetadata" | "controller_packet_metadata" => Ok(GeneratedField::ControllerPacketMetadata), - "valueSets" | "value_sets" => Ok(GeneratedField::ValueSets), - "registers" => Ok(GeneratedField::Registers), - "digests" => Ok(GeneratedField::Digests), - "externs" => Ok(GeneratedField::Externs), - "typeInfo" | "type_info" => Ok(GeneratedField::TypeInfo), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4Info; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4Info") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut pkg_info__ = None; - let mut tables__ = None; - let mut actions__ = None; - let mut action_profiles__ = None; - let mut counters__ = None; - let mut direct_counters__ = None; - let mut meters__ = None; - let mut direct_meters__ = None; - let mut controller_packet_metadata__ = None; - let mut value_sets__ = None; - let mut registers__ = None; - let mut digests__ = None; - let mut externs__ = None; - let mut type_info__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::PkgInfo => { - if pkg_info__.is_some() { - return Err(serde::de::Error::duplicate_field("pkgInfo")); - } - pkg_info__ = map_.next_value()?; - } - GeneratedField::Tables => { - if tables__.is_some() { - return Err(serde::de::Error::duplicate_field("tables")); - } - tables__ = Some(map_.next_value()?); - } - GeneratedField::Actions => { - if actions__.is_some() { - return Err(serde::de::Error::duplicate_field("actions")); - } - actions__ = Some(map_.next_value()?); - } - GeneratedField::ActionProfiles => { - if action_profiles__.is_some() { - return Err(serde::de::Error::duplicate_field("actionProfiles")); - } - action_profiles__ = Some(map_.next_value()?); - } - GeneratedField::Counters => { - if counters__.is_some() { - return Err(serde::de::Error::duplicate_field("counters")); - } - counters__ = Some(map_.next_value()?); - } - GeneratedField::DirectCounters => { - if direct_counters__.is_some() { - return Err(serde::de::Error::duplicate_field("directCounters")); - } - direct_counters__ = Some(map_.next_value()?); - } - GeneratedField::Meters => { - if meters__.is_some() { - return Err(serde::de::Error::duplicate_field("meters")); - } - meters__ = Some(map_.next_value()?); - } - GeneratedField::DirectMeters => { - if direct_meters__.is_some() { - return Err(serde::de::Error::duplicate_field("directMeters")); - } - direct_meters__ = Some(map_.next_value()?); - } - GeneratedField::ControllerPacketMetadata => { - if controller_packet_metadata__.is_some() { - return Err(serde::de::Error::duplicate_field("controllerPacketMetadata")); - } - controller_packet_metadata__ = Some(map_.next_value()?); - } - GeneratedField::ValueSets => { - if value_sets__.is_some() { - return Err(serde::de::Error::duplicate_field("valueSets")); - } - value_sets__ = Some(map_.next_value()?); - } - GeneratedField::Registers => { - if registers__.is_some() { - return Err(serde::de::Error::duplicate_field("registers")); - } - registers__ = Some(map_.next_value()?); - } - GeneratedField::Digests => { - if digests__.is_some() { - return Err(serde::de::Error::duplicate_field("digests")); - } - digests__ = Some(map_.next_value()?); - } - GeneratedField::Externs => { - if externs__.is_some() { - return Err(serde::de::Error::duplicate_field("externs")); - } - externs__ = Some(map_.next_value()?); - } - GeneratedField::TypeInfo => { - if type_info__.is_some() { - return Err(serde::de::Error::duplicate_field("typeInfo")); - } - type_info__ = map_.next_value()?; - } - } - } - Ok(P4Info { - pkg_info: pkg_info__, - tables: tables__.unwrap_or_default(), - actions: actions__.unwrap_or_default(), - action_profiles: action_profiles__.unwrap_or_default(), - counters: counters__.unwrap_or_default(), - direct_counters: direct_counters__.unwrap_or_default(), - meters: meters__.unwrap_or_default(), - direct_meters: direct_meters__.unwrap_or_default(), - controller_packet_metadata: controller_packet_metadata__.unwrap_or_default(), - value_sets: value_sets__.unwrap_or_default(), - registers: registers__.unwrap_or_default(), - digests: digests__.unwrap_or_default(), - externs: externs__.unwrap_or_default(), - type_info: type_info__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4Info", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4IntTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.bitwidth != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4IntTypeSpec", len)?; - if self.bitwidth != 0 { - struct_ser.serialize_field("bitwidth", &self.bitwidth)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4IntTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "bitwidth", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Bitwidth, - } - 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 { - "bitwidth" => Ok(GeneratedField::Bitwidth), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4IntTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4IntTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut bitwidth__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Bitwidth => { - if bitwidth__.is_some() { - return Err(serde::de::Error::duplicate_field("bitwidth")); - } - bitwidth__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(P4IntTypeSpec { - bitwidth: bitwidth__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4IntTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4NamedType { - #[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; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4NamedType", len)?; - if !self.name.is_empty() { - struct_ser.serialize_field("name", &self.name)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4NamedType { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "name", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Name, - } - 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), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4NamedType; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4NamedType") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut name__ = 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()?); - } - } - } - Ok(P4NamedType { - name: name__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4NamedType", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4NewTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - if self.representation.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4NewTypeSpec", len)?; - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - if let Some(v) = self.representation.as_ref() { - match v { - p4_new_type_spec::Representation::OriginalType(v) => { - struct_ser.serialize_field("originalType", v)?; - } - p4_new_type_spec::Representation::TranslatedType(v) => { - struct_ser.serialize_field("translatedType", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4NewTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "annotations", - "annotation_locations", - "annotationLocations", - "structured_annotations", - "structuredAnnotations", - "original_type", - "originalType", - "translated_type", - "translatedType", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Annotations, - AnnotationLocations, - StructuredAnnotations, - OriginalType, - TranslatedType, - } - 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 { - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - "originalType" | "original_type" => Ok(GeneratedField::OriginalType), - "translatedType" | "translated_type" => Ok(GeneratedField::TranslatedType), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4NewTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4NewTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut structured_annotations__ = None; - let mut representation__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - GeneratedField::OriginalType => { - if representation__.is_some() { - return Err(serde::de::Error::duplicate_field("originalType")); - } - representation__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_new_type_spec::Representation::OriginalType) -; - } - GeneratedField::TranslatedType => { - if representation__.is_some() { - return Err(serde::de::Error::duplicate_field("translatedType")); - } - representation__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_new_type_spec::Representation::TranslatedType) -; - } - } - } - Ok(P4NewTypeSpec { - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - structured_annotations: structured_annotations__.unwrap_or_default(), - representation: representation__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4NewTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4NewTypeTranslation { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.uri.is_empty() { - len += 1; - } - if self.sdn_type.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4NewTypeTranslation", len)?; - if !self.uri.is_empty() { - struct_ser.serialize_field("uri", &self.uri)?; - } - if let Some(v) = self.sdn_type.as_ref() { - match v { - p4_new_type_translation::SdnType::SdnBitwidth(v) => { - struct_ser.serialize_field("sdnBitwidth", v)?; - } - p4_new_type_translation::SdnType::SdnString(v) => { - struct_ser.serialize_field("sdnString", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4NewTypeTranslation { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "uri", - "sdn_bitwidth", - "sdnBitwidth", - "sdn_string", - "sdnString", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Uri, - SdnBitwidth, - SdnString, - } - 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 { - "uri" => Ok(GeneratedField::Uri), - "sdnBitwidth" | "sdn_bitwidth" => Ok(GeneratedField::SdnBitwidth), - "sdnString" | "sdn_string" => Ok(GeneratedField::SdnString), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4NewTypeTranslation; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4NewTypeTranslation") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut uri__ = None; - let mut sdn_type__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Uri => { - if uri__.is_some() { - return Err(serde::de::Error::duplicate_field("uri")); - } - uri__ = Some(map_.next_value()?); - } - GeneratedField::SdnBitwidth => { - if sdn_type__.is_some() { - return Err(serde::de::Error::duplicate_field("sdnBitwidth")); - } - sdn_type__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| p4_new_type_translation::SdnType::SdnBitwidth(x.0)); - } - GeneratedField::SdnString => { - if sdn_type__.is_some() { - return Err(serde::de::Error::duplicate_field("sdnString")); - } - sdn_type__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_new_type_translation::SdnType::SdnString) -; - } - } - } - Ok(P4NewTypeTranslation { - uri: uri__.unwrap_or_default(), - sdn_type: sdn_type__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4NewTypeTranslation", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for p4_new_type_translation::SdnString { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let len = 0; - let struct_ser = serializer.serialize_struct("p4.config.v1.P4NewTypeTranslation.SdnString", len)?; - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for p4_new_type_translation::SdnString { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - } - 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, - { - Err(serde::de::Error::unknown_field(value, FIELDS)) - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = p4_new_type_translation::SdnString; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4NewTypeTranslation.SdnString") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - while map_.next_key::()?.is_some() { - let _ = map_.next_value::()?; - } - Ok(p4_new_type_translation::SdnString { - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4NewTypeTranslation.SdnString", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4SerializableEnumTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.underlying_type.is_some() { - len += 1; - } - if !self.members.is_empty() { - len += 1; - } - if !self.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4SerializableEnumTypeSpec", len)?; - if let Some(v) = self.underlying_type.as_ref() { - struct_ser.serialize_field("underlyingType", v)?; - } - if !self.members.is_empty() { - struct_ser.serialize_field("members", &self.members)?; - } - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4SerializableEnumTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "underlying_type", - "underlyingType", - "members", - "annotations", - "annotation_locations", - "annotationLocations", - "structured_annotations", - "structuredAnnotations", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - UnderlyingType, - Members, - Annotations, - AnnotationLocations, - StructuredAnnotations, - } - 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 { - "underlyingType" | "underlying_type" => Ok(GeneratedField::UnderlyingType), - "members" => Ok(GeneratedField::Members), - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4SerializableEnumTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4SerializableEnumTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut underlying_type__ = None; - let mut members__ = None; - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut structured_annotations__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::UnderlyingType => { - if underlying_type__.is_some() { - return Err(serde::de::Error::duplicate_field("underlyingType")); - } - underlying_type__ = map_.next_value()?; - } - GeneratedField::Members => { - if members__.is_some() { - return Err(serde::de::Error::duplicate_field("members")); - } - members__ = Some(map_.next_value()?); - } - GeneratedField::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - } - } - Ok(P4SerializableEnumTypeSpec { - underlying_type: underlying_type__, - members: members__.unwrap_or_default(), - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - structured_annotations: structured_annotations__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4SerializableEnumTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for p4_serializable_enum_type_spec::Member { - #[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.value.is_empty() { - len += 1; - } - if !self.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4SerializableEnumTypeSpec.Member", len)?; - if !self.name.is_empty() { - struct_ser.serialize_field("name", &self.name)?; - } - if !self.value.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("value", pbjson::private::base64::encode(&self.value).as_str())?; - } - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for p4_serializable_enum_type_spec::Member { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "name", - "value", - "annotations", - "annotation_locations", - "annotationLocations", - "structured_annotations", - "structuredAnnotations", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Name, - Value, - Annotations, - AnnotationLocations, - StructuredAnnotations, - } - 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), - "value" => Ok(GeneratedField::Value), - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = p4_serializable_enum_type_spec::Member; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4SerializableEnumTypeSpec.Member") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut name__ = None; - let mut value__ = None; - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut structured_annotations__ = 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::Value => { - if value__.is_some() { - return Err(serde::de::Error::duplicate_field("value")); - } - value__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - } - } - Ok(p4_serializable_enum_type_spec::Member { - name: name__.unwrap_or_default(), - value: value__.unwrap_or_default(), - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - structured_annotations: structured_annotations__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4SerializableEnumTypeSpec.Member", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4StructTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.members.is_empty() { - len += 1; - } - if !self.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4StructTypeSpec", len)?; - if !self.members.is_empty() { - struct_ser.serialize_field("members", &self.members)?; - } - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4StructTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "members", - "annotations", - "annotation_locations", - "annotationLocations", - "structured_annotations", - "structuredAnnotations", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Members, - Annotations, - AnnotationLocations, - StructuredAnnotations, - } - 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 { - "members" => Ok(GeneratedField::Members), - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4StructTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4StructTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut members__ = None; - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut structured_annotations__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Members => { - if members__.is_some() { - return Err(serde::de::Error::duplicate_field("members")); - } - members__ = Some(map_.next_value()?); - } - GeneratedField::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - } - } - Ok(P4StructTypeSpec { - members: members__.unwrap_or_default(), - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - structured_annotations: structured_annotations__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4StructTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for p4_struct_type_spec::Member { - #[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.type_spec.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4StructTypeSpec.Member", len)?; - if !self.name.is_empty() { - struct_ser.serialize_field("name", &self.name)?; - } - if let Some(v) = self.type_spec.as_ref() { - struct_ser.serialize_field("typeSpec", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for p4_struct_type_spec::Member { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "name", - "type_spec", - "typeSpec", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Name, - TypeSpec, - } - 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), - "typeSpec" | "type_spec" => Ok(GeneratedField::TypeSpec), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = p4_struct_type_spec::Member; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4StructTypeSpec.Member") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut name__ = None; - let mut type_spec__ = 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::TypeSpec => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("typeSpec")); - } - type_spec__ = map_.next_value()?; - } - } - } - Ok(p4_struct_type_spec::Member { - name: name__.unwrap_or_default(), - type_spec: type_spec__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4StructTypeSpec.Member", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4TupleTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.members.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4TupleTypeSpec", len)?; - if !self.members.is_empty() { - struct_ser.serialize_field("members", &self.members)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4TupleTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "members", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Members, - } - 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 { - "members" => Ok(GeneratedField::Members), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4TupleTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4TupleTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut members__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Members => { - if members__.is_some() { - return Err(serde::de::Error::duplicate_field("members")); - } - members__ = Some(map_.next_value()?); - } - } - } - Ok(P4TupleTypeSpec { - members: members__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4TupleTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4TypeInfo { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.structs.is_empty() { - len += 1; - } - if !self.headers.is_empty() { - len += 1; - } - if !self.header_unions.is_empty() { - len += 1; - } - if !self.enums.is_empty() { - len += 1; - } - if self.error.is_some() { - len += 1; - } - if !self.serializable_enums.is_empty() { - len += 1; - } - if !self.new_types.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4TypeInfo", len)?; - if !self.structs.is_empty() { - struct_ser.serialize_field("structs", &self.structs)?; - } - if !self.headers.is_empty() { - struct_ser.serialize_field("headers", &self.headers)?; - } - if !self.header_unions.is_empty() { - struct_ser.serialize_field("headerUnions", &self.header_unions)?; - } - if !self.enums.is_empty() { - struct_ser.serialize_field("enums", &self.enums)?; - } - if let Some(v) = self.error.as_ref() { - struct_ser.serialize_field("error", v)?; - } - if !self.serializable_enums.is_empty() { - struct_ser.serialize_field("serializableEnums", &self.serializable_enums)?; - } - if !self.new_types.is_empty() { - struct_ser.serialize_field("newTypes", &self.new_types)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4TypeInfo { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "structs", - "headers", - "header_unions", - "headerUnions", - "enums", - "error", - "serializable_enums", - "serializableEnums", - "new_types", - "newTypes", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Structs, - Headers, - HeaderUnions, - Enums, - Error, - SerializableEnums, - NewTypes, - } - 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 { - "structs" => Ok(GeneratedField::Structs), - "headers" => Ok(GeneratedField::Headers), - "headerUnions" | "header_unions" => Ok(GeneratedField::HeaderUnions), - "enums" => Ok(GeneratedField::Enums), - "error" => Ok(GeneratedField::Error), - "serializableEnums" | "serializable_enums" => Ok(GeneratedField::SerializableEnums), - "newTypes" | "new_types" => Ok(GeneratedField::NewTypes), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4TypeInfo; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4TypeInfo") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut structs__ = None; - let mut headers__ = None; - let mut header_unions__ = None; - let mut enums__ = None; - let mut error__ = None; - let mut serializable_enums__ = None; - let mut new_types__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Structs => { - if structs__.is_some() { - return Err(serde::de::Error::duplicate_field("structs")); - } - structs__ = Some( - map_.next_value::>()? - ); - } - GeneratedField::Headers => { - if headers__.is_some() { - return Err(serde::de::Error::duplicate_field("headers")); - } - headers__ = Some( - map_.next_value::>()? - ); - } - GeneratedField::HeaderUnions => { - if header_unions__.is_some() { - return Err(serde::de::Error::duplicate_field("headerUnions")); - } - header_unions__ = Some( - map_.next_value::>()? - ); - } - GeneratedField::Enums => { - if enums__.is_some() { - return Err(serde::de::Error::duplicate_field("enums")); - } - enums__ = Some( - map_.next_value::>()? - ); - } - GeneratedField::Error => { - if error__.is_some() { - return Err(serde::de::Error::duplicate_field("error")); - } - error__ = map_.next_value()?; - } - GeneratedField::SerializableEnums => { - if serializable_enums__.is_some() { - return Err(serde::de::Error::duplicate_field("serializableEnums")); - } - serializable_enums__ = Some( - map_.next_value::>()? - ); - } - GeneratedField::NewTypes => { - if new_types__.is_some() { - return Err(serde::de::Error::duplicate_field("newTypes")); - } - new_types__ = Some( - map_.next_value::>()? - ); - } - } - } - Ok(P4TypeInfo { - structs: structs__.unwrap_or_default(), - headers: headers__.unwrap_or_default(), - header_unions: header_unions__.unwrap_or_default(), - enums: enums__.unwrap_or_default(), - error: error__, - serializable_enums: serializable_enums__.unwrap_or_default(), - new_types: new_types__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4TypeInfo", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4VarbitTypeSpec { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.max_bitwidth != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.P4VarbitTypeSpec", len)?; - if self.max_bitwidth != 0 { - struct_ser.serialize_field("maxBitwidth", &self.max_bitwidth)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4VarbitTypeSpec { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "max_bitwidth", - "maxBitwidth", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - MaxBitwidth, - } - 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 { - "maxBitwidth" | "max_bitwidth" => Ok(GeneratedField::MaxBitwidth), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4VarbitTypeSpec; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.P4VarbitTypeSpec") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut max_bitwidth__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::MaxBitwidth => { - if max_bitwidth__.is_some() { - return Err(serde::de::Error::duplicate_field("maxBitwidth")); - } - max_bitwidth__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(P4VarbitTypeSpec { - max_bitwidth: max_bitwidth__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.P4VarbitTypeSpec", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for PkgInfo { - #[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.version.is_empty() { - len += 1; - } - if self.doc.is_some() { - len += 1; - } - if !self.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if !self.arch.is_empty() { - len += 1; - } - if !self.organization.is_empty() { - len += 1; - } - if !self.contact.is_empty() { - len += 1; - } - if !self.url.is_empty() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - if self.platform_properties.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.PkgInfo", len)?; - if !self.name.is_empty() { - struct_ser.serialize_field("name", &self.name)?; - } - if !self.version.is_empty() { - struct_ser.serialize_field("version", &self.version)?; - } - if let Some(v) = self.doc.as_ref() { - struct_ser.serialize_field("doc", v)?; - } - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if !self.arch.is_empty() { - struct_ser.serialize_field("arch", &self.arch)?; - } - if !self.organization.is_empty() { - struct_ser.serialize_field("organization", &self.organization)?; - } - if !self.contact.is_empty() { - struct_ser.serialize_field("contact", &self.contact)?; - } - if !self.url.is_empty() { - struct_ser.serialize_field("url", &self.url)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - if let Some(v) = self.platform_properties.as_ref() { - struct_ser.serialize_field("platformProperties", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for PkgInfo { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "name", - "version", - "doc", - "annotations", - "annotation_locations", - "annotationLocations", - "arch", - "organization", - "contact", - "url", - "structured_annotations", - "structuredAnnotations", - "platform_properties", - "platformProperties", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Name, - Version, - Doc, - Annotations, - AnnotationLocations, - Arch, - Organization, - Contact, - Url, - StructuredAnnotations, - PlatformProperties, - } - 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), - "version" => Ok(GeneratedField::Version), - "doc" => Ok(GeneratedField::Doc), - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "arch" => Ok(GeneratedField::Arch), - "organization" => Ok(GeneratedField::Organization), - "contact" => Ok(GeneratedField::Contact), - "url" => Ok(GeneratedField::Url), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - "platformProperties" | "platform_properties" => Ok(GeneratedField::PlatformProperties), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = PkgInfo; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.PkgInfo") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut name__ = None; - let mut version__ = None; - let mut doc__ = None; - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut arch__ = None; - let mut organization__ = None; - let mut contact__ = None; - let mut url__ = None; - let mut structured_annotations__ = None; - let mut platform_properties__ = 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::Version => { - if version__.is_some() { - return Err(serde::de::Error::duplicate_field("version")); - } - version__ = Some(map_.next_value()?); - } - GeneratedField::Doc => { - if doc__.is_some() { - return Err(serde::de::Error::duplicate_field("doc")); - } - doc__ = map_.next_value()?; - } - GeneratedField::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::Arch => { - if arch__.is_some() { - return Err(serde::de::Error::duplicate_field("arch")); - } - arch__ = Some(map_.next_value()?); - } - GeneratedField::Organization => { - if organization__.is_some() { - return Err(serde::de::Error::duplicate_field("organization")); - } - organization__ = Some(map_.next_value()?); - } - GeneratedField::Contact => { - if contact__.is_some() { - return Err(serde::de::Error::duplicate_field("contact")); - } - contact__ = Some(map_.next_value()?); - } - GeneratedField::Url => { - if url__.is_some() { - return Err(serde::de::Error::duplicate_field("url")); - } - url__ = Some(map_.next_value()?); - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - GeneratedField::PlatformProperties => { - if platform_properties__.is_some() { - return Err(serde::de::Error::duplicate_field("platformProperties")); - } - platform_properties__ = map_.next_value()?; - } - } - } - Ok(PkgInfo { - name: name__.unwrap_or_default(), - version: version__.unwrap_or_default(), - doc: doc__, - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - arch: arch__.unwrap_or_default(), - organization: organization__.unwrap_or_default(), - contact: contact__.unwrap_or_default(), - url: url__.unwrap_or_default(), - structured_annotations: structured_annotations__.unwrap_or_default(), - platform_properties: platform_properties__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.PkgInfo", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for PlatformProperties { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.multicast_group_table_size != 0 { - len += 1; - } - if self.multicast_group_table_total_replicas != 0 { - len += 1; - } - if self.multicast_group_table_max_replicas_per_entry != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.PlatformProperties", len)?; - if self.multicast_group_table_size != 0 { - struct_ser.serialize_field("multicastGroupTableSize", &self.multicast_group_table_size)?; - } - if self.multicast_group_table_total_replicas != 0 { - struct_ser.serialize_field("multicastGroupTableTotalReplicas", &self.multicast_group_table_total_replicas)?; - } - if self.multicast_group_table_max_replicas_per_entry != 0 { - struct_ser.serialize_field("multicastGroupTableMaxReplicasPerEntry", &self.multicast_group_table_max_replicas_per_entry)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for PlatformProperties { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "multicast_group_table_size", - "multicastGroupTableSize", - "multicast_group_table_total_replicas", - "multicastGroupTableTotalReplicas", - "multicast_group_table_max_replicas_per_entry", - "multicastGroupTableMaxReplicasPerEntry", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - MulticastGroupTableSize, - MulticastGroupTableTotalReplicas, - MulticastGroupTableMaxReplicasPerEntry, - } - 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 { - "multicastGroupTableSize" | "multicast_group_table_size" => Ok(GeneratedField::MulticastGroupTableSize), - "multicastGroupTableTotalReplicas" | "multicast_group_table_total_replicas" => Ok(GeneratedField::MulticastGroupTableTotalReplicas), - "multicastGroupTableMaxReplicasPerEntry" | "multicast_group_table_max_replicas_per_entry" => Ok(GeneratedField::MulticastGroupTableMaxReplicasPerEntry), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = PlatformProperties; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.PlatformProperties") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut multicast_group_table_size__ = None; - let mut multicast_group_table_total_replicas__ = None; - let mut multicast_group_table_max_replicas_per_entry__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::MulticastGroupTableSize => { - if multicast_group_table_size__.is_some() { - return Err(serde::de::Error::duplicate_field("multicastGroupTableSize")); - } - multicast_group_table_size__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::MulticastGroupTableTotalReplicas => { - if multicast_group_table_total_replicas__.is_some() { - return Err(serde::de::Error::duplicate_field("multicastGroupTableTotalReplicas")); - } - multicast_group_table_total_replicas__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::MulticastGroupTableMaxReplicasPerEntry => { - if multicast_group_table_max_replicas_per_entry__.is_some() { - return Err(serde::de::Error::duplicate_field("multicastGroupTableMaxReplicasPerEntry")); - } - multicast_group_table_max_replicas_per_entry__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(PlatformProperties { - multicast_group_table_size: multicast_group_table_size__.unwrap_or_default(), - multicast_group_table_total_replicas: multicast_group_table_total_replicas__.unwrap_or_default(), - multicast_group_table_max_replicas_per_entry: multicast_group_table_max_replicas_per_entry__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.PlatformProperties", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Preamble { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.id != 0 { - len += 1; - } - if !self.name.is_empty() { - len += 1; - } - if !self.alias.is_empty() { - len += 1; - } - if !self.annotations.is_empty() { - len += 1; - } - if !self.annotation_locations.is_empty() { - len += 1; - } - if self.doc.is_some() { - len += 1; - } - if !self.structured_annotations.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.Preamble", len)?; - if self.id != 0 { - struct_ser.serialize_field("id", &self.id)?; - } - if !self.name.is_empty() { - struct_ser.serialize_field("name", &self.name)?; - } - if !self.alias.is_empty() { - struct_ser.serialize_field("alias", &self.alias)?; - } - if !self.annotations.is_empty() { - struct_ser.serialize_field("annotations", &self.annotations)?; - } - if !self.annotation_locations.is_empty() { - struct_ser.serialize_field("annotationLocations", &self.annotation_locations)?; - } - if let Some(v) = self.doc.as_ref() { - struct_ser.serialize_field("doc", v)?; - } - if !self.structured_annotations.is_empty() { - struct_ser.serialize_field("structuredAnnotations", &self.structured_annotations)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Preamble { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "id", - "name", - "alias", - "annotations", - "annotation_locations", - "annotationLocations", - "doc", - "structured_annotations", - "structuredAnnotations", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Id, - Name, - Alias, - Annotations, - AnnotationLocations, - Doc, - StructuredAnnotations, - } - 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 { - "id" => Ok(GeneratedField::Id), - "name" => Ok(GeneratedField::Name), - "alias" => Ok(GeneratedField::Alias), - "annotations" => Ok(GeneratedField::Annotations), - "annotationLocations" | "annotation_locations" => Ok(GeneratedField::AnnotationLocations), - "doc" => Ok(GeneratedField::Doc), - "structuredAnnotations" | "structured_annotations" => Ok(GeneratedField::StructuredAnnotations), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Preamble; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.Preamble") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut id__ = None; - let mut name__ = None; - let mut alias__ = None; - let mut annotations__ = None; - let mut annotation_locations__ = None; - let mut doc__ = None; - let mut structured_annotations__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Id => { - if id__.is_some() { - return Err(serde::de::Error::duplicate_field("id")); - } - id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Name => { - if name__.is_some() { - return Err(serde::de::Error::duplicate_field("name")); - } - name__ = Some(map_.next_value()?); - } - GeneratedField::Alias => { - if alias__.is_some() { - return Err(serde::de::Error::duplicate_field("alias")); - } - alias__ = Some(map_.next_value()?); - } - GeneratedField::Annotations => { - if annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotations")); - } - annotations__ = Some(map_.next_value()?); - } - GeneratedField::AnnotationLocations => { - if annotation_locations__.is_some() { - return Err(serde::de::Error::duplicate_field("annotationLocations")); - } - annotation_locations__ = Some(map_.next_value()?); - } - GeneratedField::Doc => { - if doc__.is_some() { - return Err(serde::de::Error::duplicate_field("doc")); - } - doc__ = map_.next_value()?; - } - GeneratedField::StructuredAnnotations => { - if structured_annotations__.is_some() { - return Err(serde::de::Error::duplicate_field("structuredAnnotations")); - } - structured_annotations__ = Some(map_.next_value()?); - } - } - } - Ok(Preamble { - id: id__.unwrap_or_default(), - name: name__.unwrap_or_default(), - alias: alias__.unwrap_or_default(), - annotations: annotations__.unwrap_or_default(), - annotation_locations: annotation_locations__.unwrap_or_default(), - doc: doc__, - structured_annotations: structured_annotations__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.Preamble", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Register { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.preamble.is_some() { - len += 1; - } - if self.type_spec.is_some() { - len += 1; - } - if self.size != 0 { - len += 1; - } - if self.index_type_name.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.Register", len)?; - if let Some(v) = self.preamble.as_ref() { - struct_ser.serialize_field("preamble", v)?; - } - if let Some(v) = self.type_spec.as_ref() { - struct_ser.serialize_field("typeSpec", v)?; - } - if self.size != 0 { - struct_ser.serialize_field("size", &self.size)?; - } - if let Some(v) = self.index_type_name.as_ref() { - struct_ser.serialize_field("indexTypeName", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Register { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "preamble", - "type_spec", - "typeSpec", - "size", - "index_type_name", - "indexTypeName", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Preamble, - TypeSpec, - Size, - IndexTypeName, - } - 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 { - "preamble" => Ok(GeneratedField::Preamble), - "typeSpec" | "type_spec" => Ok(GeneratedField::TypeSpec), - "size" => Ok(GeneratedField::Size), - "indexTypeName" | "index_type_name" => Ok(GeneratedField::IndexTypeName), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Register; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.Register") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut preamble__ = None; - let mut type_spec__ = None; - let mut size__ = None; - let mut index_type_name__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Preamble => { - if preamble__.is_some() { - return Err(serde::de::Error::duplicate_field("preamble")); - } - preamble__ = map_.next_value()?; - } - GeneratedField::TypeSpec => { - if type_spec__.is_some() { - return Err(serde::de::Error::duplicate_field("typeSpec")); - } - type_spec__ = map_.next_value()?; - } - GeneratedField::Size => { - if size__.is_some() { - return Err(serde::de::Error::duplicate_field("size")); - } - size__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::IndexTypeName => { - if index_type_name__.is_some() { - return Err(serde::de::Error::duplicate_field("indexTypeName")); - } - index_type_name__ = map_.next_value()?; - } - } - } - Ok(Register { - preamble: preamble__, - type_spec: type_spec__, - size: size__.unwrap_or_default(), - index_type_name: index_type_name__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.Register", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for SourceLocation { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.file.is_empty() { - len += 1; - } - if self.line != 0 { - len += 1; - } - if self.column != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.SourceLocation", len)?; - if !self.file.is_empty() { - struct_ser.serialize_field("file", &self.file)?; - } - if self.line != 0 { - struct_ser.serialize_field("line", &self.line)?; - } - if self.column != 0 { - struct_ser.serialize_field("column", &self.column)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for SourceLocation { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "file", - "line", - "column", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - File, - Line, - Column, - } - 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 { - "file" => Ok(GeneratedField::File), - "line" => Ok(GeneratedField::Line), - "column" => Ok(GeneratedField::Column), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = SourceLocation; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.SourceLocation") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut file__ = None; - let mut line__ = None; - let mut column__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::File => { - if file__.is_some() { - return Err(serde::de::Error::duplicate_field("file")); - } - file__ = Some(map_.next_value()?); - } - GeneratedField::Line => { - if line__.is_some() { - return Err(serde::de::Error::duplicate_field("line")); - } - line__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Column => { - if column__.is_some() { - return Err(serde::de::Error::duplicate_field("column")); - } - column__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(SourceLocation { - file: file__.unwrap_or_default(), - line: line__.unwrap_or_default(), - column: column__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.SourceLocation", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for StructuredAnnotation { - #[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.source_location.is_some() { - len += 1; - } - if self.body.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.StructuredAnnotation", len)?; - if !self.name.is_empty() { - struct_ser.serialize_field("name", &self.name)?; - } - if let Some(v) = self.source_location.as_ref() { - struct_ser.serialize_field("sourceLocation", v)?; - } - if let Some(v) = self.body.as_ref() { - match v { - structured_annotation::Body::ExpressionList(v) => { - struct_ser.serialize_field("expressionList", v)?; - } - structured_annotation::Body::KvPairList(v) => { - struct_ser.serialize_field("kvPairList", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for StructuredAnnotation { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "name", - "source_location", - "sourceLocation", - "expression_list", - "expressionList", - "kv_pair_list", - "kvPairList", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Name, - SourceLocation, - ExpressionList, - KvPairList, - } - 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), - "sourceLocation" | "source_location" => Ok(GeneratedField::SourceLocation), - "expressionList" | "expression_list" => Ok(GeneratedField::ExpressionList), - "kvPairList" | "kv_pair_list" => Ok(GeneratedField::KvPairList), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = StructuredAnnotation; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.StructuredAnnotation") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut name__ = None; - let mut source_location__ = None; - let mut body__ = 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::SourceLocation => { - if source_location__.is_some() { - return Err(serde::de::Error::duplicate_field("sourceLocation")); - } - source_location__ = map_.next_value()?; - } - GeneratedField::ExpressionList => { - if body__.is_some() { - return Err(serde::de::Error::duplicate_field("expressionList")); - } - body__ = map_.next_value::<::std::option::Option<_>>()?.map(structured_annotation::Body::ExpressionList) -; - } - GeneratedField::KvPairList => { - if body__.is_some() { - return Err(serde::de::Error::duplicate_field("kvPairList")); - } - body__ = map_.next_value::<::std::option::Option<_>>()?.map(structured_annotation::Body::KvPairList) -; - } - } - } - Ok(StructuredAnnotation { - name: name__.unwrap_or_default(), - source_location: source_location__, - body: body__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.StructuredAnnotation", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Table { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.preamble.is_some() { - len += 1; - } - if !self.match_fields.is_empty() { - len += 1; - } - if !self.action_refs.is_empty() { - len += 1; - } - if self.const_default_action_id != 0 { - len += 1; - } - if self.implementation_id != 0 { - len += 1; - } - if !self.direct_resource_ids.is_empty() { - len += 1; - } - if self.size != 0 { - len += 1; - } - if self.idle_timeout_behavior != 0 { - len += 1; - } - if self.is_const_table { - len += 1; - } - if self.has_initial_entries { - len += 1; - } - if self.other_properties.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.Table", len)?; - if let Some(v) = self.preamble.as_ref() { - struct_ser.serialize_field("preamble", v)?; - } - if !self.match_fields.is_empty() { - struct_ser.serialize_field("matchFields", &self.match_fields)?; - } - if !self.action_refs.is_empty() { - struct_ser.serialize_field("actionRefs", &self.action_refs)?; - } - if self.const_default_action_id != 0 { - struct_ser.serialize_field("constDefaultActionId", &self.const_default_action_id)?; - } - if self.implementation_id != 0 { - struct_ser.serialize_field("implementationId", &self.implementation_id)?; - } - if !self.direct_resource_ids.is_empty() { - struct_ser.serialize_field("directResourceIds", &self.direct_resource_ids)?; - } - if self.size != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("size", ToString::to_string(&self.size).as_str())?; - } - if self.idle_timeout_behavior != 0 { - let v = table::IdleTimeoutBehavior::try_from(self.idle_timeout_behavior) - .map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.idle_timeout_behavior)))?; - struct_ser.serialize_field("idleTimeoutBehavior", &v)?; - } - if self.is_const_table { - struct_ser.serialize_field("isConstTable", &self.is_const_table)?; - } - if self.has_initial_entries { - struct_ser.serialize_field("hasInitialEntries", &self.has_initial_entries)?; - } - if let Some(v) = self.other_properties.as_ref() { - struct_ser.serialize_field("otherProperties", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Table { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "preamble", - "match_fields", - "matchFields", - "action_refs", - "actionRefs", - "const_default_action_id", - "constDefaultActionId", - "implementation_id", - "implementationId", - "direct_resource_ids", - "directResourceIds", - "size", - "idle_timeout_behavior", - "idleTimeoutBehavior", - "is_const_table", - "isConstTable", - "has_initial_entries", - "hasInitialEntries", - "other_properties", - "otherProperties", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Preamble, - MatchFields, - ActionRefs, - ConstDefaultActionId, - ImplementationId, - DirectResourceIds, - Size, - IdleTimeoutBehavior, - IsConstTable, - HasInitialEntries, - OtherProperties, - } - 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 { - "preamble" => Ok(GeneratedField::Preamble), - "matchFields" | "match_fields" => Ok(GeneratedField::MatchFields), - "actionRefs" | "action_refs" => Ok(GeneratedField::ActionRefs), - "constDefaultActionId" | "const_default_action_id" => Ok(GeneratedField::ConstDefaultActionId), - "implementationId" | "implementation_id" => Ok(GeneratedField::ImplementationId), - "directResourceIds" | "direct_resource_ids" => Ok(GeneratedField::DirectResourceIds), - "size" => Ok(GeneratedField::Size), - "idleTimeoutBehavior" | "idle_timeout_behavior" => Ok(GeneratedField::IdleTimeoutBehavior), - "isConstTable" | "is_const_table" => Ok(GeneratedField::IsConstTable), - "hasInitialEntries" | "has_initial_entries" => Ok(GeneratedField::HasInitialEntries), - "otherProperties" | "other_properties" => Ok(GeneratedField::OtherProperties), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Table; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.Table") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut preamble__ = None; - let mut match_fields__ = None; - let mut action_refs__ = None; - let mut const_default_action_id__ = None; - let mut implementation_id__ = None; - let mut direct_resource_ids__ = None; - let mut size__ = None; - let mut idle_timeout_behavior__ = None; - let mut is_const_table__ = None; - let mut has_initial_entries__ = None; - let mut other_properties__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Preamble => { - if preamble__.is_some() { - return Err(serde::de::Error::duplicate_field("preamble")); - } - preamble__ = map_.next_value()?; - } - GeneratedField::MatchFields => { - if match_fields__.is_some() { - return Err(serde::de::Error::duplicate_field("matchFields")); - } - match_fields__ = Some(map_.next_value()?); - } - GeneratedField::ActionRefs => { - if action_refs__.is_some() { - return Err(serde::de::Error::duplicate_field("actionRefs")); - } - action_refs__ = Some(map_.next_value()?); - } - GeneratedField::ConstDefaultActionId => { - if const_default_action_id__.is_some() { - return Err(serde::de::Error::duplicate_field("constDefaultActionId")); - } - const_default_action_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::ImplementationId => { - if implementation_id__.is_some() { - return Err(serde::de::Error::duplicate_field("implementationId")); - } - implementation_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::DirectResourceIds => { - if direct_resource_ids__.is_some() { - return Err(serde::de::Error::duplicate_field("directResourceIds")); - } - direct_resource_ids__ = - Some(map_.next_value::>>()? - .into_iter().map(|x| x.0).collect()) - ; - } - GeneratedField::Size => { - if size__.is_some() { - return Err(serde::de::Error::duplicate_field("size")); - } - size__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::IdleTimeoutBehavior => { - if idle_timeout_behavior__.is_some() { - return Err(serde::de::Error::duplicate_field("idleTimeoutBehavior")); - } - idle_timeout_behavior__ = Some(map_.next_value::()? as i32); - } - GeneratedField::IsConstTable => { - if is_const_table__.is_some() { - return Err(serde::de::Error::duplicate_field("isConstTable")); - } - is_const_table__ = Some(map_.next_value()?); - } - GeneratedField::HasInitialEntries => { - if has_initial_entries__.is_some() { - return Err(serde::de::Error::duplicate_field("hasInitialEntries")); - } - has_initial_entries__ = Some(map_.next_value()?); - } - GeneratedField::OtherProperties => { - if other_properties__.is_some() { - return Err(serde::de::Error::duplicate_field("otherProperties")); - } - other_properties__ = map_.next_value()?; - } - } - } - Ok(Table { - preamble: preamble__, - match_fields: match_fields__.unwrap_or_default(), - action_refs: action_refs__.unwrap_or_default(), - const_default_action_id: const_default_action_id__.unwrap_or_default(), - implementation_id: implementation_id__.unwrap_or_default(), - direct_resource_ids: direct_resource_ids__.unwrap_or_default(), - size: size__.unwrap_or_default(), - idle_timeout_behavior: idle_timeout_behavior__.unwrap_or_default(), - is_const_table: is_const_table__.unwrap_or_default(), - has_initial_entries: has_initial_entries__.unwrap_or_default(), - other_properties: other_properties__, - }) - } - } - deserializer.deserialize_struct("p4.config.v1.Table", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for table::IdleTimeoutBehavior { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - let variant = match self { - Self::NoTimeout => "NO_TIMEOUT", - Self::NotifyControl => "NOTIFY_CONTROL", - }; - serializer.serialize_str(variant) - } -} -impl<'de> serde::Deserialize<'de> for table::IdleTimeoutBehavior { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "NO_TIMEOUT", - "NOTIFY_CONTROL", - ]; - - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = table::IdleTimeoutBehavior; - - 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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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 { - "NO_TIMEOUT" => Ok(table::IdleTimeoutBehavior::NoTimeout), - "NOTIFY_CONTROL" => Ok(table::IdleTimeoutBehavior::NotifyControl), - _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), - } - } - } - deserializer.deserialize_any(GeneratedVisitor) - } -} -impl serde::Serialize for ValueSet { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.preamble.is_some() { - len += 1; - } - if !self.r#match.is_empty() { - len += 1; - } - if self.size != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.config.v1.ValueSet", len)?; - if let Some(v) = self.preamble.as_ref() { - struct_ser.serialize_field("preamble", v)?; - } - if !self.r#match.is_empty() { - struct_ser.serialize_field("match", &self.r#match)?; - } - if self.size != 0 { - struct_ser.serialize_field("size", &self.size)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ValueSet { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "preamble", - "match", - "size", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Preamble, - Match, - Size, - } - 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 { - "preamble" => Ok(GeneratedField::Preamble), - "match" => Ok(GeneratedField::Match), - "size" => Ok(GeneratedField::Size), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ValueSet; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.config.v1.ValueSet") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut preamble__ = None; - let mut r#match__ = None; - let mut size__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Preamble => { - if preamble__.is_some() { - return Err(serde::de::Error::duplicate_field("preamble")); - } - preamble__ = map_.next_value()?; - } - GeneratedField::Match => { - if r#match__.is_some() { - return Err(serde::de::Error::duplicate_field("match")); - } - r#match__ = Some(map_.next_value()?); - } - GeneratedField::Size => { - if size__.is_some() { - return Err(serde::de::Error::duplicate_field("size")); - } - size__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(ValueSet { - preamble: preamble__, - r#match: r#match__.unwrap_or_default(), - size: size__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.config.v1.ValueSet", FIELDS, GeneratedVisitor) - } -} diff --git a/rust/src/p4.v1.rs b/rust/src/p4.v1.rs index f88b5b3c..4e8f95f7 100644 --- a/rust/src/p4.v1.rs +++ b/rust/src/p4.v1.rs @@ -1347,6 +1347,5 @@ impl SdnPort { } } } -include!("p4.v1.serde.rs"); include!("p4.v1.tonic.rs"); // @@protoc_insertion_point(module) diff --git a/rust/src/p4.v1.serde.rs b/rust/src/p4.v1.serde.rs deleted file mode 100644 index efedc453..00000000 --- a/rust/src/p4.v1.serde.rs +++ /dev/null @@ -1,9346 +0,0 @@ -// @generated -impl serde::Serialize for Action { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.action_id != 0 { - len += 1; - } - if !self.params.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.Action", len)?; - if self.action_id != 0 { - struct_ser.serialize_field("actionId", &self.action_id)?; - } - if !self.params.is_empty() { - struct_ser.serialize_field("params", &self.params)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Action { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "action_id", - "actionId", - "params", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - ActionId, - Params, - } - 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 { - "actionId" | "action_id" => Ok(GeneratedField::ActionId), - "params" => Ok(GeneratedField::Params), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Action; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.Action") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut action_id__ = None; - let mut params__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::ActionId => { - if action_id__.is_some() { - return Err(serde::de::Error::duplicate_field("actionId")); - } - action_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Params => { - if params__.is_some() { - return Err(serde::de::Error::duplicate_field("params")); - } - params__ = Some(map_.next_value()?); - } - } - } - Ok(Action { - action_id: action_id__.unwrap_or_default(), - params: params__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.Action", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for action::Param { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.param_id != 0 { - len += 1; - } - if !self.value.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.Action.Param", len)?; - if self.param_id != 0 { - struct_ser.serialize_field("paramId", &self.param_id)?; - } - if !self.value.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("value", pbjson::private::base64::encode(&self.value).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for action::Param { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "param_id", - "paramId", - "value", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - ParamId, - Value, - } - 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 { - "paramId" | "param_id" => Ok(GeneratedField::ParamId), - "value" => Ok(GeneratedField::Value), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = action::Param; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.Action.Param") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut param_id__ = None; - let mut value__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::ParamId => { - if param_id__.is_some() { - return Err(serde::de::Error::duplicate_field("paramId")); - } - param_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Value => { - if value__.is_some() { - return Err(serde::de::Error::duplicate_field("value")); - } - value__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - } - } - Ok(action::Param { - param_id: param_id__.unwrap_or_default(), - value: value__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.Action.Param", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ActionProfileAction { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.action.is_some() { - len += 1; - } - if self.weight != 0 { - len += 1; - } - if self.watch_kind.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.ActionProfileAction", len)?; - if let Some(v) = self.action.as_ref() { - struct_ser.serialize_field("action", v)?; - } - if self.weight != 0 { - struct_ser.serialize_field("weight", &self.weight)?; - } - if let Some(v) = self.watch_kind.as_ref() { - match v { - action_profile_action::WatchKind::Watch(v) => { - struct_ser.serialize_field("watch", v)?; - } - action_profile_action::WatchKind::WatchPort(v) => { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("watchPort", pbjson::private::base64::encode(&v).as_str())?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ActionProfileAction { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "action", - "weight", - "watch", - "watch_port", - "watchPort", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Action, - Weight, - Watch, - WatchPort, - } - 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 { - "action" => Ok(GeneratedField::Action), - "weight" => Ok(GeneratedField::Weight), - "watch" => Ok(GeneratedField::Watch), - "watchPort" | "watch_port" => Ok(GeneratedField::WatchPort), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ActionProfileAction; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.ActionProfileAction") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut action__ = None; - let mut weight__ = None; - let mut watch_kind__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Action => { - if action__.is_some() { - return Err(serde::de::Error::duplicate_field("action")); - } - action__ = map_.next_value()?; - } - GeneratedField::Weight => { - if weight__.is_some() { - return Err(serde::de::Error::duplicate_field("weight")); - } - weight__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Watch => { - if watch_kind__.is_some() { - return Err(serde::de::Error::duplicate_field("watch")); - } - watch_kind__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| action_profile_action::WatchKind::Watch(x.0)); - } - GeneratedField::WatchPort => { - if watch_kind__.is_some() { - return Err(serde::de::Error::duplicate_field("watchPort")); - } - watch_kind__ = map_.next_value::<::std::option::Option<::pbjson::private::BytesDeserialize<_>>>()?.map(|x| action_profile_action::WatchKind::WatchPort(x.0)); - } - } - } - Ok(ActionProfileAction { - action: action__, - weight: weight__.unwrap_or_default(), - watch_kind: watch_kind__, - }) - } - } - deserializer.deserialize_struct("p4.v1.ActionProfileAction", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ActionProfileActionSet { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.action_profile_actions.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.ActionProfileActionSet", len)?; - if !self.action_profile_actions.is_empty() { - struct_ser.serialize_field("actionProfileActions", &self.action_profile_actions)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ActionProfileActionSet { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "action_profile_actions", - "actionProfileActions", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - ActionProfileActions, - } - 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 { - "actionProfileActions" | "action_profile_actions" => Ok(GeneratedField::ActionProfileActions), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ActionProfileActionSet; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.ActionProfileActionSet") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut action_profile_actions__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::ActionProfileActions => { - if action_profile_actions__.is_some() { - return Err(serde::de::Error::duplicate_field("actionProfileActions")); - } - action_profile_actions__ = Some(map_.next_value()?); - } - } - } - Ok(ActionProfileActionSet { - action_profile_actions: action_profile_actions__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.ActionProfileActionSet", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ActionProfileGroup { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.action_profile_id != 0 { - len += 1; - } - if self.group_id != 0 { - len += 1; - } - if !self.members.is_empty() { - len += 1; - } - if self.max_size != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.ActionProfileGroup", len)?; - if self.action_profile_id != 0 { - struct_ser.serialize_field("actionProfileId", &self.action_profile_id)?; - } - if self.group_id != 0 { - struct_ser.serialize_field("groupId", &self.group_id)?; - } - if !self.members.is_empty() { - struct_ser.serialize_field("members", &self.members)?; - } - if self.max_size != 0 { - struct_ser.serialize_field("maxSize", &self.max_size)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ActionProfileGroup { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "action_profile_id", - "actionProfileId", - "group_id", - "groupId", - "members", - "max_size", - "maxSize", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - ActionProfileId, - GroupId, - Members, - MaxSize, - } - 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 { - "actionProfileId" | "action_profile_id" => Ok(GeneratedField::ActionProfileId), - "groupId" | "group_id" => Ok(GeneratedField::GroupId), - "members" => Ok(GeneratedField::Members), - "maxSize" | "max_size" => Ok(GeneratedField::MaxSize), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ActionProfileGroup; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.ActionProfileGroup") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut action_profile_id__ = None; - let mut group_id__ = None; - let mut members__ = None; - let mut max_size__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::ActionProfileId => { - if action_profile_id__.is_some() { - return Err(serde::de::Error::duplicate_field("actionProfileId")); - } - action_profile_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::GroupId => { - if group_id__.is_some() { - return Err(serde::de::Error::duplicate_field("groupId")); - } - group_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Members => { - if members__.is_some() { - return Err(serde::de::Error::duplicate_field("members")); - } - members__ = Some(map_.next_value()?); - } - GeneratedField::MaxSize => { - if max_size__.is_some() { - return Err(serde::de::Error::duplicate_field("maxSize")); - } - max_size__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(ActionProfileGroup { - action_profile_id: action_profile_id__.unwrap_or_default(), - group_id: group_id__.unwrap_or_default(), - members: members__.unwrap_or_default(), - max_size: max_size__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.ActionProfileGroup", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for action_profile_group::Member { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.member_id != 0 { - len += 1; - } - if self.weight != 0 { - len += 1; - } - if self.watch_kind.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.ActionProfileGroup.Member", len)?; - if self.member_id != 0 { - struct_ser.serialize_field("memberId", &self.member_id)?; - } - if self.weight != 0 { - struct_ser.serialize_field("weight", &self.weight)?; - } - if let Some(v) = self.watch_kind.as_ref() { - match v { - action_profile_group::member::WatchKind::Watch(v) => { - struct_ser.serialize_field("watch", v)?; - } - action_profile_group::member::WatchKind::WatchPort(v) => { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("watchPort", pbjson::private::base64::encode(&v).as_str())?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for action_profile_group::Member { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "member_id", - "memberId", - "weight", - "watch", - "watch_port", - "watchPort", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - MemberId, - Weight, - Watch, - WatchPort, - } - 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 { - "memberId" | "member_id" => Ok(GeneratedField::MemberId), - "weight" => Ok(GeneratedField::Weight), - "watch" => Ok(GeneratedField::Watch), - "watchPort" | "watch_port" => Ok(GeneratedField::WatchPort), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = action_profile_group::Member; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.ActionProfileGroup.Member") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut member_id__ = None; - let mut weight__ = None; - let mut watch_kind__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::MemberId => { - if member_id__.is_some() { - return Err(serde::de::Error::duplicate_field("memberId")); - } - member_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Weight => { - if weight__.is_some() { - return Err(serde::de::Error::duplicate_field("weight")); - } - weight__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Watch => { - if watch_kind__.is_some() { - return Err(serde::de::Error::duplicate_field("watch")); - } - watch_kind__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| action_profile_group::member::WatchKind::Watch(x.0)); - } - GeneratedField::WatchPort => { - if watch_kind__.is_some() { - return Err(serde::de::Error::duplicate_field("watchPort")); - } - watch_kind__ = map_.next_value::<::std::option::Option<::pbjson::private::BytesDeserialize<_>>>()?.map(|x| action_profile_group::member::WatchKind::WatchPort(x.0)); - } - } - } - Ok(action_profile_group::Member { - member_id: member_id__.unwrap_or_default(), - weight: weight__.unwrap_or_default(), - watch_kind: watch_kind__, - }) - } - } - deserializer.deserialize_struct("p4.v1.ActionProfileGroup.Member", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ActionProfileMember { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.action_profile_id != 0 { - len += 1; - } - if self.member_id != 0 { - len += 1; - } - if self.action.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.ActionProfileMember", len)?; - if self.action_profile_id != 0 { - struct_ser.serialize_field("actionProfileId", &self.action_profile_id)?; - } - if self.member_id != 0 { - struct_ser.serialize_field("memberId", &self.member_id)?; - } - if let Some(v) = self.action.as_ref() { - struct_ser.serialize_field("action", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ActionProfileMember { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "action_profile_id", - "actionProfileId", - "member_id", - "memberId", - "action", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - ActionProfileId, - MemberId, - Action, - } - 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 { - "actionProfileId" | "action_profile_id" => Ok(GeneratedField::ActionProfileId), - "memberId" | "member_id" => Ok(GeneratedField::MemberId), - "action" => Ok(GeneratedField::Action), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ActionProfileMember; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.ActionProfileMember") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut action_profile_id__ = None; - let mut member_id__ = None; - let mut action__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::ActionProfileId => { - if action_profile_id__.is_some() { - return Err(serde::de::Error::duplicate_field("actionProfileId")); - } - action_profile_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::MemberId => { - if member_id__.is_some() { - return Err(serde::de::Error::duplicate_field("memberId")); - } - member_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Action => { - if action__.is_some() { - return Err(serde::de::Error::duplicate_field("action")); - } - action__ = map_.next_value()?; - } - } - } - Ok(ActionProfileMember { - action_profile_id: action_profile_id__.unwrap_or_default(), - member_id: member_id__.unwrap_or_default(), - action: action__, - }) - } - } - deserializer.deserialize_struct("p4.v1.ActionProfileMember", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for CapabilitiesRequest { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let len = 0; - let struct_ser = serializer.serialize_struct("p4.v1.CapabilitiesRequest", len)?; - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for CapabilitiesRequest { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - } - 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, - { - Err(serde::de::Error::unknown_field(value, FIELDS)) - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = CapabilitiesRequest; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.CapabilitiesRequest") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - while map_.next_key::()?.is_some() { - let _ = map_.next_value::()?; - } - Ok(CapabilitiesRequest { - }) - } - } - deserializer.deserialize_struct("p4.v1.CapabilitiesRequest", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for CapabilitiesResponse { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.p4runtime_api_version.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.CapabilitiesResponse", len)?; - if !self.p4runtime_api_version.is_empty() { - struct_ser.serialize_field("p4runtimeApiVersion", &self.p4runtime_api_version)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for CapabilitiesResponse { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "p4runtime_api_version", - "p4runtimeApiVersion", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - P4runtimeApiVersion, - } - 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 { - "p4runtimeApiVersion" | "p4runtime_api_version" => Ok(GeneratedField::P4runtimeApiVersion), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = CapabilitiesResponse; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.CapabilitiesResponse") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut p4runtime_api_version__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::P4runtimeApiVersion => { - if p4runtime_api_version__.is_some() { - return Err(serde::de::Error::duplicate_field("p4runtimeApiVersion")); - } - p4runtime_api_version__ = Some(map_.next_value()?); - } - } - } - Ok(CapabilitiesResponse { - p4runtime_api_version: p4runtime_api_version__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.CapabilitiesResponse", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for CloneSessionEntry { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.session_id != 0 { - len += 1; - } - if !self.replicas.is_empty() { - len += 1; - } - if self.class_of_service != 0 { - len += 1; - } - if self.packet_length_bytes != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.CloneSessionEntry", len)?; - if self.session_id != 0 { - struct_ser.serialize_field("sessionId", &self.session_id)?; - } - if !self.replicas.is_empty() { - struct_ser.serialize_field("replicas", &self.replicas)?; - } - if self.class_of_service != 0 { - struct_ser.serialize_field("classOfService", &self.class_of_service)?; - } - if self.packet_length_bytes != 0 { - struct_ser.serialize_field("packetLengthBytes", &self.packet_length_bytes)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for CloneSessionEntry { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "session_id", - "sessionId", - "replicas", - "class_of_service", - "classOfService", - "packet_length_bytes", - "packetLengthBytes", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - SessionId, - Replicas, - ClassOfService, - PacketLengthBytes, - } - 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 { - "sessionId" | "session_id" => Ok(GeneratedField::SessionId), - "replicas" => Ok(GeneratedField::Replicas), - "classOfService" | "class_of_service" => Ok(GeneratedField::ClassOfService), - "packetLengthBytes" | "packet_length_bytes" => Ok(GeneratedField::PacketLengthBytes), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = CloneSessionEntry; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.CloneSessionEntry") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut session_id__ = None; - let mut replicas__ = None; - let mut class_of_service__ = None; - let mut packet_length_bytes__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::SessionId => { - if session_id__.is_some() { - return Err(serde::de::Error::duplicate_field("sessionId")); - } - session_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Replicas => { - if replicas__.is_some() { - return Err(serde::de::Error::duplicate_field("replicas")); - } - replicas__ = Some(map_.next_value()?); - } - GeneratedField::ClassOfService => { - if class_of_service__.is_some() { - return Err(serde::de::Error::duplicate_field("classOfService")); - } - class_of_service__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::PacketLengthBytes => { - if packet_length_bytes__.is_some() { - return Err(serde::de::Error::duplicate_field("packetLengthBytes")); - } - packet_length_bytes__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(CloneSessionEntry { - session_id: session_id__.unwrap_or_default(), - replicas: replicas__.unwrap_or_default(), - class_of_service: class_of_service__.unwrap_or_default(), - packet_length_bytes: packet_length_bytes__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.CloneSessionEntry", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for CounterData { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.byte_count != 0 { - len += 1; - } - if self.packet_count != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.CounterData", len)?; - if self.byte_count != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("byteCount", ToString::to_string(&self.byte_count).as_str())?; - } - if self.packet_count != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("packetCount", ToString::to_string(&self.packet_count).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for CounterData { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "byte_count", - "byteCount", - "packet_count", - "packetCount", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - ByteCount, - PacketCount, - } - 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 { - "byteCount" | "byte_count" => Ok(GeneratedField::ByteCount), - "packetCount" | "packet_count" => Ok(GeneratedField::PacketCount), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = CounterData; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.CounterData") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut byte_count__ = None; - let mut packet_count__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::ByteCount => { - if byte_count__.is_some() { - return Err(serde::de::Error::duplicate_field("byteCount")); - } - byte_count__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::PacketCount => { - if packet_count__.is_some() { - return Err(serde::de::Error::duplicate_field("packetCount")); - } - packet_count__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(CounterData { - byte_count: byte_count__.unwrap_or_default(), - packet_count: packet_count__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.CounterData", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for CounterEntry { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.counter_id != 0 { - len += 1; - } - if self.index.is_some() { - len += 1; - } - if self.data.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.CounterEntry", len)?; - if self.counter_id != 0 { - struct_ser.serialize_field("counterId", &self.counter_id)?; - } - if let Some(v) = self.index.as_ref() { - struct_ser.serialize_field("index", v)?; - } - if let Some(v) = self.data.as_ref() { - struct_ser.serialize_field("data", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for CounterEntry { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "counter_id", - "counterId", - "index", - "data", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - CounterId, - Index, - Data, - } - 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 { - "counterId" | "counter_id" => Ok(GeneratedField::CounterId), - "index" => Ok(GeneratedField::Index), - "data" => Ok(GeneratedField::Data), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = CounterEntry; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.CounterEntry") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut counter_id__ = None; - let mut index__ = None; - let mut data__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::CounterId => { - if counter_id__.is_some() { - return Err(serde::de::Error::duplicate_field("counterId")); - } - counter_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Index => { - if index__.is_some() { - return Err(serde::de::Error::duplicate_field("index")); - } - index__ = map_.next_value()?; - } - GeneratedField::Data => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("data")); - } - data__ = map_.next_value()?; - } - } - } - Ok(CounterEntry { - counter_id: counter_id__.unwrap_or_default(), - index: index__, - data: data__, - }) - } - } - deserializer.deserialize_struct("p4.v1.CounterEntry", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for DigestEntry { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.digest_id != 0 { - len += 1; - } - if self.config.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.DigestEntry", len)?; - if self.digest_id != 0 { - struct_ser.serialize_field("digestId", &self.digest_id)?; - } - if let Some(v) = self.config.as_ref() { - struct_ser.serialize_field("config", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for DigestEntry { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "digest_id", - "digestId", - "config", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - DigestId, - 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 { - "digestId" | "digest_id" => Ok(GeneratedField::DigestId), - "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 = DigestEntry; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.DigestEntry") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut digest_id__ = None; - let mut config__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::DigestId => { - if digest_id__.is_some() { - return Err(serde::de::Error::duplicate_field("digestId")); - } - digest_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Config => { - if config__.is_some() { - return Err(serde::de::Error::duplicate_field("config")); - } - config__ = map_.next_value()?; - } - } - } - Ok(DigestEntry { - digest_id: digest_id__.unwrap_or_default(), - config: config__, - }) - } - } - deserializer.deserialize_struct("p4.v1.DigestEntry", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for digest_entry::Config { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.max_timeout_ns != 0 { - len += 1; - } - if self.max_list_size != 0 { - len += 1; - } - if self.ack_timeout_ns != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.DigestEntry.Config", len)?; - if self.max_timeout_ns != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("maxTimeoutNs", ToString::to_string(&self.max_timeout_ns).as_str())?; - } - if self.max_list_size != 0 { - struct_ser.serialize_field("maxListSize", &self.max_list_size)?; - } - if self.ack_timeout_ns != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("ackTimeoutNs", ToString::to_string(&self.ack_timeout_ns).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for digest_entry::Config { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "max_timeout_ns", - "maxTimeoutNs", - "max_list_size", - "maxListSize", - "ack_timeout_ns", - "ackTimeoutNs", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - MaxTimeoutNs, - MaxListSize, - AckTimeoutNs, - } - 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 { - "maxTimeoutNs" | "max_timeout_ns" => Ok(GeneratedField::MaxTimeoutNs), - "maxListSize" | "max_list_size" => Ok(GeneratedField::MaxListSize), - "ackTimeoutNs" | "ack_timeout_ns" => Ok(GeneratedField::AckTimeoutNs), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = digest_entry::Config; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.DigestEntry.Config") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut max_timeout_ns__ = None; - let mut max_list_size__ = None; - let mut ack_timeout_ns__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::MaxTimeoutNs => { - if max_timeout_ns__.is_some() { - return Err(serde::de::Error::duplicate_field("maxTimeoutNs")); - } - max_timeout_ns__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::MaxListSize => { - if max_list_size__.is_some() { - return Err(serde::de::Error::duplicate_field("maxListSize")); - } - max_list_size__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::AckTimeoutNs => { - if ack_timeout_ns__.is_some() { - return Err(serde::de::Error::duplicate_field("ackTimeoutNs")); - } - ack_timeout_ns__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(digest_entry::Config { - max_timeout_ns: max_timeout_ns__.unwrap_or_default(), - max_list_size: max_list_size__.unwrap_or_default(), - ack_timeout_ns: ack_timeout_ns__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.DigestEntry.Config", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for DigestList { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.digest_id != 0 { - len += 1; - } - if self.list_id != 0 { - len += 1; - } - if !self.data.is_empty() { - len += 1; - } - if self.timestamp != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.DigestList", len)?; - if self.digest_id != 0 { - struct_ser.serialize_field("digestId", &self.digest_id)?; - } - if self.list_id != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("listId", ToString::to_string(&self.list_id).as_str())?; - } - if !self.data.is_empty() { - struct_ser.serialize_field("data", &self.data)?; - } - if self.timestamp != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("timestamp", ToString::to_string(&self.timestamp).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for DigestList { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "digest_id", - "digestId", - "list_id", - "listId", - "data", - "timestamp", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - DigestId, - ListId, - Data, - Timestamp, - } - 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 { - "digestId" | "digest_id" => Ok(GeneratedField::DigestId), - "listId" | "list_id" => Ok(GeneratedField::ListId), - "data" => Ok(GeneratedField::Data), - "timestamp" => Ok(GeneratedField::Timestamp), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = DigestList; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.DigestList") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut digest_id__ = None; - let mut list_id__ = None; - let mut data__ = None; - let mut timestamp__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::DigestId => { - if digest_id__.is_some() { - return Err(serde::de::Error::duplicate_field("digestId")); - } - digest_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::ListId => { - if list_id__.is_some() { - return Err(serde::de::Error::duplicate_field("listId")); - } - list_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Data => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("data")); - } - data__ = Some(map_.next_value()?); - } - GeneratedField::Timestamp => { - if timestamp__.is_some() { - return Err(serde::de::Error::duplicate_field("timestamp")); - } - timestamp__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(DigestList { - digest_id: digest_id__.unwrap_or_default(), - list_id: list_id__.unwrap_or_default(), - data: data__.unwrap_or_default(), - timestamp: timestamp__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.DigestList", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for DigestListAck { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.digest_id != 0 { - len += 1; - } - if self.list_id != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.DigestListAck", len)?; - if self.digest_id != 0 { - struct_ser.serialize_field("digestId", &self.digest_id)?; - } - if self.list_id != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("listId", ToString::to_string(&self.list_id).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for DigestListAck { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "digest_id", - "digestId", - "list_id", - "listId", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - DigestId, - ListId, - } - 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 { - "digestId" | "digest_id" => Ok(GeneratedField::DigestId), - "listId" | "list_id" => Ok(GeneratedField::ListId), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = DigestListAck; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.DigestListAck") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut digest_id__ = None; - let mut list_id__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::DigestId => { - if digest_id__.is_some() { - return Err(serde::de::Error::duplicate_field("digestId")); - } - digest_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::ListId => { - if list_id__.is_some() { - return Err(serde::de::Error::duplicate_field("listId")); - } - list_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(DigestListAck { - digest_id: digest_id__.unwrap_or_default(), - list_id: list_id__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.DigestListAck", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for DigestListAckError { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.digest_list_ack.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.DigestListAckError", len)?; - if let Some(v) = self.digest_list_ack.as_ref() { - struct_ser.serialize_field("digestListAck", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for DigestListAckError { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "digest_list_ack", - "digestListAck", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - DigestListAck, - } - 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 { - "digestListAck" | "digest_list_ack" => Ok(GeneratedField::DigestListAck), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = DigestListAckError; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.DigestListAckError") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut digest_list_ack__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::DigestListAck => { - if digest_list_ack__.is_some() { - return Err(serde::de::Error::duplicate_field("digestListAck")); - } - digest_list_ack__ = map_.next_value()?; - } - } - } - Ok(DigestListAckError { - digest_list_ack: digest_list_ack__, - }) - } - } - deserializer.deserialize_struct("p4.v1.DigestListAckError", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for DirectCounterEntry { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.table_entry.is_some() { - len += 1; - } - if self.data.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.DirectCounterEntry", len)?; - if let Some(v) = self.table_entry.as_ref() { - struct_ser.serialize_field("tableEntry", v)?; - } - if let Some(v) = self.data.as_ref() { - struct_ser.serialize_field("data", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for DirectCounterEntry { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "table_entry", - "tableEntry", - "data", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - TableEntry, - Data, - } - 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 { - "tableEntry" | "table_entry" => Ok(GeneratedField::TableEntry), - "data" => Ok(GeneratedField::Data), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = DirectCounterEntry; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.DirectCounterEntry") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut table_entry__ = None; - let mut data__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::TableEntry => { - if table_entry__.is_some() { - return Err(serde::de::Error::duplicate_field("tableEntry")); - } - table_entry__ = map_.next_value()?; - } - GeneratedField::Data => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("data")); - } - data__ = map_.next_value()?; - } - } - } - Ok(DirectCounterEntry { - table_entry: table_entry__, - data: data__, - }) - } - } - deserializer.deserialize_struct("p4.v1.DirectCounterEntry", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for DirectMeterEntry { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.table_entry.is_some() { - len += 1; - } - if self.config.is_some() { - len += 1; - } - if self.counter_data.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.DirectMeterEntry", len)?; - if let Some(v) = self.table_entry.as_ref() { - struct_ser.serialize_field("tableEntry", v)?; - } - if let Some(v) = self.config.as_ref() { - struct_ser.serialize_field("config", v)?; - } - if let Some(v) = self.counter_data.as_ref() { - struct_ser.serialize_field("counterData", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for DirectMeterEntry { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "table_entry", - "tableEntry", - "config", - "counter_data", - "counterData", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - TableEntry, - Config, - CounterData, - } - 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 { - "tableEntry" | "table_entry" => Ok(GeneratedField::TableEntry), - "config" => Ok(GeneratedField::Config), - "counterData" | "counter_data" => Ok(GeneratedField::CounterData), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = DirectMeterEntry; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.DirectMeterEntry") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut table_entry__ = None; - let mut config__ = None; - let mut counter_data__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::TableEntry => { - if table_entry__.is_some() { - return Err(serde::de::Error::duplicate_field("tableEntry")); - } - table_entry__ = map_.next_value()?; - } - GeneratedField::Config => { - if config__.is_some() { - return Err(serde::de::Error::duplicate_field("config")); - } - config__ = map_.next_value()?; - } - GeneratedField::CounterData => { - if counter_data__.is_some() { - return Err(serde::de::Error::duplicate_field("counterData")); - } - counter_data__ = map_.next_value()?; - } - } - } - Ok(DirectMeterEntry { - table_entry: table_entry__, - config: config__, - counter_data: counter_data__, - }) - } - } - deserializer.deserialize_struct("p4.v1.DirectMeterEntry", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Entity { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.entity.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.Entity", len)?; - if let Some(v) = self.entity.as_ref() { - match v { - entity::Entity::ExternEntry(v) => { - struct_ser.serialize_field("externEntry", v)?; - } - entity::Entity::TableEntry(v) => { - struct_ser.serialize_field("tableEntry", v)?; - } - entity::Entity::ActionProfileMember(v) => { - struct_ser.serialize_field("actionProfileMember", v)?; - } - entity::Entity::ActionProfileGroup(v) => { - struct_ser.serialize_field("actionProfileGroup", v)?; - } - entity::Entity::MeterEntry(v) => { - struct_ser.serialize_field("meterEntry", v)?; - } - entity::Entity::DirectMeterEntry(v) => { - struct_ser.serialize_field("directMeterEntry", v)?; - } - entity::Entity::CounterEntry(v) => { - struct_ser.serialize_field("counterEntry", v)?; - } - entity::Entity::DirectCounterEntry(v) => { - struct_ser.serialize_field("directCounterEntry", v)?; - } - entity::Entity::PacketReplicationEngineEntry(v) => { - struct_ser.serialize_field("packetReplicationEngineEntry", v)?; - } - entity::Entity::ValueSetEntry(v) => { - struct_ser.serialize_field("valueSetEntry", v)?; - } - entity::Entity::RegisterEntry(v) => { - struct_ser.serialize_field("registerEntry", v)?; - } - entity::Entity::DigestEntry(v) => { - struct_ser.serialize_field("digestEntry", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Entity { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "extern_entry", - "externEntry", - "table_entry", - "tableEntry", - "action_profile_member", - "actionProfileMember", - "action_profile_group", - "actionProfileGroup", - "meter_entry", - "meterEntry", - "direct_meter_entry", - "directMeterEntry", - "counter_entry", - "counterEntry", - "direct_counter_entry", - "directCounterEntry", - "packet_replication_engine_entry", - "packetReplicationEngineEntry", - "value_set_entry", - "valueSetEntry", - "register_entry", - "registerEntry", - "digest_entry", - "digestEntry", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - ExternEntry, - TableEntry, - ActionProfileMember, - ActionProfileGroup, - MeterEntry, - DirectMeterEntry, - CounterEntry, - DirectCounterEntry, - PacketReplicationEngineEntry, - ValueSetEntry, - RegisterEntry, - DigestEntry, - } - 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 { - "externEntry" | "extern_entry" => Ok(GeneratedField::ExternEntry), - "tableEntry" | "table_entry" => Ok(GeneratedField::TableEntry), - "actionProfileMember" | "action_profile_member" => Ok(GeneratedField::ActionProfileMember), - "actionProfileGroup" | "action_profile_group" => Ok(GeneratedField::ActionProfileGroup), - "meterEntry" | "meter_entry" => Ok(GeneratedField::MeterEntry), - "directMeterEntry" | "direct_meter_entry" => Ok(GeneratedField::DirectMeterEntry), - "counterEntry" | "counter_entry" => Ok(GeneratedField::CounterEntry), - "directCounterEntry" | "direct_counter_entry" => Ok(GeneratedField::DirectCounterEntry), - "packetReplicationEngineEntry" | "packet_replication_engine_entry" => Ok(GeneratedField::PacketReplicationEngineEntry), - "valueSetEntry" | "value_set_entry" => Ok(GeneratedField::ValueSetEntry), - "registerEntry" | "register_entry" => Ok(GeneratedField::RegisterEntry), - "digestEntry" | "digest_entry" => Ok(GeneratedField::DigestEntry), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Entity; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.Entity") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut entity__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::ExternEntry => { - if entity__.is_some() { - return Err(serde::de::Error::duplicate_field("externEntry")); - } - entity__ = map_.next_value::<::std::option::Option<_>>()?.map(entity::Entity::ExternEntry) -; - } - GeneratedField::TableEntry => { - if entity__.is_some() { - return Err(serde::de::Error::duplicate_field("tableEntry")); - } - entity__ = map_.next_value::<::std::option::Option<_>>()?.map(entity::Entity::TableEntry) -; - } - GeneratedField::ActionProfileMember => { - if entity__.is_some() { - return Err(serde::de::Error::duplicate_field("actionProfileMember")); - } - entity__ = map_.next_value::<::std::option::Option<_>>()?.map(entity::Entity::ActionProfileMember) -; - } - GeneratedField::ActionProfileGroup => { - if entity__.is_some() { - return Err(serde::de::Error::duplicate_field("actionProfileGroup")); - } - entity__ = map_.next_value::<::std::option::Option<_>>()?.map(entity::Entity::ActionProfileGroup) -; - } - GeneratedField::MeterEntry => { - if entity__.is_some() { - return Err(serde::de::Error::duplicate_field("meterEntry")); - } - entity__ = map_.next_value::<::std::option::Option<_>>()?.map(entity::Entity::MeterEntry) -; - } - GeneratedField::DirectMeterEntry => { - if entity__.is_some() { - return Err(serde::de::Error::duplicate_field("directMeterEntry")); - } - entity__ = map_.next_value::<::std::option::Option<_>>()?.map(entity::Entity::DirectMeterEntry) -; - } - GeneratedField::CounterEntry => { - if entity__.is_some() { - return Err(serde::de::Error::duplicate_field("counterEntry")); - } - entity__ = map_.next_value::<::std::option::Option<_>>()?.map(entity::Entity::CounterEntry) -; - } - GeneratedField::DirectCounterEntry => { - if entity__.is_some() { - return Err(serde::de::Error::duplicate_field("directCounterEntry")); - } - entity__ = map_.next_value::<::std::option::Option<_>>()?.map(entity::Entity::DirectCounterEntry) -; - } - GeneratedField::PacketReplicationEngineEntry => { - if entity__.is_some() { - return Err(serde::de::Error::duplicate_field("packetReplicationEngineEntry")); - } - entity__ = map_.next_value::<::std::option::Option<_>>()?.map(entity::Entity::PacketReplicationEngineEntry) -; - } - GeneratedField::ValueSetEntry => { - if entity__.is_some() { - return Err(serde::de::Error::duplicate_field("valueSetEntry")); - } - entity__ = map_.next_value::<::std::option::Option<_>>()?.map(entity::Entity::ValueSetEntry) -; - } - GeneratedField::RegisterEntry => { - if entity__.is_some() { - return Err(serde::de::Error::duplicate_field("registerEntry")); - } - entity__ = map_.next_value::<::std::option::Option<_>>()?.map(entity::Entity::RegisterEntry) -; - } - GeneratedField::DigestEntry => { - if entity__.is_some() { - return Err(serde::de::Error::duplicate_field("digestEntry")); - } - entity__ = map_.next_value::<::std::option::Option<_>>()?.map(entity::Entity::DigestEntry) -; - } - } - } - Ok(Entity { - entity: entity__, - }) - } - } - deserializer.deserialize_struct("p4.v1.Entity", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Error { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.canonical_code != 0 { - len += 1; - } - if !self.message.is_empty() { - len += 1; - } - if !self.space.is_empty() { - len += 1; - } - if self.code != 0 { - len += 1; - } - if self.details.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.Error", len)?; - if self.canonical_code != 0 { - struct_ser.serialize_field("canonicalCode", &self.canonical_code)?; - } - if !self.message.is_empty() { - struct_ser.serialize_field("message", &self.message)?; - } - if !self.space.is_empty() { - struct_ser.serialize_field("space", &self.space)?; - } - if self.code != 0 { - struct_ser.serialize_field("code", &self.code)?; - } - if let Some(v) = self.details.as_ref() { - struct_ser.serialize_field("details", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Error { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "canonical_code", - "canonicalCode", - "message", - "space", - "code", - "details", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - CanonicalCode, - Message, - Space, - Code, - Details, - } - 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 { - "canonicalCode" | "canonical_code" => Ok(GeneratedField::CanonicalCode), - "message" => Ok(GeneratedField::Message), - "space" => Ok(GeneratedField::Space), - "code" => Ok(GeneratedField::Code), - "details" => Ok(GeneratedField::Details), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Error; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.Error") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut canonical_code__ = None; - let mut message__ = None; - let mut space__ = None; - let mut code__ = None; - let mut details__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::CanonicalCode => { - if canonical_code__.is_some() { - return Err(serde::de::Error::duplicate_field("canonicalCode")); - } - canonical_code__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Message => { - if message__.is_some() { - return Err(serde::de::Error::duplicate_field("message")); - } - message__ = Some(map_.next_value()?); - } - GeneratedField::Space => { - if space__.is_some() { - return Err(serde::de::Error::duplicate_field("space")); - } - space__ = Some(map_.next_value()?); - } - GeneratedField::Code => { - if code__.is_some() { - return Err(serde::de::Error::duplicate_field("code")); - } - code__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Details => { - if details__.is_some() { - return Err(serde::de::Error::duplicate_field("details")); - } - details__ = map_.next_value()?; - } - } - } - Ok(Error { - canonical_code: canonical_code__.unwrap_or_default(), - message: message__.unwrap_or_default(), - space: space__.unwrap_or_default(), - code: code__.unwrap_or_default(), - details: details__, - }) - } - } - deserializer.deserialize_struct("p4.v1.Error", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ExternEntry { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.extern_type_id != 0 { - len += 1; - } - if self.extern_id != 0 { - len += 1; - } - if self.entry.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.ExternEntry", len)?; - if self.extern_type_id != 0 { - struct_ser.serialize_field("externTypeId", &self.extern_type_id)?; - } - if self.extern_id != 0 { - struct_ser.serialize_field("externId", &self.extern_id)?; - } - if let Some(v) = self.entry.as_ref() { - struct_ser.serialize_field("entry", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ExternEntry { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "extern_type_id", - "externTypeId", - "extern_id", - "externId", - "entry", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - ExternTypeId, - ExternId, - Entry, - } - 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 { - "externTypeId" | "extern_type_id" => Ok(GeneratedField::ExternTypeId), - "externId" | "extern_id" => Ok(GeneratedField::ExternId), - "entry" => Ok(GeneratedField::Entry), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ExternEntry; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.ExternEntry") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut extern_type_id__ = None; - let mut extern_id__ = None; - let mut entry__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::ExternTypeId => { - if extern_type_id__.is_some() { - return Err(serde::de::Error::duplicate_field("externTypeId")); - } - extern_type_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::ExternId => { - if extern_id__.is_some() { - return Err(serde::de::Error::duplicate_field("externId")); - } - extern_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Entry => { - if entry__.is_some() { - return Err(serde::de::Error::duplicate_field("entry")); - } - entry__ = map_.next_value()?; - } - } - } - Ok(ExternEntry { - extern_type_id: extern_type_id__.unwrap_or_default(), - extern_id: extern_id__.unwrap_or_default(), - entry: entry__, - }) - } - } - deserializer.deserialize_struct("p4.v1.ExternEntry", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for FieldMatch { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.field_id != 0 { - len += 1; - } - if self.field_match_type.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.FieldMatch", len)?; - if self.field_id != 0 { - struct_ser.serialize_field("fieldId", &self.field_id)?; - } - if let Some(v) = self.field_match_type.as_ref() { - match v { - field_match::FieldMatchType::Exact(v) => { - struct_ser.serialize_field("exact", v)?; - } - field_match::FieldMatchType::Ternary(v) => { - struct_ser.serialize_field("ternary", v)?; - } - field_match::FieldMatchType::Lpm(v) => { - struct_ser.serialize_field("lpm", v)?; - } - field_match::FieldMatchType::Range(v) => { - struct_ser.serialize_field("range", v)?; - } - field_match::FieldMatchType::Optional(v) => { - struct_ser.serialize_field("optional", v)?; - } - field_match::FieldMatchType::Other(v) => { - struct_ser.serialize_field("other", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for FieldMatch { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "field_id", - "fieldId", - "exact", - "ternary", - "lpm", - "range", - "optional", - "other", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - FieldId, - Exact, - Ternary, - Lpm, - Range, - Optional, - Other, - } - 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 { - "fieldId" | "field_id" => Ok(GeneratedField::FieldId), - "exact" => Ok(GeneratedField::Exact), - "ternary" => Ok(GeneratedField::Ternary), - "lpm" => Ok(GeneratedField::Lpm), - "range" => Ok(GeneratedField::Range), - "optional" => Ok(GeneratedField::Optional), - "other" => Ok(GeneratedField::Other), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = FieldMatch; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.FieldMatch") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut field_id__ = None; - let mut field_match_type__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::FieldId => { - if field_id__.is_some() { - return Err(serde::de::Error::duplicate_field("fieldId")); - } - field_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Exact => { - if field_match_type__.is_some() { - return Err(serde::de::Error::duplicate_field("exact")); - } - field_match_type__ = map_.next_value::<::std::option::Option<_>>()?.map(field_match::FieldMatchType::Exact) -; - } - GeneratedField::Ternary => { - if field_match_type__.is_some() { - return Err(serde::de::Error::duplicate_field("ternary")); - } - field_match_type__ = map_.next_value::<::std::option::Option<_>>()?.map(field_match::FieldMatchType::Ternary) -; - } - GeneratedField::Lpm => { - if field_match_type__.is_some() { - return Err(serde::de::Error::duplicate_field("lpm")); - } - field_match_type__ = map_.next_value::<::std::option::Option<_>>()?.map(field_match::FieldMatchType::Lpm) -; - } - GeneratedField::Range => { - if field_match_type__.is_some() { - return Err(serde::de::Error::duplicate_field("range")); - } - field_match_type__ = map_.next_value::<::std::option::Option<_>>()?.map(field_match::FieldMatchType::Range) -; - } - GeneratedField::Optional => { - if field_match_type__.is_some() { - return Err(serde::de::Error::duplicate_field("optional")); - } - field_match_type__ = map_.next_value::<::std::option::Option<_>>()?.map(field_match::FieldMatchType::Optional) -; - } - GeneratedField::Other => { - if field_match_type__.is_some() { - return Err(serde::de::Error::duplicate_field("other")); - } - field_match_type__ = map_.next_value::<::std::option::Option<_>>()?.map(field_match::FieldMatchType::Other) -; - } - } - } - Ok(FieldMatch { - field_id: field_id__.unwrap_or_default(), - field_match_type: field_match_type__, - }) - } - } - deserializer.deserialize_struct("p4.v1.FieldMatch", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for field_match::Exact { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.value.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.FieldMatch.Exact", len)?; - if !self.value.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("value", pbjson::private::base64::encode(&self.value).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for field_match::Exact { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "value", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Value, - } - 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 { - "value" => Ok(GeneratedField::Value), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = field_match::Exact; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.FieldMatch.Exact") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut value__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Value => { - if value__.is_some() { - return Err(serde::de::Error::duplicate_field("value")); - } - value__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - } - } - Ok(field_match::Exact { - value: value__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.FieldMatch.Exact", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for field_match::Lpm { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.value.is_empty() { - len += 1; - } - if self.prefix_len != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.FieldMatch.LPM", len)?; - if !self.value.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("value", pbjson::private::base64::encode(&self.value).as_str())?; - } - if self.prefix_len != 0 { - struct_ser.serialize_field("prefixLen", &self.prefix_len)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for field_match::Lpm { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "value", - "prefix_len", - "prefixLen", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Value, - PrefixLen, - } - 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 { - "value" => Ok(GeneratedField::Value), - "prefixLen" | "prefix_len" => Ok(GeneratedField::PrefixLen), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = field_match::Lpm; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.FieldMatch.LPM") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut value__ = None; - let mut prefix_len__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Value => { - if value__.is_some() { - return Err(serde::de::Error::duplicate_field("value")); - } - value__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::PrefixLen => { - if prefix_len__.is_some() { - return Err(serde::de::Error::duplicate_field("prefixLen")); - } - prefix_len__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(field_match::Lpm { - value: value__.unwrap_or_default(), - prefix_len: prefix_len__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.FieldMatch.LPM", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for field_match::Optional { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.value.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.FieldMatch.Optional", len)?; - if !self.value.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("value", pbjson::private::base64::encode(&self.value).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for field_match::Optional { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "value", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Value, - } - 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 { - "value" => Ok(GeneratedField::Value), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = field_match::Optional; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.FieldMatch.Optional") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut value__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Value => { - if value__.is_some() { - return Err(serde::de::Error::duplicate_field("value")); - } - value__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - } - } - Ok(field_match::Optional { - value: value__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.FieldMatch.Optional", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for field_match::Range { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.low.is_empty() { - len += 1; - } - if !self.high.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.FieldMatch.Range", len)?; - if !self.low.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("low", pbjson::private::base64::encode(&self.low).as_str())?; - } - if !self.high.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("high", pbjson::private::base64::encode(&self.high).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for field_match::Range { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "low", - "high", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Low, - High, - } - 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 { - "low" => Ok(GeneratedField::Low), - "high" => Ok(GeneratedField::High), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = field_match::Range; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.FieldMatch.Range") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut low__ = None; - let mut high__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Low => { - if low__.is_some() { - return Err(serde::de::Error::duplicate_field("low")); - } - low__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::High => { - if high__.is_some() { - return Err(serde::de::Error::duplicate_field("high")); - } - high__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - } - } - Ok(field_match::Range { - low: low__.unwrap_or_default(), - high: high__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.FieldMatch.Range", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for field_match::Ternary { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.value.is_empty() { - len += 1; - } - if !self.mask.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.FieldMatch.Ternary", len)?; - if !self.value.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("value", pbjson::private::base64::encode(&self.value).as_str())?; - } - if !self.mask.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("mask", pbjson::private::base64::encode(&self.mask).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for field_match::Ternary { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "value", - "mask", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Value, - Mask, - } - 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 { - "value" => Ok(GeneratedField::Value), - "mask" => Ok(GeneratedField::Mask), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = field_match::Ternary; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.FieldMatch.Ternary") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut value__ = None; - let mut mask__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Value => { - if value__.is_some() { - return Err(serde::de::Error::duplicate_field("value")); - } - value__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::Mask => { - if mask__.is_some() { - return Err(serde::de::Error::duplicate_field("mask")); - } - mask__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - } - } - Ok(field_match::Ternary { - value: value__.unwrap_or_default(), - mask: mask__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.FieldMatch.Ternary", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ForwardingPipelineConfig { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.p4info.is_some() { - len += 1; - } - if !self.p4_device_config.is_empty() { - len += 1; - } - if self.cookie.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.ForwardingPipelineConfig", len)?; - if let Some(v) = self.p4info.as_ref() { - struct_ser.serialize_field("p4info", v)?; - } - if !self.p4_device_config.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("p4DeviceConfig", pbjson::private::base64::encode(&self.p4_device_config).as_str())?; - } - if let Some(v) = self.cookie.as_ref() { - struct_ser.serialize_field("cookie", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ForwardingPipelineConfig { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "p4info", - "p4_device_config", - "p4DeviceConfig", - "cookie", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - P4info, - P4DeviceConfig, - Cookie, - } - 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 { - "p4info" => Ok(GeneratedField::P4info), - "p4DeviceConfig" | "p4_device_config" => Ok(GeneratedField::P4DeviceConfig), - "cookie" => Ok(GeneratedField::Cookie), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ForwardingPipelineConfig; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.ForwardingPipelineConfig") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut p4info__ = None; - let mut p4_device_config__ = None; - let mut cookie__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::P4info => { - if p4info__.is_some() { - return Err(serde::de::Error::duplicate_field("p4info")); - } - p4info__ = map_.next_value()?; - } - GeneratedField::P4DeviceConfig => { - if p4_device_config__.is_some() { - return Err(serde::de::Error::duplicate_field("p4DeviceConfig")); - } - p4_device_config__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::Cookie => { - if cookie__.is_some() { - return Err(serde::de::Error::duplicate_field("cookie")); - } - cookie__ = map_.next_value()?; - } - } - } - Ok(ForwardingPipelineConfig { - p4info: p4info__, - p4_device_config: p4_device_config__.unwrap_or_default(), - cookie: cookie__, - }) - } - } - deserializer.deserialize_struct("p4.v1.ForwardingPipelineConfig", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for forwarding_pipeline_config::Cookie { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.cookie != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.ForwardingPipelineConfig.Cookie", len)?; - if self.cookie != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("cookie", ToString::to_string(&self.cookie).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for forwarding_pipeline_config::Cookie { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "cookie", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Cookie, - } - 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 { - "cookie" => Ok(GeneratedField::Cookie), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = forwarding_pipeline_config::Cookie; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.ForwardingPipelineConfig.Cookie") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut cookie__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Cookie => { - if cookie__.is_some() { - return Err(serde::de::Error::duplicate_field("cookie")); - } - cookie__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(forwarding_pipeline_config::Cookie { - cookie: cookie__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.ForwardingPipelineConfig.Cookie", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for GetForwardingPipelineConfigRequest { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.device_id != 0 { - len += 1; - } - if self.response_type != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.GetForwardingPipelineConfigRequest", len)?; - if self.device_id != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("deviceId", ToString::to_string(&self.device_id).as_str())?; - } - if self.response_type != 0 { - let v = get_forwarding_pipeline_config_request::ResponseType::try_from(self.response_type) - .map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.response_type)))?; - struct_ser.serialize_field("responseType", &v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for GetForwardingPipelineConfigRequest { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "device_id", - "deviceId", - "response_type", - "responseType", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - DeviceId, - ResponseType, - } - 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 { - "deviceId" | "device_id" => Ok(GeneratedField::DeviceId), - "responseType" | "response_type" => Ok(GeneratedField::ResponseType), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = GetForwardingPipelineConfigRequest; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.GetForwardingPipelineConfigRequest") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut device_id__ = None; - let mut response_type__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::DeviceId => { - if device_id__.is_some() { - return Err(serde::de::Error::duplicate_field("deviceId")); - } - device_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::ResponseType => { - if response_type__.is_some() { - return Err(serde::de::Error::duplicate_field("responseType")); - } - response_type__ = Some(map_.next_value::()? as i32); - } - } - } - Ok(GetForwardingPipelineConfigRequest { - device_id: device_id__.unwrap_or_default(), - response_type: response_type__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.GetForwardingPipelineConfigRequest", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for get_forwarding_pipeline_config_request::ResponseType { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - let variant = match self { - Self::All => "ALL", - Self::CookieOnly => "COOKIE_ONLY", - Self::P4infoAndCookie => "P4INFO_AND_COOKIE", - Self::DeviceConfigAndCookie => "DEVICE_CONFIG_AND_COOKIE", - }; - serializer.serialize_str(variant) - } -} -impl<'de> serde::Deserialize<'de> for get_forwarding_pipeline_config_request::ResponseType { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "ALL", - "COOKIE_ONLY", - "P4INFO_AND_COOKIE", - "DEVICE_CONFIG_AND_COOKIE", - ]; - - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = get_forwarding_pipeline_config_request::ResponseType; - - 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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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 { - "ALL" => Ok(get_forwarding_pipeline_config_request::ResponseType::All), - "COOKIE_ONLY" => Ok(get_forwarding_pipeline_config_request::ResponseType::CookieOnly), - "P4INFO_AND_COOKIE" => Ok(get_forwarding_pipeline_config_request::ResponseType::P4infoAndCookie), - "DEVICE_CONFIG_AND_COOKIE" => Ok(get_forwarding_pipeline_config_request::ResponseType::DeviceConfigAndCookie), - _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), - } - } - } - deserializer.deserialize_any(GeneratedVisitor) - } -} -impl serde::Serialize for GetForwardingPipelineConfigResponse { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.config.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.GetForwardingPipelineConfigResponse", len)?; - if let Some(v) = self.config.as_ref() { - struct_ser.serialize_field("config", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for GetForwardingPipelineConfigResponse { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "config", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - 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 { - "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 = GetForwardingPipelineConfigResponse; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.GetForwardingPipelineConfigResponse") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut config__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Config => { - if config__.is_some() { - return Err(serde::de::Error::duplicate_field("config")); - } - config__ = map_.next_value()?; - } - } - } - Ok(GetForwardingPipelineConfigResponse { - config: config__, - }) - } - } - deserializer.deserialize_struct("p4.v1.GetForwardingPipelineConfigResponse", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for IdleTimeoutNotification { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.table_entry.is_empty() { - len += 1; - } - if self.timestamp != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.IdleTimeoutNotification", len)?; - if !self.table_entry.is_empty() { - struct_ser.serialize_field("tableEntry", &self.table_entry)?; - } - if self.timestamp != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("timestamp", ToString::to_string(&self.timestamp).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for IdleTimeoutNotification { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "table_entry", - "tableEntry", - "timestamp", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - TableEntry, - Timestamp, - } - 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 { - "tableEntry" | "table_entry" => Ok(GeneratedField::TableEntry), - "timestamp" => Ok(GeneratedField::Timestamp), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = IdleTimeoutNotification; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.IdleTimeoutNotification") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut table_entry__ = None; - let mut timestamp__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::TableEntry => { - if table_entry__.is_some() { - return Err(serde::de::Error::duplicate_field("tableEntry")); - } - table_entry__ = Some(map_.next_value()?); - } - GeneratedField::Timestamp => { - if timestamp__.is_some() { - return Err(serde::de::Error::duplicate_field("timestamp")); - } - timestamp__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(IdleTimeoutNotification { - table_entry: table_entry__.unwrap_or_default(), - timestamp: timestamp__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.IdleTimeoutNotification", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Index { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.index != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.Index", len)?; - if self.index != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("index", ToString::to_string(&self.index).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Index { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "index", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Index, - } - 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 { - "index" => Ok(GeneratedField::Index), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Index; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.Index") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut index__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Index => { - if index__.is_some() { - return Err(serde::de::Error::duplicate_field("index")); - } - index__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(Index { - index: index__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.Index", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for MasterArbitrationUpdate { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.device_id != 0 { - len += 1; - } - if self.role.is_some() { - len += 1; - } - if self.election_id.is_some() { - len += 1; - } - if self.status.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.MasterArbitrationUpdate", len)?; - if self.device_id != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("deviceId", ToString::to_string(&self.device_id).as_str())?; - } - if let Some(v) = self.role.as_ref() { - struct_ser.serialize_field("role", v)?; - } - if let Some(v) = self.election_id.as_ref() { - struct_ser.serialize_field("electionId", v)?; - } - if let Some(v) = self.status.as_ref() { - struct_ser.serialize_field("status", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for MasterArbitrationUpdate { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "device_id", - "deviceId", - "role", - "election_id", - "electionId", - "status", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - DeviceId, - Role, - ElectionId, - Status, - } - 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 { - "deviceId" | "device_id" => Ok(GeneratedField::DeviceId), - "role" => Ok(GeneratedField::Role), - "electionId" | "election_id" => Ok(GeneratedField::ElectionId), - "status" => Ok(GeneratedField::Status), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = MasterArbitrationUpdate; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.MasterArbitrationUpdate") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut device_id__ = None; - let mut role__ = None; - let mut election_id__ = None; - let mut status__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::DeviceId => { - if device_id__.is_some() { - return Err(serde::de::Error::duplicate_field("deviceId")); - } - device_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Role => { - if role__.is_some() { - return Err(serde::de::Error::duplicate_field("role")); - } - role__ = map_.next_value()?; - } - GeneratedField::ElectionId => { - if election_id__.is_some() { - return Err(serde::de::Error::duplicate_field("electionId")); - } - election_id__ = map_.next_value()?; - } - GeneratedField::Status => { - if status__.is_some() { - return Err(serde::de::Error::duplicate_field("status")); - } - status__ = map_.next_value()?; - } - } - } - Ok(MasterArbitrationUpdate { - device_id: device_id__.unwrap_or_default(), - role: role__, - election_id: election_id__, - status: status__, - }) - } - } - deserializer.deserialize_struct("p4.v1.MasterArbitrationUpdate", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for MeterConfig { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.cir != 0 { - len += 1; - } - if self.cburst != 0 { - len += 1; - } - if self.pir != 0 { - len += 1; - } - if self.pburst != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.MeterConfig", len)?; - if self.cir != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("cir", ToString::to_string(&self.cir).as_str())?; - } - if self.cburst != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("cburst", ToString::to_string(&self.cburst).as_str())?; - } - if self.pir != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("pir", ToString::to_string(&self.pir).as_str())?; - } - if self.pburst != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("pburst", ToString::to_string(&self.pburst).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for MeterConfig { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "cir", - "cburst", - "pir", - "pburst", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Cir, - Cburst, - Pir, - Pburst, - } - 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 { - "cir" => Ok(GeneratedField::Cir), - "cburst" => Ok(GeneratedField::Cburst), - "pir" => Ok(GeneratedField::Pir), - "pburst" => Ok(GeneratedField::Pburst), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = MeterConfig; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.MeterConfig") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut cir__ = None; - let mut cburst__ = None; - let mut pir__ = None; - let mut pburst__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Cir => { - if cir__.is_some() { - return Err(serde::de::Error::duplicate_field("cir")); - } - cir__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Cburst => { - if cburst__.is_some() { - return Err(serde::de::Error::duplicate_field("cburst")); - } - cburst__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Pir => { - if pir__.is_some() { - return Err(serde::de::Error::duplicate_field("pir")); - } - pir__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Pburst => { - if pburst__.is_some() { - return Err(serde::de::Error::duplicate_field("pburst")); - } - pburst__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(MeterConfig { - cir: cir__.unwrap_or_default(), - cburst: cburst__.unwrap_or_default(), - pir: pir__.unwrap_or_default(), - pburst: pburst__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.MeterConfig", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for MeterCounterData { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.green.is_some() { - len += 1; - } - if self.yellow.is_some() { - len += 1; - } - if self.red.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.MeterCounterData", len)?; - if let Some(v) = self.green.as_ref() { - struct_ser.serialize_field("green", v)?; - } - if let Some(v) = self.yellow.as_ref() { - struct_ser.serialize_field("yellow", v)?; - } - if let Some(v) = self.red.as_ref() { - struct_ser.serialize_field("red", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for MeterCounterData { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "green", - "yellow", - "red", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Green, - Yellow, - Red, - } - 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 { - "green" => Ok(GeneratedField::Green), - "yellow" => Ok(GeneratedField::Yellow), - "red" => Ok(GeneratedField::Red), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = MeterCounterData; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.MeterCounterData") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut green__ = None; - let mut yellow__ = None; - let mut red__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Green => { - if green__.is_some() { - return Err(serde::de::Error::duplicate_field("green")); - } - green__ = map_.next_value()?; - } - GeneratedField::Yellow => { - if yellow__.is_some() { - return Err(serde::de::Error::duplicate_field("yellow")); - } - yellow__ = map_.next_value()?; - } - GeneratedField::Red => { - if red__.is_some() { - return Err(serde::de::Error::duplicate_field("red")); - } - red__ = map_.next_value()?; - } - } - } - Ok(MeterCounterData { - green: green__, - yellow: yellow__, - red: red__, - }) - } - } - deserializer.deserialize_struct("p4.v1.MeterCounterData", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for MeterEntry { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.meter_id != 0 { - len += 1; - } - if self.index.is_some() { - len += 1; - } - if self.config.is_some() { - len += 1; - } - if self.counter_data.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.MeterEntry", len)?; - if self.meter_id != 0 { - struct_ser.serialize_field("meterId", &self.meter_id)?; - } - if let Some(v) = self.index.as_ref() { - struct_ser.serialize_field("index", v)?; - } - if let Some(v) = self.config.as_ref() { - struct_ser.serialize_field("config", v)?; - } - if let Some(v) = self.counter_data.as_ref() { - struct_ser.serialize_field("counterData", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for MeterEntry { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "meter_id", - "meterId", - "index", - "config", - "counter_data", - "counterData", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - MeterId, - Index, - Config, - CounterData, - } - 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 { - "meterId" | "meter_id" => Ok(GeneratedField::MeterId), - "index" => Ok(GeneratedField::Index), - "config" => Ok(GeneratedField::Config), - "counterData" | "counter_data" => Ok(GeneratedField::CounterData), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = MeterEntry; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.MeterEntry") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut meter_id__ = None; - let mut index__ = None; - let mut config__ = None; - let mut counter_data__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::MeterId => { - if meter_id__.is_some() { - return Err(serde::de::Error::duplicate_field("meterId")); - } - meter_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Index => { - if index__.is_some() { - return Err(serde::de::Error::duplicate_field("index")); - } - index__ = map_.next_value()?; - } - GeneratedField::Config => { - if config__.is_some() { - return Err(serde::de::Error::duplicate_field("config")); - } - config__ = map_.next_value()?; - } - GeneratedField::CounterData => { - if counter_data__.is_some() { - return Err(serde::de::Error::duplicate_field("counterData")); - } - counter_data__ = map_.next_value()?; - } - } - } - Ok(MeterEntry { - meter_id: meter_id__.unwrap_or_default(), - index: index__, - config: config__, - counter_data: counter_data__, - }) - } - } - deserializer.deserialize_struct("p4.v1.MeterEntry", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for MulticastGroupEntry { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.multicast_group_id != 0 { - len += 1; - } - if !self.replicas.is_empty() { - len += 1; - } - if !self.metadata.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.MulticastGroupEntry", len)?; - if self.multicast_group_id != 0 { - struct_ser.serialize_field("multicastGroupId", &self.multicast_group_id)?; - } - if !self.replicas.is_empty() { - struct_ser.serialize_field("replicas", &self.replicas)?; - } - if !self.metadata.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("metadata", pbjson::private::base64::encode(&self.metadata).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for MulticastGroupEntry { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "multicast_group_id", - "multicastGroupId", - "replicas", - "metadata", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - MulticastGroupId, - Replicas, - Metadata, - } - 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 { - "multicastGroupId" | "multicast_group_id" => Ok(GeneratedField::MulticastGroupId), - "replicas" => Ok(GeneratedField::Replicas), - "metadata" => Ok(GeneratedField::Metadata), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = MulticastGroupEntry; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.MulticastGroupEntry") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut multicast_group_id__ = None; - let mut replicas__ = None; - let mut metadata__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::MulticastGroupId => { - if multicast_group_id__.is_some() { - return Err(serde::de::Error::duplicate_field("multicastGroupId")); - } - multicast_group_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Replicas => { - if replicas__.is_some() { - return Err(serde::de::Error::duplicate_field("replicas")); - } - replicas__ = Some(map_.next_value()?); - } - GeneratedField::Metadata => { - if metadata__.is_some() { - return Err(serde::de::Error::duplicate_field("metadata")); - } - metadata__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - } - } - Ok(MulticastGroupEntry { - multicast_group_id: multicast_group_id__.unwrap_or_default(), - replicas: replicas__.unwrap_or_default(), - metadata: metadata__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.MulticastGroupEntry", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4Data { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.data.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.P4Data", len)?; - if let Some(v) = self.data.as_ref() { - match v { - p4_data::Data::Bitstring(v) => { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("bitstring", pbjson::private::base64::encode(&v).as_str())?; - } - p4_data::Data::Varbit(v) => { - struct_ser.serialize_field("varbit", v)?; - } - p4_data::Data::Bool(v) => { - struct_ser.serialize_field("bool", v)?; - } - p4_data::Data::Tuple(v) => { - struct_ser.serialize_field("tuple", v)?; - } - p4_data::Data::Struct(v) => { - struct_ser.serialize_field("struct", v)?; - } - p4_data::Data::Header(v) => { - struct_ser.serialize_field("header", v)?; - } - p4_data::Data::HeaderUnion(v) => { - struct_ser.serialize_field("headerUnion", v)?; - } - p4_data::Data::HeaderStack(v) => { - struct_ser.serialize_field("headerStack", v)?; - } - p4_data::Data::HeaderUnionStack(v) => { - struct_ser.serialize_field("headerUnionStack", v)?; - } - p4_data::Data::Enum(v) => { - struct_ser.serialize_field("enum", v)?; - } - p4_data::Data::Error(v) => { - struct_ser.serialize_field("error", v)?; - } - p4_data::Data::EnumValue(v) => { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("enumValue", pbjson::private::base64::encode(&v).as_str())?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4Data { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "bitstring", - "varbit", - "bool", - "tuple", - "struct", - "header", - "header_union", - "headerUnion", - "header_stack", - "headerStack", - "header_union_stack", - "headerUnionStack", - "enum", - "error", - "enum_value", - "enumValue", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Bitstring, - Varbit, - Bool, - Tuple, - Struct, - Header, - HeaderUnion, - HeaderStack, - HeaderUnionStack, - Enum, - Error, - EnumValue, - } - 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 { - "bitstring" => Ok(GeneratedField::Bitstring), - "varbit" => Ok(GeneratedField::Varbit), - "bool" => Ok(GeneratedField::Bool), - "tuple" => Ok(GeneratedField::Tuple), - "struct" => Ok(GeneratedField::Struct), - "header" => Ok(GeneratedField::Header), - "headerUnion" | "header_union" => Ok(GeneratedField::HeaderUnion), - "headerStack" | "header_stack" => Ok(GeneratedField::HeaderStack), - "headerUnionStack" | "header_union_stack" => Ok(GeneratedField::HeaderUnionStack), - "enum" => Ok(GeneratedField::Enum), - "error" => Ok(GeneratedField::Error), - "enumValue" | "enum_value" => Ok(GeneratedField::EnumValue), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4Data; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.P4Data") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut data__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Bitstring => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("bitstring")); - } - data__ = map_.next_value::<::std::option::Option<::pbjson::private::BytesDeserialize<_>>>()?.map(|x| p4_data::Data::Bitstring(x.0)); - } - GeneratedField::Varbit => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("varbit")); - } - data__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data::Data::Varbit) -; - } - GeneratedField::Bool => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("bool")); - } - data__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data::Data::Bool); - } - GeneratedField::Tuple => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("tuple")); - } - data__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data::Data::Tuple) -; - } - GeneratedField::Struct => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("struct")); - } - data__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data::Data::Struct) -; - } - GeneratedField::Header => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("header")); - } - data__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data::Data::Header) -; - } - GeneratedField::HeaderUnion => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("headerUnion")); - } - data__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data::Data::HeaderUnion) -; - } - GeneratedField::HeaderStack => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("headerStack")); - } - data__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data::Data::HeaderStack) -; - } - GeneratedField::HeaderUnionStack => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("headerUnionStack")); - } - data__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data::Data::HeaderUnionStack) -; - } - GeneratedField::Enum => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("enum")); - } - data__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data::Data::Enum); - } - GeneratedField::Error => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("error")); - } - data__ = map_.next_value::<::std::option::Option<_>>()?.map(p4_data::Data::Error); - } - GeneratedField::EnumValue => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("enumValue")); - } - data__ = map_.next_value::<::std::option::Option<::pbjson::private::BytesDeserialize<_>>>()?.map(|x| p4_data::Data::EnumValue(x.0)); - } - } - } - Ok(P4Data { - data: data__, - }) - } - } - deserializer.deserialize_struct("p4.v1.P4Data", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4Header { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.is_valid { - len += 1; - } - if !self.bitstrings.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.P4Header", len)?; - if self.is_valid { - struct_ser.serialize_field("isValid", &self.is_valid)?; - } - if !self.bitstrings.is_empty() { - struct_ser.serialize_field("bitstrings", &self.bitstrings.iter().map(pbjson::private::base64::encode).collect::>())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4Header { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "is_valid", - "isValid", - "bitstrings", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - IsValid, - Bitstrings, - } - 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 { - "isValid" | "is_valid" => Ok(GeneratedField::IsValid), - "bitstrings" => Ok(GeneratedField::Bitstrings), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4Header; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.P4Header") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut is_valid__ = None; - let mut bitstrings__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::IsValid => { - if is_valid__.is_some() { - return Err(serde::de::Error::duplicate_field("isValid")); - } - is_valid__ = Some(map_.next_value()?); - } - GeneratedField::Bitstrings => { - if bitstrings__.is_some() { - return Err(serde::de::Error::duplicate_field("bitstrings")); - } - bitstrings__ = - Some(map_.next_value::>>()? - .into_iter().map(|x| x.0).collect()) - ; - } - } - } - Ok(P4Header { - is_valid: is_valid__.unwrap_or_default(), - bitstrings: bitstrings__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.P4Header", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4HeaderStack { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.entries.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.P4HeaderStack", len)?; - if !self.entries.is_empty() { - struct_ser.serialize_field("entries", &self.entries)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4HeaderStack { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "entries", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Entries, - } - 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 { - "entries" => Ok(GeneratedField::Entries), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4HeaderStack; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.P4HeaderStack") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut entries__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Entries => { - if entries__.is_some() { - return Err(serde::de::Error::duplicate_field("entries")); - } - entries__ = Some(map_.next_value()?); - } - } - } - Ok(P4HeaderStack { - entries: entries__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.P4HeaderStack", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4HeaderUnion { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.valid_header_name.is_empty() { - len += 1; - } - if self.valid_header.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.P4HeaderUnion", len)?; - if !self.valid_header_name.is_empty() { - struct_ser.serialize_field("validHeaderName", &self.valid_header_name)?; - } - if let Some(v) = self.valid_header.as_ref() { - struct_ser.serialize_field("validHeader", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4HeaderUnion { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "valid_header_name", - "validHeaderName", - "valid_header", - "validHeader", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - ValidHeaderName, - ValidHeader, - } - 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 { - "validHeaderName" | "valid_header_name" => Ok(GeneratedField::ValidHeaderName), - "validHeader" | "valid_header" => Ok(GeneratedField::ValidHeader), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4HeaderUnion; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.P4HeaderUnion") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut valid_header_name__ = None; - let mut valid_header__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::ValidHeaderName => { - if valid_header_name__.is_some() { - return Err(serde::de::Error::duplicate_field("validHeaderName")); - } - valid_header_name__ = Some(map_.next_value()?); - } - GeneratedField::ValidHeader => { - if valid_header__.is_some() { - return Err(serde::de::Error::duplicate_field("validHeader")); - } - valid_header__ = map_.next_value()?; - } - } - } - Ok(P4HeaderUnion { - valid_header_name: valid_header_name__.unwrap_or_default(), - valid_header: valid_header__, - }) - } - } - deserializer.deserialize_struct("p4.v1.P4HeaderUnion", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4HeaderUnionStack { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.entries.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.P4HeaderUnionStack", len)?; - if !self.entries.is_empty() { - struct_ser.serialize_field("entries", &self.entries)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4HeaderUnionStack { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "entries", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Entries, - } - 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 { - "entries" => Ok(GeneratedField::Entries), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4HeaderUnionStack; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.P4HeaderUnionStack") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut entries__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Entries => { - if entries__.is_some() { - return Err(serde::de::Error::duplicate_field("entries")); - } - entries__ = Some(map_.next_value()?); - } - } - } - Ok(P4HeaderUnionStack { - entries: entries__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.P4HeaderUnionStack", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4StructLike { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.members.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.P4StructLike", len)?; - if !self.members.is_empty() { - struct_ser.serialize_field("members", &self.members)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4StructLike { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "members", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Members, - } - 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 { - "members" => Ok(GeneratedField::Members), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4StructLike; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.P4StructLike") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut members__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Members => { - if members__.is_some() { - return Err(serde::de::Error::duplicate_field("members")); - } - members__ = Some(map_.next_value()?); - } - } - } - Ok(P4StructLike { - members: members__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.P4StructLike", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for P4Varbit { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.bitstring.is_empty() { - len += 1; - } - if self.bitwidth != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.P4Varbit", len)?; - if !self.bitstring.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("bitstring", pbjson::private::base64::encode(&self.bitstring).as_str())?; - } - if self.bitwidth != 0 { - struct_ser.serialize_field("bitwidth", &self.bitwidth)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for P4Varbit { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "bitstring", - "bitwidth", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Bitstring, - Bitwidth, - } - 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 { - "bitstring" => Ok(GeneratedField::Bitstring), - "bitwidth" => Ok(GeneratedField::Bitwidth), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = P4Varbit; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.P4Varbit") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut bitstring__ = None; - let mut bitwidth__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Bitstring => { - if bitstring__.is_some() { - return Err(serde::de::Error::duplicate_field("bitstring")); - } - bitstring__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::Bitwidth => { - if bitwidth__.is_some() { - return Err(serde::de::Error::duplicate_field("bitwidth")); - } - bitwidth__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(P4Varbit { - bitstring: bitstring__.unwrap_or_default(), - bitwidth: bitwidth__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.P4Varbit", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for PacketIn { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.payload.is_empty() { - len += 1; - } - if !self.metadata.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.PacketIn", len)?; - if !self.payload.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("payload", pbjson::private::base64::encode(&self.payload).as_str())?; - } - if !self.metadata.is_empty() { - struct_ser.serialize_field("metadata", &self.metadata)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for PacketIn { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "payload", - "metadata", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Payload, - Metadata, - } - 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 { - "payload" => Ok(GeneratedField::Payload), - "metadata" => Ok(GeneratedField::Metadata), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = PacketIn; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.PacketIn") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut payload__ = None; - let mut metadata__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Payload => { - if payload__.is_some() { - return Err(serde::de::Error::duplicate_field("payload")); - } - payload__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::Metadata => { - if metadata__.is_some() { - return Err(serde::de::Error::duplicate_field("metadata")); - } - metadata__ = Some(map_.next_value()?); - } - } - } - Ok(PacketIn { - payload: payload__.unwrap_or_default(), - metadata: metadata__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.PacketIn", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for PacketMetadata { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.metadata_id != 0 { - len += 1; - } - if !self.value.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.PacketMetadata", len)?; - if self.metadata_id != 0 { - struct_ser.serialize_field("metadataId", &self.metadata_id)?; - } - if !self.value.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("value", pbjson::private::base64::encode(&self.value).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for PacketMetadata { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "metadata_id", - "metadataId", - "value", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - MetadataId, - Value, - } - 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 { - "metadataId" | "metadata_id" => Ok(GeneratedField::MetadataId), - "value" => Ok(GeneratedField::Value), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = PacketMetadata; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.PacketMetadata") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut metadata_id__ = None; - let mut value__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::MetadataId => { - if metadata_id__.is_some() { - return Err(serde::de::Error::duplicate_field("metadataId")); - } - metadata_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Value => { - if value__.is_some() { - return Err(serde::de::Error::duplicate_field("value")); - } - value__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - } - } - Ok(PacketMetadata { - metadata_id: metadata_id__.unwrap_or_default(), - value: value__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.PacketMetadata", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for PacketOut { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.payload.is_empty() { - len += 1; - } - if !self.metadata.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.PacketOut", len)?; - if !self.payload.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("payload", pbjson::private::base64::encode(&self.payload).as_str())?; - } - if !self.metadata.is_empty() { - struct_ser.serialize_field("metadata", &self.metadata)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for PacketOut { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "payload", - "metadata", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Payload, - Metadata, - } - 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 { - "payload" => Ok(GeneratedField::Payload), - "metadata" => Ok(GeneratedField::Metadata), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = PacketOut; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.PacketOut") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut payload__ = None; - let mut metadata__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Payload => { - if payload__.is_some() { - return Err(serde::de::Error::duplicate_field("payload")); - } - payload__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::Metadata => { - if metadata__.is_some() { - return Err(serde::de::Error::duplicate_field("metadata")); - } - metadata__ = Some(map_.next_value()?); - } - } - } - Ok(PacketOut { - payload: payload__.unwrap_or_default(), - metadata: metadata__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.PacketOut", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for PacketOutError { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.packet_out.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.PacketOutError", len)?; - if let Some(v) = self.packet_out.as_ref() { - struct_ser.serialize_field("packetOut", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for PacketOutError { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "packet_out", - "packetOut", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - PacketOut, - } - 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 { - "packetOut" | "packet_out" => Ok(GeneratedField::PacketOut), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = PacketOutError; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.PacketOutError") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut packet_out__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::PacketOut => { - if packet_out__.is_some() { - return Err(serde::de::Error::duplicate_field("packetOut")); - } - packet_out__ = map_.next_value()?; - } - } - } - Ok(PacketOutError { - packet_out: packet_out__, - }) - } - } - deserializer.deserialize_struct("p4.v1.PacketOutError", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for PacketReplicationEngineEntry { - #[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#type.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.PacketReplicationEngineEntry", len)?; - if let Some(v) = self.r#type.as_ref() { - match v { - packet_replication_engine_entry::Type::MulticastGroupEntry(v) => { - struct_ser.serialize_field("multicastGroupEntry", v)?; - } - packet_replication_engine_entry::Type::CloneSessionEntry(v) => { - struct_ser.serialize_field("cloneSessionEntry", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for PacketReplicationEngineEntry { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "multicast_group_entry", - "multicastGroupEntry", - "clone_session_entry", - "cloneSessionEntry", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - MulticastGroupEntry, - CloneSessionEntry, - } - 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 { - "multicastGroupEntry" | "multicast_group_entry" => Ok(GeneratedField::MulticastGroupEntry), - "cloneSessionEntry" | "clone_session_entry" => Ok(GeneratedField::CloneSessionEntry), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = PacketReplicationEngineEntry; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.PacketReplicationEngineEntry") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut r#type__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::MulticastGroupEntry => { - if r#type__.is_some() { - return Err(serde::de::Error::duplicate_field("multicastGroupEntry")); - } - r#type__ = map_.next_value::<::std::option::Option<_>>()?.map(packet_replication_engine_entry::Type::MulticastGroupEntry) -; - } - GeneratedField::CloneSessionEntry => { - if r#type__.is_some() { - return Err(serde::de::Error::duplicate_field("cloneSessionEntry")); - } - r#type__ = map_.next_value::<::std::option::Option<_>>()?.map(packet_replication_engine_entry::Type::CloneSessionEntry) -; - } - } - } - Ok(PacketReplicationEngineEntry { - r#type: r#type__, - }) - } - } - deserializer.deserialize_struct("p4.v1.PacketReplicationEngineEntry", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ReadRequest { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.device_id != 0 { - len += 1; - } - if !self.role.is_empty() { - len += 1; - } - if !self.entities.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.ReadRequest", len)?; - if self.device_id != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("deviceId", ToString::to_string(&self.device_id).as_str())?; - } - if !self.role.is_empty() { - struct_ser.serialize_field("role", &self.role)?; - } - if !self.entities.is_empty() { - struct_ser.serialize_field("entities", &self.entities)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ReadRequest { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "device_id", - "deviceId", - "role", - "entities", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - DeviceId, - Role, - Entities, - } - 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 { - "deviceId" | "device_id" => Ok(GeneratedField::DeviceId), - "role" => Ok(GeneratedField::Role), - "entities" => Ok(GeneratedField::Entities), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ReadRequest; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.ReadRequest") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut device_id__ = None; - let mut role__ = None; - let mut entities__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::DeviceId => { - if device_id__.is_some() { - return Err(serde::de::Error::duplicate_field("deviceId")); - } - device_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Role => { - if role__.is_some() { - return Err(serde::de::Error::duplicate_field("role")); - } - role__ = Some(map_.next_value()?); - } - GeneratedField::Entities => { - if entities__.is_some() { - return Err(serde::de::Error::duplicate_field("entities")); - } - entities__ = Some(map_.next_value()?); - } - } - } - Ok(ReadRequest { - device_id: device_id__.unwrap_or_default(), - role: role__.unwrap_or_default(), - entities: entities__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.ReadRequest", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ReadResponse { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.entities.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.ReadResponse", len)?; - if !self.entities.is_empty() { - struct_ser.serialize_field("entities", &self.entities)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ReadResponse { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "entities", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Entities, - } - 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 { - "entities" => Ok(GeneratedField::Entities), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ReadResponse; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.ReadResponse") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut entities__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Entities => { - if entities__.is_some() { - return Err(serde::de::Error::duplicate_field("entities")); - } - entities__ = Some(map_.next_value()?); - } - } - } - Ok(ReadResponse { - entities: entities__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.ReadResponse", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for RegisterEntry { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.register_id != 0 { - len += 1; - } - if self.index.is_some() { - len += 1; - } - if self.data.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.RegisterEntry", len)?; - if self.register_id != 0 { - struct_ser.serialize_field("registerId", &self.register_id)?; - } - if let Some(v) = self.index.as_ref() { - struct_ser.serialize_field("index", v)?; - } - if let Some(v) = self.data.as_ref() { - struct_ser.serialize_field("data", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for RegisterEntry { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "register_id", - "registerId", - "index", - "data", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - RegisterId, - Index, - Data, - } - 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 { - "registerId" | "register_id" => Ok(GeneratedField::RegisterId), - "index" => Ok(GeneratedField::Index), - "data" => Ok(GeneratedField::Data), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = RegisterEntry; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.RegisterEntry") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut register_id__ = None; - let mut index__ = None; - let mut data__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::RegisterId => { - if register_id__.is_some() { - return Err(serde::de::Error::duplicate_field("registerId")); - } - register_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Index => { - if index__.is_some() { - return Err(serde::de::Error::duplicate_field("index")); - } - index__ = map_.next_value()?; - } - GeneratedField::Data => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("data")); - } - data__ = map_.next_value()?; - } - } - } - Ok(RegisterEntry { - register_id: register_id__.unwrap_or_default(), - index: index__, - data: data__, - }) - } - } - deserializer.deserialize_struct("p4.v1.RegisterEntry", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Replica { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.instance != 0 { - len += 1; - } - if self.port_kind.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.Replica", len)?; - if self.instance != 0 { - struct_ser.serialize_field("instance", &self.instance)?; - } - if let Some(v) = self.port_kind.as_ref() { - match v { - replica::PortKind::EgressPort(v) => { - struct_ser.serialize_field("egressPort", v)?; - } - replica::PortKind::Port(v) => { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("port", pbjson::private::base64::encode(&v).as_str())?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Replica { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "instance", - "egress_port", - "egressPort", - "port", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Instance, - EgressPort, - Port, - } - 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 { - "instance" => Ok(GeneratedField::Instance), - "egressPort" | "egress_port" => Ok(GeneratedField::EgressPort), - "port" => Ok(GeneratedField::Port), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Replica; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.Replica") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut instance__ = None; - let mut port_kind__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Instance => { - if instance__.is_some() { - return Err(serde::de::Error::duplicate_field("instance")); - } - instance__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::EgressPort => { - if port_kind__.is_some() { - return Err(serde::de::Error::duplicate_field("egressPort")); - } - port_kind__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| replica::PortKind::EgressPort(x.0)); - } - GeneratedField::Port => { - if port_kind__.is_some() { - return Err(serde::de::Error::duplicate_field("port")); - } - port_kind__ = map_.next_value::<::std::option::Option<::pbjson::private::BytesDeserialize<_>>>()?.map(|x| replica::PortKind::Port(x.0)); - } - } - } - Ok(Replica { - instance: instance__.unwrap_or_default(), - port_kind: port_kind__, - }) - } - } - deserializer.deserialize_struct("p4.v1.Replica", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Role { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.id != 0 { - len += 1; - } - if !self.name.is_empty() { - len += 1; - } - if self.config.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.Role", len)?; - if self.id != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("id", ToString::to_string(&self.id).as_str())?; - } - 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 Role { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "id", - "name", - "config", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Id, - 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 { - "id" => Ok(GeneratedField::Id), - "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 = Role; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.Role") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut id__ = None; - let mut name__ = None; - let mut config__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Id => { - if id__.is_some() { - return Err(serde::de::Error::duplicate_field("id")); - } - id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - 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(Role { - id: id__.unwrap_or_default(), - name: name__.unwrap_or_default(), - config: config__, - }) - } - } - deserializer.deserialize_struct("p4.v1.Role", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for SdnPort { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - let variant = match self { - Self::Unknown => "SDN_PORT_UNKNOWN", - Self::Min => "SDN_PORT_MIN", - Self::Max => "SDN_PORT_MAX", - Self::Recirculate => "SDN_PORT_RECIRCULATE", - Self::Cpu => "SDN_PORT_CPU", - }; - serializer.serialize_str(variant) - } -} -impl<'de> serde::Deserialize<'de> for SdnPort { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "SDN_PORT_UNKNOWN", - "SDN_PORT_MIN", - "SDN_PORT_MAX", - "SDN_PORT_RECIRCULATE", - "SDN_PORT_CPU", - ]; - - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = SdnPort; - - 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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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 { - "SDN_PORT_UNKNOWN" => Ok(SdnPort::Unknown), - "SDN_PORT_MIN" => Ok(SdnPort::Min), - "SDN_PORT_MAX" => Ok(SdnPort::Max), - "SDN_PORT_RECIRCULATE" => Ok(SdnPort::Recirculate), - "SDN_PORT_CPU" => Ok(SdnPort::Cpu), - _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), - } - } - } - deserializer.deserialize_any(GeneratedVisitor) - } -} -impl serde::Serialize for SetForwardingPipelineConfigRequest { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.device_id != 0 { - len += 1; - } - if self.role_id != 0 { - len += 1; - } - if !self.role.is_empty() { - len += 1; - } - if self.election_id.is_some() { - len += 1; - } - if self.action != 0 { - len += 1; - } - if self.config.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.SetForwardingPipelineConfigRequest", len)?; - if self.device_id != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("deviceId", ToString::to_string(&self.device_id).as_str())?; - } - if self.role_id != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("roleId", ToString::to_string(&self.role_id).as_str())?; - } - if !self.role.is_empty() { - struct_ser.serialize_field("role", &self.role)?; - } - if let Some(v) = self.election_id.as_ref() { - struct_ser.serialize_field("electionId", v)?; - } - if self.action != 0 { - let v = set_forwarding_pipeline_config_request::Action::try_from(self.action) - .map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.action)))?; - struct_ser.serialize_field("action", &v)?; - } - if let Some(v) = self.config.as_ref() { - struct_ser.serialize_field("config", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for SetForwardingPipelineConfigRequest { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "device_id", - "deviceId", - "role_id", - "roleId", - "role", - "election_id", - "electionId", - "action", - "config", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - DeviceId, - RoleId, - Role, - ElectionId, - Action, - 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 { - "deviceId" | "device_id" => Ok(GeneratedField::DeviceId), - "roleId" | "role_id" => Ok(GeneratedField::RoleId), - "role" => Ok(GeneratedField::Role), - "electionId" | "election_id" => Ok(GeneratedField::ElectionId), - "action" => Ok(GeneratedField::Action), - "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 = SetForwardingPipelineConfigRequest; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.SetForwardingPipelineConfigRequest") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut device_id__ = None; - let mut role_id__ = None; - let mut role__ = None; - let mut election_id__ = None; - let mut action__ = None; - let mut config__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::DeviceId => { - if device_id__.is_some() { - return Err(serde::de::Error::duplicate_field("deviceId")); - } - device_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::RoleId => { - if role_id__.is_some() { - return Err(serde::de::Error::duplicate_field("roleId")); - } - role_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Role => { - if role__.is_some() { - return Err(serde::de::Error::duplicate_field("role")); - } - role__ = Some(map_.next_value()?); - } - GeneratedField::ElectionId => { - if election_id__.is_some() { - return Err(serde::de::Error::duplicate_field("electionId")); - } - election_id__ = map_.next_value()?; - } - GeneratedField::Action => { - if action__.is_some() { - return Err(serde::de::Error::duplicate_field("action")); - } - action__ = Some(map_.next_value::()? as i32); - } - GeneratedField::Config => { - if config__.is_some() { - return Err(serde::de::Error::duplicate_field("config")); - } - config__ = map_.next_value()?; - } - } - } - Ok(SetForwardingPipelineConfigRequest { - device_id: device_id__.unwrap_or_default(), - role_id: role_id__.unwrap_or_default(), - role: role__.unwrap_or_default(), - election_id: election_id__, - action: action__.unwrap_or_default(), - config: config__, - }) - } - } - deserializer.deserialize_struct("p4.v1.SetForwardingPipelineConfigRequest", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for set_forwarding_pipeline_config_request::Action { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - let variant = match self { - Self::Unspecified => "UNSPECIFIED", - Self::Verify => "VERIFY", - Self::VerifyAndSave => "VERIFY_AND_SAVE", - Self::VerifyAndCommit => "VERIFY_AND_COMMIT", - Self::Commit => "COMMIT", - Self::ReconcileAndCommit => "RECONCILE_AND_COMMIT", - }; - serializer.serialize_str(variant) - } -} -impl<'de> serde::Deserialize<'de> for set_forwarding_pipeline_config_request::Action { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "UNSPECIFIED", - "VERIFY", - "VERIFY_AND_SAVE", - "VERIFY_AND_COMMIT", - "COMMIT", - "RECONCILE_AND_COMMIT", - ]; - - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = set_forwarding_pipeline_config_request::Action; - - 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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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 { - "UNSPECIFIED" => Ok(set_forwarding_pipeline_config_request::Action::Unspecified), - "VERIFY" => Ok(set_forwarding_pipeline_config_request::Action::Verify), - "VERIFY_AND_SAVE" => Ok(set_forwarding_pipeline_config_request::Action::VerifyAndSave), - "VERIFY_AND_COMMIT" => Ok(set_forwarding_pipeline_config_request::Action::VerifyAndCommit), - "COMMIT" => Ok(set_forwarding_pipeline_config_request::Action::Commit), - "RECONCILE_AND_COMMIT" => Ok(set_forwarding_pipeline_config_request::Action::ReconcileAndCommit), - _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), - } - } - } - deserializer.deserialize_any(GeneratedVisitor) - } -} -impl serde::Serialize for SetForwardingPipelineConfigResponse { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let len = 0; - let struct_ser = serializer.serialize_struct("p4.v1.SetForwardingPipelineConfigResponse", len)?; - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for SetForwardingPipelineConfigResponse { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - } - 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, - { - Err(serde::de::Error::unknown_field(value, FIELDS)) - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = SetForwardingPipelineConfigResponse; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.SetForwardingPipelineConfigResponse") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - while map_.next_key::()?.is_some() { - let _ = map_.next_value::()?; - } - Ok(SetForwardingPipelineConfigResponse { - }) - } - } - deserializer.deserialize_struct("p4.v1.SetForwardingPipelineConfigResponse", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for StreamError { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.canonical_code != 0 { - len += 1; - } - if !self.message.is_empty() { - len += 1; - } - if !self.space.is_empty() { - len += 1; - } - if self.code != 0 { - len += 1; - } - if self.details.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.StreamError", len)?; - if self.canonical_code != 0 { - struct_ser.serialize_field("canonicalCode", &self.canonical_code)?; - } - if !self.message.is_empty() { - struct_ser.serialize_field("message", &self.message)?; - } - if !self.space.is_empty() { - struct_ser.serialize_field("space", &self.space)?; - } - if self.code != 0 { - struct_ser.serialize_field("code", &self.code)?; - } - if let Some(v) = self.details.as_ref() { - match v { - stream_error::Details::PacketOut(v) => { - struct_ser.serialize_field("packetOut", v)?; - } - stream_error::Details::DigestListAck(v) => { - struct_ser.serialize_field("digestListAck", v)?; - } - stream_error::Details::Other(v) => { - struct_ser.serialize_field("other", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for StreamError { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "canonical_code", - "canonicalCode", - "message", - "space", - "code", - "packet_out", - "packetOut", - "digest_list_ack", - "digestListAck", - "other", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - CanonicalCode, - Message, - Space, - Code, - PacketOut, - DigestListAck, - Other, - } - 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 { - "canonicalCode" | "canonical_code" => Ok(GeneratedField::CanonicalCode), - "message" => Ok(GeneratedField::Message), - "space" => Ok(GeneratedField::Space), - "code" => Ok(GeneratedField::Code), - "packetOut" | "packet_out" => Ok(GeneratedField::PacketOut), - "digestListAck" | "digest_list_ack" => Ok(GeneratedField::DigestListAck), - "other" => Ok(GeneratedField::Other), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = StreamError; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.StreamError") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut canonical_code__ = None; - let mut message__ = None; - let mut space__ = None; - let mut code__ = None; - let mut details__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::CanonicalCode => { - if canonical_code__.is_some() { - return Err(serde::de::Error::duplicate_field("canonicalCode")); - } - canonical_code__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Message => { - if message__.is_some() { - return Err(serde::de::Error::duplicate_field("message")); - } - message__ = Some(map_.next_value()?); - } - GeneratedField::Space => { - if space__.is_some() { - return Err(serde::de::Error::duplicate_field("space")); - } - space__ = Some(map_.next_value()?); - } - GeneratedField::Code => { - if code__.is_some() { - return Err(serde::de::Error::duplicate_field("code")); - } - code__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::PacketOut => { - if details__.is_some() { - return Err(serde::de::Error::duplicate_field("packetOut")); - } - details__ = map_.next_value::<::std::option::Option<_>>()?.map(stream_error::Details::PacketOut) -; - } - GeneratedField::DigestListAck => { - if details__.is_some() { - return Err(serde::de::Error::duplicate_field("digestListAck")); - } - details__ = map_.next_value::<::std::option::Option<_>>()?.map(stream_error::Details::DigestListAck) -; - } - GeneratedField::Other => { - if details__.is_some() { - return Err(serde::de::Error::duplicate_field("other")); - } - details__ = map_.next_value::<::std::option::Option<_>>()?.map(stream_error::Details::Other) -; - } - } - } - Ok(StreamError { - canonical_code: canonical_code__.unwrap_or_default(), - message: message__.unwrap_or_default(), - space: space__.unwrap_or_default(), - code: code__.unwrap_or_default(), - details: details__, - }) - } - } - deserializer.deserialize_struct("p4.v1.StreamError", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for StreamMessageRequest { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.update.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.StreamMessageRequest", len)?; - if let Some(v) = self.update.as_ref() { - match v { - stream_message_request::Update::Arbitration(v) => { - struct_ser.serialize_field("arbitration", v)?; - } - stream_message_request::Update::Packet(v) => { - struct_ser.serialize_field("packet", v)?; - } - stream_message_request::Update::DigestAck(v) => { - struct_ser.serialize_field("digestAck", v)?; - } - stream_message_request::Update::Other(v) => { - struct_ser.serialize_field("other", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for StreamMessageRequest { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "arbitration", - "packet", - "digest_ack", - "digestAck", - "other", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Arbitration, - Packet, - DigestAck, - Other, - } - 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 { - "arbitration" => Ok(GeneratedField::Arbitration), - "packet" => Ok(GeneratedField::Packet), - "digestAck" | "digest_ack" => Ok(GeneratedField::DigestAck), - "other" => Ok(GeneratedField::Other), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = StreamMessageRequest; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.StreamMessageRequest") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut update__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Arbitration => { - if update__.is_some() { - return Err(serde::de::Error::duplicate_field("arbitration")); - } - update__ = map_.next_value::<::std::option::Option<_>>()?.map(stream_message_request::Update::Arbitration) -; - } - GeneratedField::Packet => { - if update__.is_some() { - return Err(serde::de::Error::duplicate_field("packet")); - } - update__ = map_.next_value::<::std::option::Option<_>>()?.map(stream_message_request::Update::Packet) -; - } - GeneratedField::DigestAck => { - if update__.is_some() { - return Err(serde::de::Error::duplicate_field("digestAck")); - } - update__ = map_.next_value::<::std::option::Option<_>>()?.map(stream_message_request::Update::DigestAck) -; - } - GeneratedField::Other => { - if update__.is_some() { - return Err(serde::de::Error::duplicate_field("other")); - } - update__ = map_.next_value::<::std::option::Option<_>>()?.map(stream_message_request::Update::Other) -; - } - } - } - Ok(StreamMessageRequest { - update: update__, - }) - } - } - deserializer.deserialize_struct("p4.v1.StreamMessageRequest", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for StreamMessageResponse { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.update.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.StreamMessageResponse", len)?; - if let Some(v) = self.update.as_ref() { - match v { - stream_message_response::Update::Arbitration(v) => { - struct_ser.serialize_field("arbitration", v)?; - } - stream_message_response::Update::Packet(v) => { - struct_ser.serialize_field("packet", v)?; - } - stream_message_response::Update::Digest(v) => { - struct_ser.serialize_field("digest", v)?; - } - stream_message_response::Update::IdleTimeoutNotification(v) => { - struct_ser.serialize_field("idleTimeoutNotification", v)?; - } - stream_message_response::Update::Other(v) => { - struct_ser.serialize_field("other", v)?; - } - stream_message_response::Update::Error(v) => { - struct_ser.serialize_field("error", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for StreamMessageResponse { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "arbitration", - "packet", - "digest", - "idle_timeout_notification", - "idleTimeoutNotification", - "other", - "error", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Arbitration, - Packet, - Digest, - IdleTimeoutNotification, - Other, - Error, - } - 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 { - "arbitration" => Ok(GeneratedField::Arbitration), - "packet" => Ok(GeneratedField::Packet), - "digest" => Ok(GeneratedField::Digest), - "idleTimeoutNotification" | "idle_timeout_notification" => Ok(GeneratedField::IdleTimeoutNotification), - "other" => Ok(GeneratedField::Other), - "error" => Ok(GeneratedField::Error), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = StreamMessageResponse; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.StreamMessageResponse") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut update__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Arbitration => { - if update__.is_some() { - return Err(serde::de::Error::duplicate_field("arbitration")); - } - update__ = map_.next_value::<::std::option::Option<_>>()?.map(stream_message_response::Update::Arbitration) -; - } - GeneratedField::Packet => { - if update__.is_some() { - return Err(serde::de::Error::duplicate_field("packet")); - } - update__ = map_.next_value::<::std::option::Option<_>>()?.map(stream_message_response::Update::Packet) -; - } - GeneratedField::Digest => { - if update__.is_some() { - return Err(serde::de::Error::duplicate_field("digest")); - } - update__ = map_.next_value::<::std::option::Option<_>>()?.map(stream_message_response::Update::Digest) -; - } - GeneratedField::IdleTimeoutNotification => { - if update__.is_some() { - return Err(serde::de::Error::duplicate_field("idleTimeoutNotification")); - } - update__ = map_.next_value::<::std::option::Option<_>>()?.map(stream_message_response::Update::IdleTimeoutNotification) -; - } - GeneratedField::Other => { - if update__.is_some() { - return Err(serde::de::Error::duplicate_field("other")); - } - update__ = map_.next_value::<::std::option::Option<_>>()?.map(stream_message_response::Update::Other) -; - } - GeneratedField::Error => { - if update__.is_some() { - return Err(serde::de::Error::duplicate_field("error")); - } - update__ = map_.next_value::<::std::option::Option<_>>()?.map(stream_message_response::Update::Error) -; - } - } - } - Ok(StreamMessageResponse { - update: update__, - }) - } - } - deserializer.deserialize_struct("p4.v1.StreamMessageResponse", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for StreamOtherError { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.other.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.StreamOtherError", len)?; - if let Some(v) = self.other.as_ref() { - struct_ser.serialize_field("other", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for StreamOtherError { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "other", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Other, - } - 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 { - "other" => Ok(GeneratedField::Other), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = StreamOtherError; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.StreamOtherError") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut other__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Other => { - if other__.is_some() { - return Err(serde::de::Error::duplicate_field("other")); - } - other__ = map_.next_value()?; - } - } - } - Ok(StreamOtherError { - other: other__, - }) - } - } - deserializer.deserialize_struct("p4.v1.StreamOtherError", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for TableAction { - #[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#type.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.TableAction", len)?; - if let Some(v) = self.r#type.as_ref() { - match v { - table_action::Type::Action(v) => { - struct_ser.serialize_field("action", v)?; - } - table_action::Type::ActionProfileMemberId(v) => { - struct_ser.serialize_field("actionProfileMemberId", v)?; - } - table_action::Type::ActionProfileGroupId(v) => { - struct_ser.serialize_field("actionProfileGroupId", v)?; - } - table_action::Type::ActionProfileActionSet(v) => { - struct_ser.serialize_field("actionProfileActionSet", v)?; - } - } - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for TableAction { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "action", - "action_profile_member_id", - "actionProfileMemberId", - "action_profile_group_id", - "actionProfileGroupId", - "action_profile_action_set", - "actionProfileActionSet", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Action, - ActionProfileMemberId, - ActionProfileGroupId, - ActionProfileActionSet, - } - 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 { - "action" => Ok(GeneratedField::Action), - "actionProfileMemberId" | "action_profile_member_id" => Ok(GeneratedField::ActionProfileMemberId), - "actionProfileGroupId" | "action_profile_group_id" => Ok(GeneratedField::ActionProfileGroupId), - "actionProfileActionSet" | "action_profile_action_set" => Ok(GeneratedField::ActionProfileActionSet), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = TableAction; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.TableAction") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut r#type__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Action => { - if r#type__.is_some() { - return Err(serde::de::Error::duplicate_field("action")); - } - r#type__ = map_.next_value::<::std::option::Option<_>>()?.map(table_action::Type::Action) -; - } - GeneratedField::ActionProfileMemberId => { - if r#type__.is_some() { - return Err(serde::de::Error::duplicate_field("actionProfileMemberId")); - } - r#type__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| table_action::Type::ActionProfileMemberId(x.0)); - } - GeneratedField::ActionProfileGroupId => { - if r#type__.is_some() { - return Err(serde::de::Error::duplicate_field("actionProfileGroupId")); - } - r#type__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| table_action::Type::ActionProfileGroupId(x.0)); - } - GeneratedField::ActionProfileActionSet => { - if r#type__.is_some() { - return Err(serde::de::Error::duplicate_field("actionProfileActionSet")); - } - r#type__ = map_.next_value::<::std::option::Option<_>>()?.map(table_action::Type::ActionProfileActionSet) -; - } - } - } - Ok(TableAction { - r#type: r#type__, - }) - } - } - deserializer.deserialize_struct("p4.v1.TableAction", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for TableEntry { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.table_id != 0 { - len += 1; - } - if !self.r#match.is_empty() { - len += 1; - } - if self.action.is_some() { - len += 1; - } - if self.priority != 0 { - len += 1; - } - if self.controller_metadata != 0 { - len += 1; - } - if self.meter_config.is_some() { - len += 1; - } - if self.counter_data.is_some() { - len += 1; - } - if self.meter_counter_data.is_some() { - len += 1; - } - if self.is_default_action { - len += 1; - } - if self.idle_timeout_ns != 0 { - len += 1; - } - if self.time_since_last_hit.is_some() { - len += 1; - } - if !self.metadata.is_empty() { - len += 1; - } - if self.is_const { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.TableEntry", len)?; - if self.table_id != 0 { - struct_ser.serialize_field("tableId", &self.table_id)?; - } - if !self.r#match.is_empty() { - struct_ser.serialize_field("match", &self.r#match)?; - } - if let Some(v) = self.action.as_ref() { - struct_ser.serialize_field("action", v)?; - } - if self.priority != 0 { - struct_ser.serialize_field("priority", &self.priority)?; - } - if self.controller_metadata != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("controllerMetadata", ToString::to_string(&self.controller_metadata).as_str())?; - } - if let Some(v) = self.meter_config.as_ref() { - struct_ser.serialize_field("meterConfig", v)?; - } - if let Some(v) = self.counter_data.as_ref() { - struct_ser.serialize_field("counterData", v)?; - } - if let Some(v) = self.meter_counter_data.as_ref() { - struct_ser.serialize_field("meterCounterData", v)?; - } - if self.is_default_action { - struct_ser.serialize_field("isDefaultAction", &self.is_default_action)?; - } - if self.idle_timeout_ns != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("idleTimeoutNs", ToString::to_string(&self.idle_timeout_ns).as_str())?; - } - if let Some(v) = self.time_since_last_hit.as_ref() { - struct_ser.serialize_field("timeSinceLastHit", v)?; - } - if !self.metadata.is_empty() { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("metadata", pbjson::private::base64::encode(&self.metadata).as_str())?; - } - if self.is_const { - struct_ser.serialize_field("isConst", &self.is_const)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for TableEntry { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "table_id", - "tableId", - "match", - "action", - "priority", - "controller_metadata", - "controllerMetadata", - "meter_config", - "meterConfig", - "counter_data", - "counterData", - "meter_counter_data", - "meterCounterData", - "is_default_action", - "isDefaultAction", - "idle_timeout_ns", - "idleTimeoutNs", - "time_since_last_hit", - "timeSinceLastHit", - "metadata", - "is_const", - "isConst", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - TableId, - Match, - Action, - Priority, - ControllerMetadata, - MeterConfig, - CounterData, - MeterCounterData, - IsDefaultAction, - IdleTimeoutNs, - TimeSinceLastHit, - Metadata, - IsConst, - } - 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 { - "tableId" | "table_id" => Ok(GeneratedField::TableId), - "match" => Ok(GeneratedField::Match), - "action" => Ok(GeneratedField::Action), - "priority" => Ok(GeneratedField::Priority), - "controllerMetadata" | "controller_metadata" => Ok(GeneratedField::ControllerMetadata), - "meterConfig" | "meter_config" => Ok(GeneratedField::MeterConfig), - "counterData" | "counter_data" => Ok(GeneratedField::CounterData), - "meterCounterData" | "meter_counter_data" => Ok(GeneratedField::MeterCounterData), - "isDefaultAction" | "is_default_action" => Ok(GeneratedField::IsDefaultAction), - "idleTimeoutNs" | "idle_timeout_ns" => Ok(GeneratedField::IdleTimeoutNs), - "timeSinceLastHit" | "time_since_last_hit" => Ok(GeneratedField::TimeSinceLastHit), - "metadata" => Ok(GeneratedField::Metadata), - "isConst" | "is_const" => Ok(GeneratedField::IsConst), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = TableEntry; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.TableEntry") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut table_id__ = None; - let mut r#match__ = None; - let mut action__ = None; - let mut priority__ = None; - let mut controller_metadata__ = None; - let mut meter_config__ = None; - let mut counter_data__ = None; - let mut meter_counter_data__ = None; - let mut is_default_action__ = None; - let mut idle_timeout_ns__ = None; - let mut time_since_last_hit__ = None; - let mut metadata__ = None; - let mut is_const__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::TableId => { - if table_id__.is_some() { - return Err(serde::de::Error::duplicate_field("tableId")); - } - table_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Match => { - if r#match__.is_some() { - return Err(serde::de::Error::duplicate_field("match")); - } - r#match__ = Some(map_.next_value()?); - } - GeneratedField::Action => { - if action__.is_some() { - return Err(serde::de::Error::duplicate_field("action")); - } - action__ = map_.next_value()?; - } - GeneratedField::Priority => { - if priority__.is_some() { - return Err(serde::de::Error::duplicate_field("priority")); - } - priority__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::ControllerMetadata => { - if controller_metadata__.is_some() { - return Err(serde::de::Error::duplicate_field("controllerMetadata")); - } - controller_metadata__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::MeterConfig => { - if meter_config__.is_some() { - return Err(serde::de::Error::duplicate_field("meterConfig")); - } - meter_config__ = map_.next_value()?; - } - GeneratedField::CounterData => { - if counter_data__.is_some() { - return Err(serde::de::Error::duplicate_field("counterData")); - } - counter_data__ = map_.next_value()?; - } - GeneratedField::MeterCounterData => { - if meter_counter_data__.is_some() { - return Err(serde::de::Error::duplicate_field("meterCounterData")); - } - meter_counter_data__ = map_.next_value()?; - } - GeneratedField::IsDefaultAction => { - if is_default_action__.is_some() { - return Err(serde::de::Error::duplicate_field("isDefaultAction")); - } - is_default_action__ = Some(map_.next_value()?); - } - GeneratedField::IdleTimeoutNs => { - if idle_timeout_ns__.is_some() { - return Err(serde::de::Error::duplicate_field("idleTimeoutNs")); - } - idle_timeout_ns__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::TimeSinceLastHit => { - if time_since_last_hit__.is_some() { - return Err(serde::de::Error::duplicate_field("timeSinceLastHit")); - } - time_since_last_hit__ = map_.next_value()?; - } - GeneratedField::Metadata => { - if metadata__.is_some() { - return Err(serde::de::Error::duplicate_field("metadata")); - } - metadata__ = - Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::IsConst => { - if is_const__.is_some() { - return Err(serde::de::Error::duplicate_field("isConst")); - } - is_const__ = Some(map_.next_value()?); - } - } - } - Ok(TableEntry { - table_id: table_id__.unwrap_or_default(), - r#match: r#match__.unwrap_or_default(), - action: action__, - priority: priority__.unwrap_or_default(), - controller_metadata: controller_metadata__.unwrap_or_default(), - meter_config: meter_config__, - counter_data: counter_data__, - meter_counter_data: meter_counter_data__, - is_default_action: is_default_action__.unwrap_or_default(), - idle_timeout_ns: idle_timeout_ns__.unwrap_or_default(), - time_since_last_hit: time_since_last_hit__, - metadata: metadata__.unwrap_or_default(), - is_const: is_const__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.TableEntry", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for table_entry::IdleTimeout { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.elapsed_ns != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.TableEntry.IdleTimeout", len)?; - if self.elapsed_ns != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("elapsedNs", ToString::to_string(&self.elapsed_ns).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for table_entry::IdleTimeout { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "elapsed_ns", - "elapsedNs", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - ElapsedNs, - } - 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 { - "elapsedNs" | "elapsed_ns" => Ok(GeneratedField::ElapsedNs), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = table_entry::IdleTimeout; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.TableEntry.IdleTimeout") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut elapsed_ns__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::ElapsedNs => { - if elapsed_ns__.is_some() { - return Err(serde::de::Error::duplicate_field("elapsedNs")); - } - elapsed_ns__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(table_entry::IdleTimeout { - elapsed_ns: elapsed_ns__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.TableEntry.IdleTimeout", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Uint128 { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.high != 0 { - len += 1; - } - if self.low != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.Uint128", len)?; - if self.high != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("high", ToString::to_string(&self.high).as_str())?; - } - if self.low != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("low", ToString::to_string(&self.low).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Uint128 { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "high", - "low", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - High, - Low, - } - 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 { - "high" => Ok(GeneratedField::High), - "low" => Ok(GeneratedField::Low), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Uint128; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.Uint128") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut high__ = None; - let mut low__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::High => { - if high__.is_some() { - return Err(serde::de::Error::duplicate_field("high")); - } - high__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Low => { - if low__.is_some() { - return Err(serde::de::Error::duplicate_field("low")); - } - low__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - } - } - Ok(Uint128 { - high: high__.unwrap_or_default(), - low: low__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.Uint128", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Update { - #[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#type != 0 { - len += 1; - } - if self.entity.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.Update", len)?; - if self.r#type != 0 { - let v = update::Type::try_from(self.r#type) - .map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.r#type)))?; - struct_ser.serialize_field("type", &v)?; - } - if let Some(v) = self.entity.as_ref() { - struct_ser.serialize_field("entity", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Update { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "type", - "entity", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Type, - Entity, - } - 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 { - "type" => Ok(GeneratedField::Type), - "entity" => Ok(GeneratedField::Entity), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Update; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.Update") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut r#type__ = None; - let mut entity__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::Type => { - if r#type__.is_some() { - return Err(serde::de::Error::duplicate_field("type")); - } - r#type__ = Some(map_.next_value::()? as i32); - } - GeneratedField::Entity => { - if entity__.is_some() { - return Err(serde::de::Error::duplicate_field("entity")); - } - entity__ = map_.next_value()?; - } - } - } - Ok(Update { - r#type: r#type__.unwrap_or_default(), - entity: entity__, - }) - } - } - deserializer.deserialize_struct("p4.v1.Update", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for update::Type { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - let variant = match self { - Self::Unspecified => "UNSPECIFIED", - Self::Insert => "INSERT", - Self::Modify => "MODIFY", - Self::Delete => "DELETE", - }; - serializer.serialize_str(variant) - } -} -impl<'de> serde::Deserialize<'de> for update::Type { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "UNSPECIFIED", - "INSERT", - "MODIFY", - "DELETE", - ]; - - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = update::Type; - - 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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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 { - "UNSPECIFIED" => Ok(update::Type::Unspecified), - "INSERT" => Ok(update::Type::Insert), - "MODIFY" => Ok(update::Type::Modify), - "DELETE" => Ok(update::Type::Delete), - _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), - } - } - } - deserializer.deserialize_any(GeneratedVisitor) - } -} -impl serde::Serialize for ValueSetEntry { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.value_set_id != 0 { - len += 1; - } - if !self.members.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.ValueSetEntry", len)?; - if self.value_set_id != 0 { - struct_ser.serialize_field("valueSetId", &self.value_set_id)?; - } - if !self.members.is_empty() { - struct_ser.serialize_field("members", &self.members)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ValueSetEntry { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "value_set_id", - "valueSetId", - "members", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - ValueSetId, - Members, - } - 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 { - "valueSetId" | "value_set_id" => Ok(GeneratedField::ValueSetId), - "members" => Ok(GeneratedField::Members), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ValueSetEntry; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.ValueSetEntry") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut value_set_id__ = None; - let mut members__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::ValueSetId => { - if value_set_id__.is_some() { - return Err(serde::de::Error::duplicate_field("valueSetId")); - } - value_set_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Members => { - if members__.is_some() { - return Err(serde::de::Error::duplicate_field("members")); - } - members__ = Some(map_.next_value()?); - } - } - } - Ok(ValueSetEntry { - value_set_id: value_set_id__.unwrap_or_default(), - members: members__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.ValueSetEntry", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ValueSetMember { - #[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_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.ValueSetMember", len)?; - if !self.r#match.is_empty() { - struct_ser.serialize_field("match", &self.r#match)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ValueSetMember { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "match", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Match, - } - 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), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ValueSetMember; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.ValueSetMember") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut r#match__ = 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__ = Some(map_.next_value()?); - } - } - } - Ok(ValueSetMember { - r#match: r#match__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.ValueSetMember", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for WriteRequest { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if self.device_id != 0 { - len += 1; - } - if self.role_id != 0 { - len += 1; - } - if !self.role.is_empty() { - len += 1; - } - if self.election_id.is_some() { - len += 1; - } - if !self.updates.is_empty() { - len += 1; - } - if self.atomicity != 0 { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("p4.v1.WriteRequest", len)?; - if self.device_id != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("deviceId", ToString::to_string(&self.device_id).as_str())?; - } - if self.role_id != 0 { - #[allow(clippy::needless_borrow)] - struct_ser.serialize_field("roleId", ToString::to_string(&self.role_id).as_str())?; - } - if !self.role.is_empty() { - struct_ser.serialize_field("role", &self.role)?; - } - if let Some(v) = self.election_id.as_ref() { - struct_ser.serialize_field("electionId", v)?; - } - if !self.updates.is_empty() { - struct_ser.serialize_field("updates", &self.updates)?; - } - if self.atomicity != 0 { - let v = write_request::Atomicity::try_from(self.atomicity) - .map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.atomicity)))?; - struct_ser.serialize_field("atomicity", &v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for WriteRequest { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "device_id", - "deviceId", - "role_id", - "roleId", - "role", - "election_id", - "electionId", - "updates", - "atomicity", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - DeviceId, - RoleId, - Role, - ElectionId, - Updates, - Atomicity, - } - 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 { - "deviceId" | "device_id" => Ok(GeneratedField::DeviceId), - "roleId" | "role_id" => Ok(GeneratedField::RoleId), - "role" => Ok(GeneratedField::Role), - "electionId" | "election_id" => Ok(GeneratedField::ElectionId), - "updates" => Ok(GeneratedField::Updates), - "atomicity" => Ok(GeneratedField::Atomicity), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = WriteRequest; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.WriteRequest") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut device_id__ = None; - let mut role_id__ = None; - let mut role__ = None; - let mut election_id__ = None; - let mut updates__ = None; - let mut atomicity__ = None; - while let Some(k) = map_.next_key()? { - match k { - GeneratedField::DeviceId => { - if device_id__.is_some() { - return Err(serde::de::Error::duplicate_field("deviceId")); - } - device_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::RoleId => { - if role_id__.is_some() { - return Err(serde::de::Error::duplicate_field("roleId")); - } - role_id__ = - Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Role => { - if role__.is_some() { - return Err(serde::de::Error::duplicate_field("role")); - } - role__ = Some(map_.next_value()?); - } - GeneratedField::ElectionId => { - if election_id__.is_some() { - return Err(serde::de::Error::duplicate_field("electionId")); - } - election_id__ = map_.next_value()?; - } - GeneratedField::Updates => { - if updates__.is_some() { - return Err(serde::de::Error::duplicate_field("updates")); - } - updates__ = Some(map_.next_value()?); - } - GeneratedField::Atomicity => { - if atomicity__.is_some() { - return Err(serde::de::Error::duplicate_field("atomicity")); - } - atomicity__ = Some(map_.next_value::()? as i32); - } - } - } - Ok(WriteRequest { - device_id: device_id__.unwrap_or_default(), - role_id: role_id__.unwrap_or_default(), - role: role__.unwrap_or_default(), - election_id: election_id__, - updates: updates__.unwrap_or_default(), - atomicity: atomicity__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("p4.v1.WriteRequest", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for write_request::Atomicity { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - let variant = match self { - Self::ContinueOnError => "CONTINUE_ON_ERROR", - Self::RollbackOnError => "ROLLBACK_ON_ERROR", - Self::DataplaneAtomic => "DATAPLANE_ATOMIC", - }; - serializer.serialize_str(variant) - } -} -impl<'de> serde::Deserialize<'de> for write_request::Atomicity { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "CONTINUE_ON_ERROR", - "ROLLBACK_ON_ERROR", - "DATAPLANE_ATOMIC", - ]; - - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = write_request::Atomicity; - - 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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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, - { - i32::try_from(v) - .ok() - .and_then(|x| x.try_into().ok()) - .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 { - "CONTINUE_ON_ERROR" => Ok(write_request::Atomicity::ContinueOnError), - "ROLLBACK_ON_ERROR" => Ok(write_request::Atomicity::RollbackOnError), - "DATAPLANE_ATOMIC" => Ok(write_request::Atomicity::DataplaneAtomic), - _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), - } - } - } - deserializer.deserialize_any(GeneratedVisitor) - } -} -impl serde::Serialize for WriteResponse { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let len = 0; - let struct_ser = serializer.serialize_struct("p4.v1.WriteResponse", len)?; - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for WriteResponse { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - } - 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, - { - Err(serde::de::Error::unknown_field(value, FIELDS)) - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = WriteResponse; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct p4.v1.WriteResponse") - } - - fn visit_map(self, mut map_: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - while map_.next_key::()?.is_some() { - let _ = map_.next_value::()?; - } - Ok(WriteResponse { - }) - } - } - deserializer.deserialize_struct("p4.v1.WriteResponse", FIELDS, GeneratedVisitor) - } -}