diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 1234f020a6..08db66cc3d 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -811,9 +811,9 @@ pub struct SendMmsgData<'a, I, C> pub _lt: std::marker::PhantomData<&'a I>, } -/// An extension of [`sendmsg`] that allows the caller to transmit multiple -/// messages on a socket using a single system call. (This has performance -/// benefits for some applications.). +/// An extension of `sendmsg` that allows the caller to transmit multiple +/// messages on a socket using a single system call. This has performance +/// benefits for some applications. /// /// Allocations are performed for cmsgs and to build `msghdr` buffer /// @@ -823,11 +823,11 @@ pub struct SendMmsgData<'a, I, C> /// * `data`: Struct that implements `IntoIterator` with `SendMmsgData` items /// * `flags`: Optional flags passed directly to the operating system. /// -/// Returns tuple, where the first value is number of sent messages, and the second one -/// it a `Vec` with numbers of bytes sent on each appropriate message. +/// # Returns +/// `Vec` with numbers of sent bytes on each sent message. /// -///# References -/// [`sendmmsg`](fn.sendmsg.html) +/// # References +/// [`sendmsg`](fn.sendmsg.html) #[cfg(any( target_os = "linux", target_os = "android", @@ -839,7 +839,7 @@ pub fn sendmmsg<'a, I, C>( fd: RawFd, data: impl std::iter::IntoIterator>, flags: MsgFlags -) -> Result<(usize, Vec)> +) -> Result> where I: AsRef<[IoVec<&'a [u8]>]> + 'a, C: AsRef<[ControlMessage<'a>]> + 'a, @@ -888,7 +888,7 @@ pub fn sendmmsg<'a, I, C>( sent_bytes[i] = initialized_data[i].msg_len as usize; } - Ok((sent_messages, sent_bytes)) + Ok(sent_bytes) } @@ -902,11 +902,11 @@ pub struct RecvMmsgData<'a, I> pub cmsg_buffer: Option<&'a mut Vec>, } -/// An extension of [`recvmsg`] that allows the caller to receive multiple -/// messages from a socket using a single system call. (This has -/// performance benefits for some applications.) +/// An extension of `recvmsg` that allows the caller to receive multiple +/// messages from a socket using a single system call. This has +/// performance benefits for some applications. /// -/// `iov` and `cmsg_buffer` should be constucted similarly to recvmsg +/// `iov` and `cmsg_buffer` should be constructed similarly to `recvmsg` /// /// Multiple allocations are performed /// @@ -922,8 +922,12 @@ pub struct RecvMmsgData<'a, I> /// * `cmsg_buffer`: Space to receive ancillary data. Should be created by /// [`cmsg_space!`](macro.cmsg_space.html) /// +/// # Returns +/// A `Vec` with multiple `RecvMsg`, one per received message +/// /// # References -/// [`recvmsg`](fn.recvmsg.html) +/// - [`recvmsg`](fn.recvmsg.html) +/// - [`RecvMsg`](struct.RecvMsg.html) #[cfg(any( target_os = "linux", target_os = "android", diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs index 7e62fddb12..91f7be580f 100644 --- a/test/sys/test_socket.rs +++ b/test/sys/test_socket.rs @@ -282,13 +282,12 @@ mod recvfrom { ); } sendmmsg(s, msgs.iter(), flags) - .map(move |(sent_messages, sent_bytes)| { - assert!(sent_messages >= 1); - assert_eq!(sent_bytes.len(), sent_messages); + .map(move |sent_bytes| { + assert!(sent_bytes.len() >= 1); for sent in &sent_bytes { assert_eq!(*sent, m.len()); } - sent_messages + sent_bytes.len() }) }); // UDP sockets should set the from address