#[derive(Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Clone, serde::Deserialize, serde::Serialize)] pub enum C { U, S, D, } #[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)] pub struct B { pub pass: i64, pub direction: C, pub depth: f64, } /// Auto-generated type for unnamed Avro union variants. #[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)] #[serde(remote = "Self")] pub enum UnionLongDoubleB { Long(i64), Double(f64), B(B), } impl From for UnionLongDoubleB { fn from(v: i64) -> Self { Self::Long(v) } } impl TryFrom for i64 { type Error = UnionLongDoubleB; fn try_from(v: UnionLongDoubleB) -> Result { if let UnionLongDoubleB::Long(v) = v { Ok(v) } else { Err(v) } } } impl From for UnionLongDoubleB { fn from(v: f64) -> Self { Self::Double(v) } } impl TryFrom for f64 { type Error = UnionLongDoubleB; fn try_from(v: UnionLongDoubleB) -> Result { if let UnionLongDoubleB::Double(v) = v { Ok(v) } else { Err(v) } } } impl From for UnionLongDoubleB { fn from(v: B) -> Self { Self::B(v) } } impl TryFrom for B { type Error = UnionLongDoubleB; fn try_from(v: UnionLongDoubleB) -> Result { if let UnionLongDoubleB::B(v) = v { Ok(v) } else { Err(v) } } } impl serde::Serialize for UnionLongDoubleB { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, { struct NewtypeVariantSerializer(S); impl serde::Serializer for NewtypeVariantSerializer where S: serde::Serializer, { type Ok = S::Ok; type Error = S::Error; type SerializeSeq = serde::ser::Impossible; type SerializeTuple = serde::ser::Impossible; type SerializeTupleStruct = serde::ser::Impossible; type SerializeTupleVariant = serde::ser::Impossible; type SerializeMap = serde::ser::Impossible; type SerializeStruct = serde::ser::Impossible; type SerializeStructVariant = serde::ser::Impossible; fn serialize_bool(self, _v: bool) -> Result { unimplemented!() } fn serialize_i8(self, _v: i8) -> Result { unimplemented!() } fn serialize_i16(self, _v: i16) -> Result { unimplemented!() } fn serialize_i32(self, _v: i32) -> Result { unimplemented!() } fn serialize_i64(self, _v: i64) -> Result { unimplemented!() } fn serialize_u8(self, _v: u8) -> Result { unimplemented!() } fn serialize_u16(self, _v: u16) -> Result { unimplemented!() } fn serialize_u32(self, _v: u32) -> Result { unimplemented!() } fn serialize_u64(self, _v: u64) -> Result { unimplemented!() } fn serialize_f32(self, _v: f32) -> Result { unimplemented!() } fn serialize_f64(self, _v: f64) -> Result { unimplemented!() } fn serialize_char(self, _v: char) -> Result { unimplemented!() } fn serialize_str(self, _v: &str) -> Result { unimplemented!() } fn serialize_bytes(self, _v: &[u8]) -> Result { unimplemented!() } fn serialize_none(self) -> Result { unimplemented!() } fn serialize_some(self, _value: &T) -> Result{ unimplemented!() } fn serialize_unit(self) -> Result { unimplemented!() } fn serialize_unit_struct(self, _name: &'static str) -> Result { unimplemented!() } fn serialize_unit_variant(self ,_name: &'static str, _variant_index: u32, _variant: &'static str) -> Result { unimplemented!() } fn serialize_newtype_struct(self, _name: &'static str, _value: &T,) -> Result { unimplemented!() } fn serialize_seq(self,_len: Option,) -> Result { unimplemented!() } fn serialize_tuple(self, _len: usize) -> Result { unimplemented!() } fn serialize_tuple_struct(self,_name: &'static str,_len: usize) -> Result { unimplemented!() } fn serialize_tuple_variant(self,_name: &'static str,_variant_index: u32,_variant: &'static str,_len: usize) -> Result { unimplemented!() } fn serialize_map(self,_len: Option) -> Result { unimplemented!() } fn serialize_struct(self,_name: &'static str,_len: usize) -> Result { unimplemented!() } fn serialize_struct_variant(self,_name: &'static str,_variant_index: u32,_variant: &'static str,_len: usize) -> Result { unimplemented!() } fn serialize_newtype_variant( self, _name: &'static str, _variant_index: u32, _variant: &'static str, value: &T, ) -> Result { value.serialize(self.0) } } Self::serialize(self, NewtypeVariantSerializer(serializer)) } } impl<'de> serde::Deserialize<'de> for UnionLongDoubleB { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { Self::deserialize(deserializer) } } #[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)] pub struct A { pub item: Option, }