Closed spaolacci closed 11 months ago
Do you mean borrow_decode_from_slice? This returns (D, usize)
where the usize
is the amount of bytes read.
Well, I obviously feel embarrassed. Was only looking into bincode::serde
since.. using serde :/..
Layout might gain from having the function on the two locations, or all of them in just one location, but anyway this is clearly what I was looking for.
Thanks a lot.
seb
I'm going to reopen this as the serde functions ideally would be the same as the standard bincode functions
Should be fixed in the next version, please re-open this if any of the names do not match
Hi,
On top of being more symmetrical with
decode_from_slice
, this is very handy for cases where that information is not easily available decoding side.Use case that I'm having is where the slice host a collection of bincode-encoded items. The overall size is know (through a specific header) but not individual item encoded sizes. A representative example could be a list of
&str
.That’s obviously fixable through a per item extra
usize
header but make encoding/decoding slower, and serialized size larger, than need to be.I might have missed something but it seem decoder's reader is having that information which could gain from being exposed (as for
decode_from_slice
).And thanks a lot for the very nice crate!
Seb