diff --git a/Cargo.toml b/Cargo.toml index fabe255..6124b95 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ serde = { version = "1", default-features = false, features = ["derive"] } serde_bytes = "0.11.12" [features] +bytes-from-array = [] log-all = [] log-none = [] log-info = [] diff --git a/src/de.rs b/src/de.rs index 92533e1..013cc7c 100644 --- a/src/de.rs +++ b/src/de.rs @@ -597,10 +597,24 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { where V: Visitor<'de>, { - // major type 2: "byte string" - let length = self.raw_deserialize_u32(MAJOR_BYTES)? as usize; - let bytes: &'de [u8] = self.try_take_n(length)?; - visitor.visit_borrowed_bytes(bytes) + let major = self.peek_major()?; + match major { + #[cfg(feature = "bytes-from-array")] + MAJOR_ARRAY => { + let len = self.raw_deserialize_u32(MAJOR_ARRAY)?; + visitor.visit_seq(SeqAccess { + deserializer: self, + len: len as usize, + }) + } + MAJOR_BYTES => { + // major type 2: "byte string" + let length = self.raw_deserialize_u32(MAJOR_BYTES)? as usize; + let bytes: &'de [u8] = self.try_take_n(length)?; + visitor.visit_borrowed_bytes(bytes) + } + _ => Err(Error::DeserializeBadMajor), + } } fn deserialize_byte_buf(self, visitor: V) -> Result