hyper
hyper copied to clipboard
Add the ability to safely read into ReadBuf
Is your feature request related to a problem? Please describe.
It is impossible to write an implementation of hyper::rt::Read
because ReadBufCursor
cannot be written to safely.
Describe the solution you'd like
Have a method that initializes the read buffer by zeroing it and then returning an &mut [u8]
that can be filled safely. E.g. this.
Describe alternatives you've considered N/A
Yea, I purposefully stuck with the smallest API possible, so that an overly eager method wouldn't restrict it's internal design. I'm happy to have proposals for new methods to add.
You're specifically asking for a way to access the slice as &mut [u8]
, instead of the &mut [MaybeUninit<u8>]
, right?
Yes, that would be best. See my implementation where I have to use unsafe
code to read into the buffer. If I could pass a &mut [u8]
to the underlying reader I would be able to mark this crate as forbid(unsafe_code)
.