diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-03-24 02:56:27 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-24 02:56:27 +0000 |
commit | d2bc189f5d45cc7e8e98b9510e527a5ce7307aa4 (patch) | |
tree | 9c7ae45a636c627016ad1de8742453b69054899a /src/sys/socket/addr.rs | |
parent | 3ca28f681ca7b7caa08809f19ae4f3eccc1d41a2 (diff) | |
parent | 350423ca02403892081b1db4d7cc4267d8209587 (diff) | |
download | nix-d2bc189f5d45cc7e8e98b9510e527a5ce7307aa4.zip |
Merge #1686
1686: [skip ci] better docs for SockaddrLike::from_raw r=asomers a=asomers
Fixes #1680
Co-authored-by: Alan Somers <asomers@gmail.com>
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 faaa7211..e2321cb7 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -1014,10 +1014,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; |