#[derive(Debug, PartialEq, Eq, Clone, serde::Deserialize, serde::Serialize)] #[serde(default)] pub struct BytesData { #[serde(deserialize_with = "nullable_bytesdata_b")] #[serde(serialize_with = "apache_avro::serde_avro_bytes::serialize")] pub b: Vec, pub nb: Option>, } #[inline(always)] fn nullable_bytesdata_b<'de, D>(deserializer: D) -> Result, D::Error> where D: serde::Deserializer<'de>, { use serde::Deserialize; #[derive(serde::Deserialize)] struct Wrapper(#[serde(with = "apache_avro::serde_avro_bytes")] Vec); let opt = Option::::deserialize(deserializer)?.map(|w| w.0); Ok(opt.unwrap_or_else(|| default_bytesdata_b() )) } #[inline(always)] fn default_bytesdata_b() -> Vec { vec![195, 191] } #[inline(always)] fn default_bytesdata_nb() -> Option> { None } impl Default for BytesData { fn default() -> BytesData { BytesData { b: default_bytesdata_b(), nb: default_bytesdata_nb(), } } }