-
Notifications
You must be signed in to change notification settings - Fork 320
Open
Description
It would be nice if Bytes could be decomposed into its "raw parts" in order to reduce the size overhead of types that wish to support using Bytes as the buffer but already store a base pointer and length information separately, e.g. a multi-dimensional array backed by a Bytes buffer.
To support this, there could be:
impl Bytes {
pub fn to_raw_parts(self) -> (*const u8, usize, BytesOwner) { ... }
pub unsafe fn from_raw_parts(ptr: *const u8, len: usize, owner: BytesOwner) -> Bytes { ... }
}where BytesOwner includes the data and vtable information.
Users would be required to call from_raw_parts with exactly the values returned from to_raw_parts in order to free the memory. Dropping BytesOwner would leak the memory.
If the maintainers are open to this, I can create a PR.
Metadata
Metadata
Assignees
Labels
No labels