Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to safely read into ReadBuf #3509

Open
notgull opened this issue Dec 30, 2023 · 2 comments · May be fixed by #3515
Open

Add the ability to safely read into ReadBuf #3509

notgull opened this issue Dec 30, 2023 · 2 comments · May be fixed by #3515
Labels
C-feature Category: feature. This is adding a new feature.

Comments

@notgull
Copy link

notgull commented Dec 30, 2023

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 notgull added the C-feature Category: feature. This is adding a new feature. label Dec 30, 2023
@seanmonstar
Copy link
Member

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?

@notgull
Copy link
Author

notgull commented Jan 1, 2024

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 added a commit to forkgull/hyper that referenced this issue Jan 5, 2024
Closes hyperium#3509

Signed-off-by: John Nunley <dev@notgull.net>
@notgull notgull linked a pull request Jan 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: feature. This is adding a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants