pub fn recv_body<T: ByteValued + Sized + MsgValidator>(
        &mut self,
    ) -> Result<(MsgHeader, T, Option<Vec<File>>)> {
        let mut hdr = MsgHeader::default();
        let mut body: T = Default::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: (&mut body as *mut T) as *mut c_void,
                iov_len: mem::size_of::<T>(),
            },
        ];
        // Safe because we own hdr and body and they're ByteValued.
        let (bytes, files) = unsafe { self.recv_into_iovec_all(&mut iovs[..])? };

        let total = mem::size_of::<MsgHeader>() + mem::size_of::<T>();
        if bytes != total {
            return Err(Error::PartialMessage);
        } else if !hdr.is_valid() || !body.is_valid() {
            return Err(Error::InvalidMessage);
        }

        Ok((hdr, body, files))
    }
/// Receive a message with optional attached file descriptors.
/// Note, only the first MAX_ATTACHED_FD_ENTRIES file descriptors will be
/// accepted and all other file descriptor will be discard silently.
///
/// # Return:
/// * - (message header, message body, [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 optional attached file descriptors.
Note, only the first MAX_ATTACHED_FD_ENTRIES file descriptors will be
accepted and all other file descriptor will be discard silently.
Receive a message with optional attached file descriptors . Note only the first MAX_ATTACHED_FD_ENTRIES file descriptors will be accepted and all other file descriptor will be discard silently .
pub fn recv_body<T: ByteValued + Sized + MsgValidator>(
        &mut self,
    ) -> Result<(MsgHeader, T, Option<Vec<File>>)> {
        let mut hdr = MsgHeader::default();
        let mut body: T = Default::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: (&mut body as *mut T) as *mut c_void,
                iov_len: mem::size_of::<T>(),
            },
        ];
        // Safe because we own hdr and body and they're ByteValued.
        let (bytes, files) = unsafe { self.recv_into_iovec_all(&mut iovs[..])? };
        let total = mem::size_of::<MsgHeader>() + mem::size_of::<T>();
        if bytes != total {
            return Err(Error::PartialMessage);
        } else if !hdr.is_valid() || !body.is_valid() {
            return Err(Error::InvalidMessage);
        }
        Ok((hdr, body, files))
    }
pub fn recv_body < T : ByteValued + Sized + MsgValidator > ( & mut self , ) -> Result < ( MsgHeader , T , Option < Vec < File > > ) > { let mut hdr = MsgHeader :: default ( ) ; let mut body : T = Default :: 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 : ( & mut body as * mut T ) as * mut c_void , iov_len : mem :: size_of :: < T > ( ) , } , ] ; // Safe because we own hdr and body and they're ByteValued. let ( bytes , files ) = unsafe { self . recv_into_iovec_all ( & mut iovs [ .. ] ) ? } ; let total = mem :: size_of :: < MsgHeader > ( ) + mem :: size_of :: < T > ( ) ; if bytes != total { return Err ( Error :: PartialMessage ) ; } else if ! hdr . is_valid ( ) || ! body . is_valid ( ) { return Err ( Error :: InvalidMessage ) ; } Ok ( ( hdr , body , files ) ) }
Receive a message with optional attached file descriptors.
Receive a message with optional attached file descriptors .
&mut self
&mut self
return:
- (message header, message body, [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 body [ 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 .