RecordReader

Trait RecordReader 

Source
pub trait RecordReader: Iterator<Item = Result<Record>> {
    // Required methods
    fn read_into(&mut self, record: &mut Record) -> Result<bool>;
    fn pause(&mut self);
}
Expand description

A trait for reading BAM/SAM records.

You can use the single record:

let mut record = bam::Record::new();
loop {
   // reader: impl RecordReader
   // New record is saved into record.
   match reader.read_into(&mut record) {
       // No more records to read.
       Ok(false) => break,
       Ok(true) => {},
       Err(e) => panic!("{}", e),
   }
   // Do somethind with the record.
}

Or you can just iterate over records:

for record in reader {
   let record = record.unwrap();
   // Do somethind with the record.
}

Required Methods§

Source

fn read_into(&mut self, record: &mut Record) -> Result<bool>

Writes the next record into record. It allows to skip excessive memory allocation. If there are no more records to iterate over, the function returns false.

If the function returns an error, the record is cleared.

Source

fn pause(&mut self)

Pauses multi-thread reader until the next read operation. Does nothing to a single-thread reader.

Use with caution: pausing and unpausing takes some time.

Implementors§