pub fn sys_channel_read(
        &self,
        handle_value: HandleValue,
        options: u32,
        mut bytes: UserOutPtr<u8>,
        handles: usize,
        num_bytes: u32,
        num_handles: u32,
        mut actual_bytes: UserOutPtr<u32>,
        mut actual_handles: UserOutPtr<u32>,
        is_etc: bool,
    ) -> ZxResult {
        info!(
            "channel.read: handle={:#x?}, options={:?}, bytes=({:#x?}; {:#x?}), handles=({:#x?}; {:#x?})",
            handle_value, options, bytes, num_bytes, handles, num_handles,
        );
        let proc = self.thread.proc();
        let channel = proc.get_object_with_rights::<Channel>(handle_value, Rights::READ)?;
        const MAY_DISCARD: u32 = 1;
        let never_discard = options & MAY_DISCARD == 0;

        let mut msg = if never_discard {
            channel.check_and_read(|front_msg| {
                if num_bytes < front_msg.data.len() as u32
                    || num_handles < front_msg.handles.len() as u32
                {
                    let bytes = front_msg.data.len() + TESTS_ARGS.lock().len();
                    actual_bytes.write_if_not_null(bytes as u32)?;
                    actual_handles.write_if_not_null(front_msg.handles.len() as u32)?;
                    Err(ZxError::BUFFER_TOO_SMALL)
                } else {
                    Ok(())
                }
            })?
        } else {
            channel.read()?
        };

        hack_core_tests(handle_value, &self.thread.proc().name(), &mut msg.data);

        actual_bytes.write_if_not_null(msg.data.len() as u32)?;
        actual_handles.write_if_not_null(msg.handles.len() as u32)?;
        if num_bytes < msg.data.len() as u32 || num_handles < msg.handles.len() as u32 {
            return Err(ZxError::BUFFER_TOO_SMALL);
        }
        bytes.write_array(msg.data.as_slice())?;
        if is_etc {
            let mut handle_infos: Vec<HandleInfo> = msg
                .handles
                .iter()
                .map(|handle| handle.get_handle_info())
                .collect();
            let values = proc.add_handles(msg.handles);
            for (i, value) in values.iter().enumerate() {
                handle_infos[i].handle = *value;
            }
            UserOutPtr::<HandleInfo>::from(handles).write_array(&handle_infos)?;
        } else {
            let values = proc.add_handles(msg.handles);
            UserOutPtr::<HandleValue>::from(handles).write_array(&values)?;
        }
        Ok(())
    }
/// Read/Receive a message from a channel.  
Read/Receive a message from a channel.
Read / Receive a message from a channel .
pub fn sys_channel_read(
        &self,
        handle_value: HandleValue,
        options: u32,
        mut bytes: UserOutPtr<u8>,
        handles: usize,
        num_bytes: u32,
        num_handles: u32,
        mut actual_bytes: UserOutPtr<u32>,
        mut actual_handles: UserOutPtr<u32>,
        is_etc: bool,
    ) -> ZxResult {
        info!(
            "channel.read: handle={:#x?}, options={:?}, bytes=({:#x?}; {:#x?}), handles=({:#x?}; {:#x?})",
            handle_value, options, bytes, num_bytes, handles, num_handles,
        );
        let proc = self.thread.proc();
        let channel = proc.get_object_with_rights::<Channel>(handle_value, Rights::READ)?;
        const MAY_DISCARD: u32 = 1;
        let never_discard = options & MAY_DISCARD == 0;
        let mut msg = if never_discard {
            channel.check_and_read(|front_msg| {
                if num_bytes < front_msg.data.len() as u32
                    || num_handles < front_msg.handles.len() as u32
                {
                    let bytes = front_msg.data.len() + TESTS_ARGS.lock().len();
                    actual_bytes.write_if_not_null(bytes as u32)?;
                    actual_handles.write_if_not_null(front_msg.handles.len() as u32)?;
                    Err(ZxError::BUFFER_TOO_SMALL)
                } else {
                    Ok(())
                }
            })?
        } else {
            channel.read()?
        };
        hack_core_tests(handle_value, &self.thread.proc().name(), &mut msg.data);
        actual_bytes.write_if_not_null(msg.data.len() as u32)?;
        actual_handles.write_if_not_null(msg.handles.len() as u32)?;
        if num_bytes < msg.data.len() as u32 || num_handles < msg.handles.len() as u32 {
            return Err(ZxError::BUFFER_TOO_SMALL);
        }
        bytes.write_array(msg.data.as_slice())?;
        if is_etc {
            let mut handle_infos: Vec<HandleInfo> = msg
                .handles
                .iter()
                .map(|handle| handle.get_handle_info())
                .collect();
            let values = proc.add_handles(msg.handles);
            for (i, value) in values.iter().enumerate() {
                handle_infos[i].handle = *value;
            }
            UserOutPtr::<HandleInfo>::from(handles).write_array(&handle_infos)?;
        } else {
            let values = proc.add_handles(msg.handles);
            UserOutPtr::<HandleValue>::from(handles).write_array(&values)?;
        }
        Ok(())
    }
pub fn sys_channel_read ( & self , handle_value : HandleValue , options : u32 , mut bytes : UserOutPtr < u8 > , handles : usize , num_bytes : u32 , num_handles : u32 , mut actual_bytes : UserOutPtr < u32 > , mut actual_handles : UserOutPtr < u32 > , is_etc : bool , ) -> ZxResult { info ! ( " " handle_value options bytes num_bytes handles num_handles ) ; let proc = self . thread . proc ( ) ; let channel = proc . get_object_with_rights :: < Channel > ( handle_value , Rights :: READ ) ? ; const MAY_DISCARD : u32 = 1 ; let never_discard = options & MAY_DISCARD == 0 ; let mut msg = if never_discard { channel . check_and_read ( | front_msg | { if num_bytes < front_msg . data . len ( ) as u32 || num_handles < front_msg . handles . len ( ) as u32 { let bytes = front_msg . data . len ( ) + TESTS_ARGS . lock ( ) . len ( ) ; actual_bytes . write_if_not_null ( bytes as u32 ) ? ; actual_handles . write_if_not_null ( front_msg . handles . len ( ) as u32 ) ? ; Err ( ZxError :: BUFFER_TOO_SMALL ) } else { Ok ( ( ) ) } } ) ? } else { channel . read ( ) ? } ; hack_core_tests ( handle_value , & self . thread . proc ( ) . name ( ) , & mut msg . data ) ; actual_bytes . write_if_not_null ( msg . data . len ( ) as u32 ) ? ; actual_handles . write_if_not_null ( msg . handles . len ( ) as u32 ) ? ; if num_bytes < msg . data . len ( ) as u32 || num_handles < msg . handles . len ( ) as u32 { return Err ( ZxError :: BUFFER_TOO_SMALL ) ; } bytes . write_array ( msg . data . as_slice ( ) ) ? ; if is_etc { let mut handle_infos : Vec < HandleInfo > = msg . handles . iter ( ) . map ( | handle | handle . get_handle_info ( ) ) . collect ( ) ; let values = proc . add_handles ( msg . handles ) ; for ( i , value ) in values . iter ( ) . enumerate ( ) { handle_infos [ i ] . handle = * value ; } UserOutPtr :: < HandleInfo > :: from ( handles ) . write_array ( & handle_infos ) ? ; } else { let values = proc . add_handles ( msg . handles ) ; UserOutPtr :: < HandleValue > :: from ( handles ) . write_array ( & values ) ? ; } Ok ( ( ) ) }
Read/Receive a message from a channel.
Read / Receive a message from a channel .
&self
handle_value
HandleValue
options
u32
bytes
UserOutPtr<u8>
handles
usize
num_bytes
u32
num_handles
u32
actual_bytes
UserOutPtr<u32>
actual_handles
UserOutPtr<u32>
is_etc
bool
&self
handle_value
HandleValue
options
u32
bytes
UserOutPtr<u8>
handles
usize
num_bytes
u32
num_handles
u32
actual_bytes
UserOutPtr<u32>
actual_handles
UserOutPtr<u32>
is_etc
bool