fn read_next(pos: ReadPos) -> Option<(ReadPos,Vec<u8>)> {

    // next file available?
    if fs::metadata(blk_file_name(pos.file_number + 1)).is_ok() {
        return read_next(ReadPos { file_number: pos.file_number +  1, file_position: 0 });
    }

    let name = blk_file_name(pos.file_number);

    let file = File::open(name).unwrap();
    let mut rdr = BufReader::new(file);

    let _ = rdr.seek(std::io::SeekFrom::Start(pos.file_position)).unwrap();


    let blk = blk_file::read_block(&mut rdr).unwrap();
    match blk {
        None => {
            None
        },
        Some(blk) => {
            Some( (ReadPos {
                file_number: pos.file_number,
                file_position: rdr.seek(std::io::SeekFrom::Current(0)).unwrap()

                }, blk))

        }

    }

}
/// Reads a block from the blk file position
/// This is used on live reading, as we need to reopen the file to come out of EOF position.
Reads a block from the blk file position
This is used on live reading, as we need to reopen the file to come out of EOF position.
Reads a block from the blk file position This is used on live reading as we need to reopen the file to come out of EOF position .
fn read_next(pos: ReadPos) -> Option<(ReadPos,Vec<u8>)> {
    // next file available?
    if fs::metadata(blk_file_name(pos.file_number + 1)).is_ok() {
        return read_next(ReadPos { file_number: pos.file_number +  1, file_position: 0 });
    }
    let name = blk_file_name(pos.file_number);
    let file = File::open(name).unwrap();
    let mut rdr = BufReader::new(file);
    let _ = rdr.seek(std::io::SeekFrom::Start(pos.file_position)).unwrap();
    let blk = blk_file::read_block(&mut rdr).unwrap();
    match blk {
        None => {
            None
        },
        Some(blk) => {
            Some( (ReadPos {
                file_number: pos.file_number,
                file_position: rdr.seek(std::io::SeekFrom::Current(0)).unwrap()
                }, blk))
        }
    }
}
fn read_next ( pos : ReadPos ) -> Option < ( ReadPos , Vec < u8 > ) > { // next file available? if fs :: metadata ( blk_file_name ( pos . file_number + 1 ) ) . is_ok ( ) { return read_next ( ReadPos { file_number : pos . file_number + 1 , file_position : 0 } ) ; } let name = blk_file_name ( pos . file_number ) ; let file = File :: open ( name ) . unwrap ( ) ; let mut rdr = BufReader :: new ( file ) ; let _ = rdr . seek ( std :: io :: SeekFrom :: Start ( pos . file_position ) ) . unwrap ( ) ; let blk = blk_file :: read_block ( & mut rdr ) . unwrap ( ) ; match blk { None => { None } , Some ( blk ) => { Some ( ( ReadPos { file_number : pos . file_number , file_position : rdr . seek ( std :: io :: SeekFrom :: Current ( 0 ) ) . unwrap ( ) } , blk ) ) } } }
Reads a block from the blk file position
This is used on live reading, as we need to reopen the file to come out of EOF position.
Reads a block from the blk file position This is used on live reading as we need to reopen the file to come out of EOF position .
pos
ReadPos
pos
ReadPos