/// Read the body of a page from the provided `ByteStream` and enqueues complete packets onto
/// the stream's packet queue.
Read the body of a page from the provided `ByteStream` and enqueues complete packets onto
the stream's packet queue.
Read the body of a page from the provided ` ByteStream ` and enqueues complete packets onto the stream ' s packet queue .
pub fn read<B: ByteStream>(&mut self, reader: &mut B, page: &PageHeader) -> Result<()> {
        let mut payload_len = 0;
        let mut packet_len = self.write_at - self.read_from;
        if packet_len > 0 && !page.is_continuation {
            warn!("expected continuation page");
            // Expected a continuation page to complete an incomplete packet, however this page does
            // not continue a previous page, therefore the incomplete packet must be dropped.
            packet_len = 0;
            self.write_at -= packet_len;
        }
        // Read each segment length from the segment table and calculate length of each packet
        // contained within the page, and the total payload size.
        for _ in 0..page.n_segments {
            let segment_len = reader.read_byte()?;
            packet_len += usize::from(segment_len);
            payload_len += usize::from(segment_len);
            // trace!("  │  ├ segment {{ len: {} }}", segment_len);
            // A segment with a length < 255 indicates that the segment is the end of a packet.
            // Push the packet length into the packet queue for the stream.
            if segment_len < 255 {
                // trace!("  ├ packet {{ len: {} }}", packet_len);
                self.packets.push_back(packet_len);
                packet_len = 0;
            }
        }
        // Load the page's payload in the packet buffer for the stream.
        let context_slice = self.write(payload_len);
        reader.read_buf_exact(context_slice)?;
        Ok(())
    }
pub fn read < B : ByteStream > ( & mut self , reader : & mut B , page : & PageHeader ) -> Result < ( ) > { let mut payload_len = 0 ; let mut packet_len = self . write_at - self . read_from ; if packet_len > 0 && ! page . is_continuation { warn ! ( " " ) ; // Expected a continuation page to complete an incomplete packet, however this page does // not continue a previous page, therefore the incomplete packet must be dropped. packet_len = 0 ; self . write_at -= packet_len ; } // Read each segment length from the segment table and calculate length of each packet // contained within the page, and the total payload size. for _ in 0 .. page . n_segments { let segment_len = reader . read_byte ( ) ? ; packet_len += usize :: from ( segment_len ) ; payload_len += usize :: from ( segment_len ) ; // trace!("  │  ├ segment {{ len: {} }}", segment_len); // A segment with a length < 255 indicates that the segment is the end of a packet. // Push the packet length into the packet queue for the stream. if segment_len < 255 { // trace!("  ├ packet {{ len: {} }}", packet_len); self . packets . push_back ( packet_len ) ; packet_len = 0 ; } } // Load the page's payload in the packet buffer for the stream. let context_slice = self . write ( payload_len ) ; reader . read_buf_exact ( context_slice ) ? ; Ok ( ( ) ) }
Read the body of a page from the provided `ByteStream` and enqueues complete packets onto
the stream's packet queue.
Read the body of a page from the provided ` ByteStream ` and enqueues complete packets onto the stream ' s packet queue .
&mut self
reader
&mut B
page
&PageHeader