hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Add the ability to safely read into ReadBuf

Open notgull opened this issue 1 year ago • 2 comments

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

notgull avatar Dec 30 '23 04:12 notgull

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?

seanmonstar avatar Jan 01 '24 19:01 seanmonstar

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).

notgull avatar Jan 01 '24 19:01 notgull