nix
nix copied to clipboard
no .as_unix_addr() / .as_unix_addr_mut() on SockaddrStorage
As above, there's no .as_unix_addr() / .as_unix_addr_mut() methods on SockaddrStorage.
Comparing the list from https://docs.rs/nix/latest/nix/sys/socket/trait.SockaddrLike.html#implementors to https://docs.rs/nix/latest/nix/sys/socket/union.SockaddrStorage.html#implementations :
- SockAddr deprecated not needed.
- AlgAddr => as_alg_addr / as_alg_addr_mut
- LinkAddr => as_link_addr / as_link_addr_mut
- NetlinkAddr => as_netlink_addr / as_netlink_addr_mut
- SockaddrIn => as_sockaddr_in / as_sockaddr_in_mut
- SockaddrIn6 => as_sockaddr_in6 / as_sockaddr_in6_mut
- UnixAddr => missing
- VsockAddr => as_vsock_addr / as_vsok_addr_mut
- SockaddrStorage => identity, not needed.
That's deliberate. Such a method could be implemented on the BSDs. But Linux doesn't have a sun_len field, which means you can't cast a sockaddr_storage to a sockaddr_un without having some other source for information about its valid length.
Fixed by #1871 . We had to add a sun_len field to the structure on Linux, so it isn't zero-cost anymore. But that enables methods like these.