[][src]Trait bam::RecordReader

pub trait RecordReader: Iterator<Item = Result<Record, Error>> {
    fn read_into(&mut self, record: &mut Record) -> Result<(), Error>;
}

A trait for reading BAM/SAM records.

You can use the single record:

let mut record = bam::Record::new();
loop {
   // reader: impl RecordReader
   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.

If the function returns an error, the record is supposed to be cleared.

Loading content...

Implementors

impl<'a, R: Read + Seek> RecordReader for RegionViewer<'a, R>[src]

impl<R: BufRead> RecordReader for SamReader<R>[src]

impl<R: Read> RecordReader for BamReader<R>[src]

Loading content...