self.finish_if_not_nested()
}
fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error> {
- self.builder.push(v);
+ self.builder.push(crate::Blob(v));
self.finish_if_not_nested()
}
fn serialize_none(self) -> Result<Self::Ok, Self::Error> {
-#![allow(unused_imports)]
-
use super::rwyw::NonNullString;
use flexbuffers::*;
use quickcheck::{Arbitrary, Gen};
b: Array4<i32>,
c: Array2<f64>,
},
+ Blobs(#[serde(with = "serde_bytes")] Vec<u8>),
}
// There is some upstream bug in deriving Arbitrary for Enum so we manually implement it here.
let read = MyTupleStruct::deserialize(reader).unwrap();
assert_eq!(data, read);
}
-
+#[test]
+fn serialize_serde_with_bytes_as_blob() {
+ #[derive(Serialize, Deserialize)]
+ struct Foo(#[serde(with = "serde_bytes")] Vec<u8>);
+ let mut s = FlexbufferSerializer::new();
+ Foo(vec![5, 6, 7, 8]).serialize(&mut s).unwrap();
+ let reader = Reader::get_root(s.view()).unwrap();
+ assert_eq!(reader.flexbuffer_type(), FlexBufferType::Blob);
+ assert_eq!(reader.as_blob(), Blob(&[5, 6, 7, 8]));
+}
#[test]
fn iter() {
let mut fxb = Builder::default();