Currently Cow<'a, [u8]> uses &'a [u8] deserialization implementation which would fail when deserializing from any non-binary format.
While this is expected for &'a [u8] but Cow<'a, [u8]> can contain Vec<u8> as well and doesn't have to be a pointer into deserializer owned data.
I suggest to write a special visitor for Cow<'a, [u8]> that will create Cow::Borrowed when visit_borrowed_bytes or visit_borrowed_str is called, and Cow::Owned for visit_str, visit_string, visit_bytes or visit_byte_buf.
Currently
Cow<'a, [u8]>
uses&'a [u8]
deserialization implementation which would fail when deserializing from any non-binary format. While this is expected for&'a [u8]
butCow<'a, [u8]>
can containVec<u8>
as well and doesn't have to be a pointer into deserializer owned data.I suggest to write a special visitor for
Cow<'a, [u8]>
that will createCow::Borrowed
whenvisit_borrowed_bytes
orvisit_borrowed_str
is called, andCow::Owned
forvisit_str
,visit_string
,visit_bytes
orvisit_byte_buf
.