Currently, the rustix::net::sockopt::socket_peercred is Linux-specific only. The PR that added the API, had pointers to the API used on other platforms but I didn't find any issues regarding this, so opening this issue.
I am not sure what the API would look like though? Ideally we should just make socket_peercred work on those platforms but getpeereid doesn't give you the PID. Perhaps the solution would be to just add a #[cfg(target_os = "linux")] to rustix::net::UCred::pid but then what about rustix::net::SendAncillaryMessage::ScmCredentials? 🤔