pub fn next(&mut self) -> Result<Option<Entry>, Error> {
        if self.valid_offset + 8 > self.size {
            // we reached end of file. So, we'll truncate till valid offset.
            return Ok(None);
        }
        // check whether we have entry from the valid offset or not.
        let mut buf: [u8; 8] = [0; 8];
        self.fs.read(&mut buf)?;
        let mut current_offset = self.valid_offset + 8;
        let entry_len = decode_u64(&buf);

        if current_offset + entry_len > self.size {
            // we only persisted entry length not the entry so skipping here.
            return Ok(None);
        }
        // read the entry.
        let mut entry_buf: Vec<u8> = vec![0; entry_len as usize];
        self.fs.read(&mut entry_buf[..])?;
        current_offset = current_offset + entry_len;
        let entry = decode_entry(&entry_buf);
        // entry offset is the entry starting offset. so
        // we should always have track of previous valid offset.
        // to ensure the current starting offset.
        self.valid_entry_offset = self.valid_offset;
        // update the current valid offset.
        self.valid_offset = current_offset;
        Ok(Some(entry))
    }
/// next will iterate entry of the segment file one by one.
next will iterate entry of the segment file one by one.
next will iterate entry of the segment file one by one .
pub fn next(&mut self) -> Result<Option<Entry>, Error> {
        if self.valid_offset + 8 > self.size {
            // we reached end of file. So, we'll truncate till valid offset.
            return Ok(None);
        }
        // check whether we have entry from the valid offset or not.
        let mut buf: [u8; 8] = [0; 8];
        self.fs.read(&mut buf)?;
        let mut current_offset = self.valid_offset + 8;
        let entry_len = decode_u64(&buf);
        if current_offset + entry_len > self.size {
            // we only persisted entry length not the entry so skipping here.
            return Ok(None);
        }
        // read the entry.
        let mut entry_buf: Vec<u8> = vec![0; entry_len as usize];
        self.fs.read(&mut entry_buf[..])?;
        current_offset = current_offset + entry_len;
        let entry = decode_entry(&entry_buf);
        // entry offset is the entry starting offset. so
        // we should always have track of previous valid offset.
        // to ensure the current starting offset.
        self.valid_entry_offset = self.valid_offset;
        // update the current valid offset.
        self.valid_offset = current_offset;
        Ok(Some(entry))
    }
pub fn next ( & mut self ) -> Result < Option < Entry > , Error > { if self . valid_offset + 8 > self . size { // we reached end of file. So, we'll truncate till valid offset. return Ok ( None ) ; } // check whether we have entry from the valid offset or not. let mut buf : [ u8 ; 8 ] = [ 0 ; 8 ] ; self . fs . read ( & mut buf ) ? ; let mut current_offset = self . valid_offset + 8 ; let entry_len = decode_u64 ( & buf ) ; if current_offset + entry_len > self . size { // we only persisted entry length not the entry so skipping here. return Ok ( None ) ; } // read the entry. let mut entry_buf : Vec < u8 > = vec ! [ 0 entry_len as usize ] ; self . fs . read ( & mut entry_buf [ .. ] ) ? ; current_offset = current_offset + entry_len ; let entry = decode_entry ( & entry_buf ) ; // entry offset is the entry starting offset. so // we should always have track of previous valid offset. // to ensure the current starting offset. self . valid_entry_offset = self . valid_offset ; // update the current valid offset. self . valid_offset = current_offset ; Ok ( Some ( entry ) ) }
next will iterate entry of the segment file one by one.
next will iterate entry of the segment file one by one .
&mut self