-
Notifications
You must be signed in to change notification settings - Fork 228
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
Socket::recv_from taking a &mut [u8] #223
Comments
Socket2 makes the guarantee that no uninitalized bytes are written to the buffer, but indeed rustc doesn't understand this.
I'm afraid since socket2 is a low level library we focus on those "hyper-tuned" application. On top of socket2 nicer API can be build, so I won't change it back. However I'm open to additional API that works with
The following code at least avoids Lines 1384 to 1389 in 34a0786
|
Is this no longer the case, then? EDIT: I guess that's a little unfair, the safe API is just harder to use. I'd be happy to work on a new equivalent recv_from method that takes |
The crate made it a lot easier to work with uninitialised bytes, which is a pain using the sockets from stdlib, but I understand your pain. |
Closing in favour of #366. |
Starting in version 0.4.0 there's no safe way to pass a
&mut [u8]
into recv_from, since RecvFrom takes&mut [MaybeUninitialized<u8>]
and rustc does not understand if the library potentially writes uninitalized bytes to the buffer.Would it be possible to return the signature of the function to the way it was in 0.3.0 so that we can safely call recv_from? Perhaps a recv_from_uninitialized_with_options would be something useful for hyper-tuned applications.
Currently the only way I can see to interact with recv_from when I have a &mut [u8] is to use transmute, which is very difficult to pass code review with and difficult to reason about.
The text was updated successfully, but these errors were encountered: