Description
Hi. I am interested in bincode 2 and am trying migrating from v1. A difficult point is that I do not find an equivalent of BincodeRead::get_byte_buffer()
in v2. I use it for zero-copy deserialization.
You might think, anyway, we need to first allocate a Vec<u8>
then read data into it when using get_byte_buffer
, hence there will be no difference compared to Reader::read()
in v2, which fills data into a provided &[u8]
. However, this is not the case when we are memory mapping a file and using a custom global allocator which can 1) ignore deallactions in that heap regions and latter free them in batch, or 2) can do partial deallocation. In my use case, I directly construct Vec<u8>
(unsafely) from slices within the ignored heap regions and pass its ownership to deserializer in get_byte_buffer
. The Vec<u8>
is then passed to serve_bytes::ByteBuf
or String
in my data structures. There is zero copy in this deserializing process.
My use case may be tricky. However, as the allocator API is getting stabilized, we will be able to do it in a safer way.
I am wondering whether it would be better to provide a similar API in v2.