/// Reads messages until there are no more messages, a message with ancillary data is
/// encountered, or `user_buffers` are full.
///
/// # Parameters
/// - `task`: The task to read memory from.
/// - `user_buffers`: The `UserBufferIterator` to write the data to.
///
/// Returns the number of bytes that were read into the buffer, and any ancillary data that was
/// read.
Reads messages until there are no more messages, a message with ancillary data is
encountered, or `user_buffers` are full.
Reads messages until there are no more messages a message with ancillary data is encountered or ` user_buffers ` are full .
pub fn read_stream(
        &mut self,
        task: &Task,
        user_buffers: &mut UserBufferIterator<'_>,
    ) -> Result<MessageReadInfo, Errno> {
        if self.closed {
            if self.peer_closed_with_unread_data {
                return error!(ECONNRESET);
            }
            return Ok(MessageReadInfo::default());
        }
        let mut total_bytes_read = 0;
        let mut address = None;
        let mut ancillary_data = None;
        while !self.is_empty() {
            if let Some(mut user_buffer) = user_buffers.next(self.length) {
                // Try to read enough bytes to fill the current user buffer.
                let (messages, bytes_read) = self.read_bytes(&mut address, user_buffer.length);
                for message in messages {
                    task.mm.write_memory(user_buffer.address, message.data.bytes())?;
                    // Update the user address to write to.
                    user_buffer.address += message.len();
                    total_bytes_read += message.len();
                    if message.ancillary_data.is_some() {
                        ancillary_data = message.ancillary_data;
                        break;
                    }
                }
                if bytes_read < user_buffer.length {
                    // If the buffer was not filled, break out of the loop.
                    break;
                }
            } else {
                // Break out of the loop if there is no more space in the user buffers.
                break;
            }
        }
        Ok(MessageReadInfo {
            bytes_read: total_bytes_read,
            message_length: total_bytes_read,
            address,
            ancillary_data,
        })
    }
pub fn read_stream ( & mut self , task : & Task , user_buffers : & mut UserBufferIterator < ' _ > , ) -> Result < MessageReadInfo , Errno > { if self . closed { if self . peer_closed_with_unread_data { return error ! ( ECONNRESET ) ; } return Ok ( MessageReadInfo :: default ( ) ) ; } let mut total_bytes_read = 0 ; let mut address = None ; let mut ancillary_data = None ; while ! self . is_empty ( ) { if let Some ( mut user_buffer ) = user_buffers . next ( self . length ) { // Try to read enough bytes to fill the current user buffer. let ( messages , bytes_read ) = self . read_bytes ( & mut address , user_buffer . length ) ; for message in messages { task . mm . write_memory ( user_buffer . address , message . data . bytes ( ) ) ? ; // Update the user address to write to. user_buffer . address += message . len ( ) ; total_bytes_read += message . len ( ) ; if message . ancillary_data . is_some ( ) { ancillary_data = message . ancillary_data ; break ; } } if bytes_read < user_buffer . length { // If the buffer was not filled, break out of the loop. break ; } } else { // Break out of the loop if there is no more space in the user buffers. break ; } } Ok ( MessageReadInfo { bytes_read : total_bytes_read , message_length : total_bytes_read , address , ancillary_data , } ) }
Reads messages until there are no more messages, a message with ancillary data is
encountered, or `user_buffers` are full.
Reads messages until there are no more messages a message with ancillary data is encountered or ` user_buffers ` are full .
&mut self
task
&Task
The task to read memory from.
The task to read memory from .
user_buffers
&mut UserBufferIterator<'_>
The `UserBufferIterator` to write the data to.

Returns the number of bytes that were read into the buffer, and any ancillary data that was
read.
The ` UserBufferIterator ` to write the data to . Returns the number of bytes that were read into the buffer and any ancillary data that was read .