Several serialization formats (for example, flatbuffers), allocate a buffer that they serialize data into, but don't necessary fill the entire buffer with the data. The data might only be a subset of the buffer, starting at some offset for a certain number of elements. It would be awesome to have a way to construct a Message from a Vec<u8> with an associated offset and size.
Without such a function, the data either has to be copied into a new Vec<u8> that holds only the intended data, or you have to implement Sendable and call zmq_msg_init_data with a callback and unsafe code. Being a bit of a Rust newbie, I don't like the idea of using unsafe, nevertheless giving a callback that C will call, that is in charge of destructing my type.
Several serialization formats (for example, flatbuffers), allocate a buffer that they serialize data into, but don't necessary fill the entire buffer with the data. The data might only be a subset of the buffer, starting at some offset for a certain number of elements. It would be awesome to have a way to construct a
Message
from aVec<u8>
with an associated offset and size.Without such a function, the data either has to be copied into a new
Vec<u8>
that holds only the intended data, or you have to implementSendable
and callzmq_msg_init_data
with a callback and unsafe code. Being a bit of a Rust newbie, I don't like the idea of usingunsafe
, nevertheless giving a callback that C will call, that is in charge of destructing my type.Could a function like the following be added?