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.
}