Skip to content

Commit d2bc189

Browse files
bors[bot]asomers
andauthored
Merge #1686
1686: [skip ci] better docs for SockaddrLike::from_raw r=asomers a=asomers Fixes #1680 Co-authored-by: Alan Somers <[email protected]>
2 parents 3ca28f6 + 350423c commit d2bc189

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/sys/socket/addr.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -1014,10 +1014,22 @@ pub trait SockaddrLike: private::SockaddrLikePriv {
10141014
/// Some C APIs from provide `len`, and others do not. If it's provided it
10151015
/// will be validated. If not, it will be guessed based on the family.
10161016
///
1017+
/// # Arguments
1018+
///
1019+
/// - `addr`: raw pointer to something that can be cast to a
1020+
/// `libc::sockaddr`. For example, `libc::sockaddr_in`,
1021+
/// `libc::sockaddr_in6`, etc.
1022+
/// - `len`: For fixed-width types like `sockaddr_in`, it will be
1023+
/// validated if present and ignored if not. For variable-width
1024+
/// types it is required and must be the total length of valid
1025+
/// data. For example, if `addr` points to a
1026+
/// named `sockaddr_un`, then `len` must be the length of the
1027+
/// structure up to but not including the trailing NUL.
1028+
///
10171029
/// # Safety
10181030
///
10191031
/// `addr` must be valid for the specific type of sockaddr. `len`, if
1020-
/// present, must be the length of valid data in `addr`.
1032+
/// present, must not exceed the length of valid data in `addr`.
10211033
unsafe fn from_raw(addr: *const libc::sockaddr, len: Option<libc::socklen_t>)
10221034
-> Option<Self> where Self: Sized;
10231035

0 commit comments

Comments
 (0)