Trait bam::RecordReader[][src]

pub trait RecordReader: Iterator<Item = Result<Record>> {
    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

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.

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