fn read_bytes()

in src/connection.rs [142:161]


    fn read_bytes(&mut self) -> Result<usize, ConnectionError> {
        if self.read_cursor >= BUFFER_SIZE {
            return Err(ConnectionError::ParseError(RequestError::Overflow));
        }
        // Append new bytes to what we already have in the buffer.
        // The slice access is safe, the index is checked above.
        let (bytes_read, new_files) = self.recv_with_fds()?;

        // Update the internal list of files that must be associated with the
        // request.
        self.files.extend(new_files);

        // If the read returned 0 then the client has closed the connection.
        if bytes_read == 0 {
            return Err(ConnectionError::ConnectionClosed);
        }
        bytes_read
            .checked_add(self.read_cursor)
            .ok_or(ConnectionError::ParseError(RequestError::Overflow))
    }