-
Notifications
You must be signed in to change notification settings - Fork 672
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
Definition of the SockaddrFromRaw
trait
#2235
Conversation
1f14239
to
c3b2c67
Compare
c3b2c67
to
e079841
Compare
I don't understand what problem this PR would solve. Could you please explain? |
https://man7.org/linux/man-pages/man3/recvmsg.3p.html:
That means that we don't get any feedback whether the address buffer got initialized or not. The only way to ensure it is initialized when returning from
As discussed in #2177, the current implementation The only alternative I see to this is to check every invariant of the address type after |
Basically, the call order of S::init_storage -> syscall -> S::from_raw |
On second thought, I don't think that implementations for I've also edited the PR message |
Fixing that will only require a single line in
So can your proposed alternative.
The |
All types except If we go down this route, we should mark the /// # Safety
///
/// If `&self` is convertible to `&libc::sockaddr`, then`Self::as_ptr` must perform this conversion.
///
/// If `&self` is *not* convertible to `&libc::sockaddr`, then `Self::as_ptr` must return NULL.
The difference between my |
Another difference is that when using I'll open a separate PR if the version with |
Preparation to fyx #2177.
Example Implementation for
SockaddrIn
:Alternatives
The functionality of this trait could also be embedded into
SockaddrLike
. But this would force us to set the return type of thefrom_raw
function toOption<XXX>
. This has one disadvantage:SockaddrStorage
can never fail. We can assume thatlen
is always in bounds oflibc::sockaddr_storage
or otherwise panic.Checklist:
CONTRIBUTING.md