pub fn recv_body_into_buf(
        &mut self,
        buf: &mut [u8],
    ) -> Result<(MsgHeader, usize, Option<Vec<File>>)> {
        let mut hdr = MsgHeader::default();
        let mut iovs = [
            iovec {
                iov_base: (&mut hdr as *mut MsgHeader) as *mut c_void,
                iov_len: mem::size_of::<MsgHeader>(),
            },
            iovec {
                iov_base: buf.as_mut_ptr() as *mut c_void,
                iov_len: buf.len(),
            },
        ];
        // Safe because we own hdr and have a mutable borrow of buf, and hdr is ByteValued
        // and it's safe to fill a byte slice with arbitrary data.
        let (bytes, files) = unsafe { self.recv_into_iovec_all(&mut iovs[..])? };

        if bytes < mem::size_of::<MsgHeader>() {
            return Err(Error::PartialMessage);
        } else if !hdr.is_valid() {
            return Err(Error::InvalidMessage);
        }

        Ok((hdr, bytes - mem::size_of::<MsgHeader>(), files))
    }
/// Receive a message with header and optional content. Callers need to
/// pre-allocate a big enough buffer to receive the message body and
/// optional payload. If there are attached file descriptor associated
/// with the message, the first MAX_ATTACHED_FD_ENTRIES file descriptors
/// will be accepted and all other file descriptor will be discard
/// silently.
///
/// # Return:
/// * - (message header, message size, [received files]) on success.
/// * - SocketRetry: temporary error caused by signals or short of resources.
/// * - SocketBroken: the underline socket is broken.
/// * - SocketError: other socket related errors.
/// * - PartialMessage: received a partial message.
/// * - InvalidMessage: received a invalid message.
Receive a message with header and optional content. Callers need to
pre-allocate a big enough buffer to receive the message body and
optional payload. If there are attached file descriptor associated
with the message, the first MAX_ATTACHED_FD_ENTRIES file descriptors
will be accepted and all other file descriptor will be discard
silently.
Receive a message with header and optional content . Callers need to pre - allocate a big enough buffer to receive the message body and optional payload . If there are attached file descriptor associated with the message the first MAX_ATTACHED_FD_ENTRIES file descriptors will be accepted and all other file descriptor will be discard silently .
pub fn recv_body_into_buf(
        &mut self,
        buf: &mut [u8],
    ) -> Result<(MsgHeader, usize, Option<Vec<File>>)> {
        let mut hdr = MsgHeader::default();
        let mut iovs = [
            iovec {
                iov_base: (&mut hdr as *mut MsgHeader) as *mut c_void,
                iov_len: mem::size_of::<MsgHeader>(),
            },
            iovec {
                iov_base: buf.as_mut_ptr() as *mut c_void,
                iov_len: buf.len(),
            },
        ];
        // Safe because we own hdr and have a mutable borrow of buf, and hdr is ByteValued
        // and it's safe to fill a byte slice with arbitrary data.
        let (bytes, files) = unsafe { self.recv_into_iovec_all(&mut iovs[..])? };
        if bytes < mem::size_of::<MsgHeader>() {
            return Err(Error::PartialMessage);
        } else if !hdr.is_valid() {
            return Err(Error::InvalidMessage);
        }
        Ok((hdr, bytes - mem::size_of::<MsgHeader>(), files))
    }
pub fn recv_body_into_buf ( & mut self , buf : & mut [ u8 ] , ) -> Result < ( MsgHeader , usize , Option < Vec < File > > ) > { let mut hdr = MsgHeader :: default ( ) ; let mut iovs = [ iovec { iov_base : ( & mut hdr as * mut MsgHeader ) as * mut c_void , iov_len : mem :: size_of :: < MsgHeader > ( ) , } , iovec { iov_base : buf . as_mut_ptr ( ) as * mut c_void , iov_len : buf . len ( ) , } , ] ; // Safe because we own hdr and have a mutable borrow of buf, and hdr is ByteValued // and it's safe to fill a byte slice with arbitrary data. let ( bytes , files ) = unsafe { self . recv_into_iovec_all ( & mut iovs [ .. ] ) ? } ; if bytes < mem :: size_of :: < MsgHeader > ( ) { return Err ( Error :: PartialMessage ) ; } else if ! hdr . is_valid ( ) { return Err ( Error :: InvalidMessage ) ; } Ok ( ( hdr , bytes - mem :: size_of :: < MsgHeader > ( ) , files ) ) }
Receive a message with header and optional content.
Receive a message with header and optional content .
&mut self
buf
&mut [u8]
&mut self
buf
&mut [u8]
return:
- (message header, message size, [received files]) on success.
- SocketRetry: temporary error caused by signals or short of resources.
- SocketBroken: the underline socket is broken.
- SocketError: other socket related errors.
- PartialMessage: received a partial message.
- InvalidMessage: received a invalid message.
- ( message header message size [ received files ] ) on success . - SocketRetry : temporary error caused by signals or short of resources . - SocketBroken : the underline socket is broken . - SocketError : other socket related errors . - PartialMessage : received a partial message . - InvalidMessage : received a invalid message .