pub fn read_to_next<W: Write>(self, write: &mut W) -> Result<Option<LogEntry<'l>>, LogError> {
        let LogEntry { log, index } = self;
        let len = log.file.read_u64()?;

        let mut hasher = crc32fast::Hasher::new();

        {
            let mut bytes_left: usize = len
                .try_into()
                .expect("Log entry is too large to read on a 32 bit platform.");
            let mut buf = [0; 8 * 1024];

            while bytes_left > 0 {
                let read = bytes_left.min(buf.len());
                let read = log.file.read(&mut buf[..read])?;

                hasher.update(&buf[..read]);
                write.write_all(&buf[..read])?;

                bytes_left -= read;
            }
        }

        let checksum = log.file.read_u32()?;

        if checksum != hasher.finalize() {
            return Err(LogError::BadChecksum);
        }

        let next_index = index + 1;

        if log.first_index + log.len > next_index {
            Ok(Some(LogEntry {
                log,
                index: next_index,
            }))
        } else {
            Ok(None)
        }
    }
/// Reads into the io::Write and returns the next log entry if in-bounds.
Reads into the io::Write and returns the next log entry if in-bounds.
Reads into the io :: Write and returns the next log entry if in - bounds .
pub fn read_to_next<W: Write>(self, write: &mut W) -> Result<Option<LogEntry<'l>>, LogError> {
        let LogEntry { log, index } = self;
        let len = log.file.read_u64()?;
        let mut hasher = crc32fast::Hasher::new();
        {
            let mut bytes_left: usize = len
                .try_into()
                .expect("Log entry is too large to read on a 32 bit platform.");
            let mut buf = [0; 8 * 1024];
            while bytes_left > 0 {
                let read = bytes_left.min(buf.len());
                let read = log.file.read(&mut buf[..read])?;
                hasher.update(&buf[..read]);
                write.write_all(&buf[..read])?;
                bytes_left -= read;
            }
        }
        let checksum = log.file.read_u32()?;
        if checksum != hasher.finalize() {
            return Err(LogError::BadChecksum);
        }
        let next_index = index + 1;
        if log.first_index + log.len > next_index {
            Ok(Some(LogEntry {
                log,
                index: next_index,
            }))
        } else {
            Ok(None)
        }
    }
pub fn read_to_next < W : Write > ( self , write : & mut W ) -> Result < Option < LogEntry < ' l > > , LogError > { let LogEntry { log , index } = self ; let len = log . file . read_u64 ( ) ? ; let mut hasher = crc32fast :: Hasher :: new ( ) ; { let mut bytes_left : usize = len . try_into ( ) . expect ( " " ) ; let mut buf = [ 0 ; 8 * 1024 ] ; while bytes_left > 0 { let read = bytes_left . min ( buf . len ( ) ) ; let read = log . file . read ( & mut buf [ .. read ] ) ? ; hasher . update ( & buf [ .. read ] ) ; write . write_all ( & buf [ .. read ] ) ? ; bytes_left -= read ; } } let checksum = log . file . read_u32 ( ) ? ; if checksum != hasher . finalize ( ) { return Err ( LogError :: BadChecksum ) ; } let next_index = index + 1 ; if log . first_index + log . len > next_index { Ok ( Some ( LogEntry { log , index : next_index , } ) ) } else { Ok ( None ) } }
Reads into the io::Write and returns the next log entry if in-bounds.
Reads into the io :: Write and returns the next log entry if in - bounds .
self
write
&mut W