diff options
author | Alan Somers <asomers@gmail.com> | 2022-03-22 21:02:02 -0600 |
---|---|---|
committer | Alan Somers <asomers@gmail.com> | 2022-03-22 21:29:51 -0600 |
commit | 350423ca02403892081b1db4d7cc4267d8209587 (patch) | |
tree | a4996bf2674e0fb410f3e963f95d80ba6c895c01 /src/sys/socket/addr.rs | |
parent | 0fe668265f08c134a93bf682ac9349dc743bce00 (diff) | |
download | nix-350423ca02403892081b1db4d7cc4267d8209587.zip |
[skip ci] better docs for SockaddrLike::from_raw
Fixes #1680
Diffstat (limited to 'src/sys/socket/addr.rs')
-rw-r--r-- | src/sys/socket/addr.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index 9d22beea..f5452d27 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -975,10 +975,22 @@ pub trait SockaddrLike: private::SockaddrLikePriv { /// Some C APIs from provide `len`, and others do not. If it's provided it /// will be validated. If not, it will be guessed based on the family. /// + /// # Arguments + /// + /// - `addr`: raw pointer to something that can be cast to a + /// `libc::sockaddr`. For example, `libc::sockaddr_in`, + /// `libc::sockaddr_in6`, etc. + /// - `len`: For fixed-width types like `sockaddr_in`, it will be + /// validated if present and ignored if not. For variable-width + /// types it is required and must be the total length of valid + /// data. For example, if `addr` points to a + /// named `sockaddr_un`, then `len` must be the length of the + /// structure up to but not including the trailing NUL. + /// /// # Safety /// /// `addr` must be valid for the specific type of sockaddr. `len`, if - /// present, must be the length of valid data in `addr`. + /// present, must not exceed the length of valid data in `addr`. unsafe fn from_raw(addr: *const libc::sockaddr, len: Option<libc::socklen_t>) -> Option<Self> where Self: Sized; |