Skip to content

Commit 350423c

Browse files
committed
[skip ci] better docs for SockaddrLike::from_raw
Fixes #1680
1 parent 0fe6682 commit 350423c

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
@@ -975,10 +975,22 @@ pub trait SockaddrLike: private::SockaddrLikePriv {
975975
/// Some C APIs from provide `len`, and others do not. If it's provided it
976976
/// will be validated. If not, it will be guessed based on the family.
977977
///
978+
/// # Arguments
979+
///
980+
/// - `addr`: raw pointer to something that can be cast to a
981+
/// `libc::sockaddr`. For example, `libc::sockaddr_in`,
982+
/// `libc::sockaddr_in6`, etc.
983+
/// - `len`: For fixed-width types like `sockaddr_in`, it will be
984+
/// validated if present and ignored if not. For variable-width
985+
/// types it is required and must be the total length of valid
986+
/// data. For example, if `addr` points to a
987+
/// named `sockaddr_un`, then `len` must be the length of the
988+
/// structure up to but not including the trailing NUL.
989+
///
978990
/// # Safety
979991
///
980992
/// `addr` must be valid for the specific type of sockaddr. `len`, if
981-
/// present, must be the length of valid data in `addr`.
993+
/// present, must not exceed the length of valid data in `addr`.
982994
unsafe fn from_raw(addr: *const libc::sockaddr, len: Option<libc::socklen_t>)
983995
-> Option<Self> where Self: Sized;
984996

0 commit comments

Comments
 (0)