[−][src]Trait bam::bam_reader::BamReader
Iterator over bam records.
You can use the single record:
let mut record = bam::Record::new(); loop { // reader: impl BamReader match reader.read_into(&mut record) { // New record is saved into record Ok(()) => {}, // NoMoreRecords represents stop iteration Err(bam::Error::NoMoreRecords) => break, 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
fn read_into(&mut self, record: &mut Record) -> Result<(), Error>
Writes the next record into record
. It allows to skip excessive memory allocation.
Errors
If there are no more records to iterate over, the function returns NoMoreRecords error.
If the record was corrupted, the function returns Corrupted error. If the record was truncated or the reading failed for a different reason, the function returns Truncated error.