You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to use nix to go from a libc::sockaddr to a std::net::SockAddr. This is useful when using recvmsg to receive data off a UDP socket or when using the equivalent io_uring operations. I notice that from_libc_sockaddr (
) implements this functionality, but is marked as crate only. I was wondering if it would acceptable to mark it as public.
The change is of course trivial to make, I wanted to create an issue just to understand if there were concerns around marking it pub. One possible concern I can imagine is that it is marked unsafe at the moment, I imagine this is because of the pointer cast but I have to admit I am not sure how to make it safer because the code already ensures that the passed pointer is not null, so the checks required would need to ensure that the pointer is to a 4-byte allocation, which is non-trivial. On the other hand, maybe unsafe exports are unavoidable from nix and there are already cases, e.g., ptsname (
The current situation requires that I copy the code into my project (or rewrite a more restricted version), and I want to avoid that if possible. Let me know if this is acceptable and I am happy to submit a PR.
The text was updated successfully, but these errors were encountered:
I don't have any objections to making this public (other than wanting documentation about what is actually supported by it), but I know @asomers is touching SockAddr in changes related to #1544. @asomers any issues making this public?
Yes, I think the need to make this public will go away once I finish the sockaddr changes. I know I haven't touched that branch in awhile. I'll try to get to it this week, after I reach a stopping point on another project.
I was trying to use nix to go from a
libc::sockaddr
to astd::net::SockAddr
. This is useful when usingrecvmsg
to receive data off a UDP socket or when using the equivalent io_uring operations. I notice thatfrom_libc_sockaddr
(nix/src/sys/socket/addr.rs
Line 959 in 5cd01a1
The change is of course trivial to make, I wanted to create an issue just to understand if there were concerns around marking it
pub
. One possible concern I can imagine is that it is marked unsafe at the moment, I imagine this is because of the pointer cast but I have to admit I am not sure how to make it safer because the code already ensures that the passed pointer is not null, so the checks required would need to ensure that the pointer is to a 4-byte allocation, which is non-trivial. On the other hand, maybe unsafe exports are unavoidable from nix and there are already cases, e.g.,ptsname
(nix/src/pty.rs
Line 175 in 83cd1da
The current situation requires that I copy the code into my project (or rewrite a more restricted version), and I want to avoid that if possible. Let me know if this is acceptable and I am happy to submit a PR.
The text was updated successfully, but these errors were encountered: