serde-rs / bytes

Wrapper types to enable optimized handling of &[u8] and Vec<u8>
Apache License 2.0
306 stars 37 forks source link

`Vec<Vec<u8>>` conversion support missing #7

Closed jq-rs closed 7 years ago

jq-rs commented 7 years ago

Hello! Thanks for this great crate! I tried to add Vec<Vec<u8>> under efficient bytes conversion but was unable to. Probably expected, would it be possible to add such support?

More detailed errors below:

... error[E0277]: the trait bound std::vec::Vec<std::vec::Vec<u8>>: std::convert::AsRef<[u8]> is not satisfied --> src/lib.rs:169:10 169 #[derive(Serialize, Deserialize, Debug, Clone)] ^^^^^^^^^ the trait std::convert::AsRef<[u8]> is not implemented for std::vec::Vec<std::vec::Vec<u8>>
= help: the following implementations were found:
          <std::vec::Vec<T> as std::convert::AsRef<[T]>>
          <std::vec::Vec<T> as std::convert::AsRef<std::vec::Vec<T>>>
= note: required by `serde_bytes::serialize`
error[E0277]: the trait bound std::vec::Vec<std::vec::Vec<u8>>: std::convert::From<std::vec::Vec<u8>> is not satisfied --> src/lib.rs:169:21 169 #[derive(Serialize, Deserialize, Debug, Clone)] ^^^^^^^^^^^ the trait std::convert::From<std::vec::Vec<u8>> is not implemented for std::vec::Vec<std::vec::Vec<u8>>
= help: the following implementations were found:
          <std::vec::Vec<u8> as std::convert::From<serde_bytes::ByteBuf>>
          <std::vec::Vec<T> as std::convert::From<std::collections::BinaryHeap<T>>>
          <std::vec::Vec<T> as std::convert::From<std::boxed::Box<[T]>>>
          <std::vec::Vec<u8> as std::convert::From<&'a str>>
        and 6 others
= note: required by `serde_bytes::deserialize`

...

jq-rs commented 7 years ago

I was able to workaround this with a separate struct definition. Closing.