mod builder;
pub use self::builder::Builder;
use std::io::{self, BufRead, Seek};
use noodles_core::Region;
use super::Reader;
use crate::{fai, Record};
pub struct IndexedReader<R> {
inner: Reader<R>,
index: fai::Index,
}
impl<R> IndexedReader<R>
where
R: BufRead,
{
pub fn new(inner: R, index: fai::Index) -> Self {
Self {
inner: Reader::new(inner),
index,
}
}
pub fn get_ref(&self) -> &R {
self.inner.get_ref()
}
pub fn get_mut(&mut self) -> &mut R {
self.inner.get_mut()
}
pub fn into_inner(self) -> R {
self.inner.into_inner()
}
pub fn read_definition(&mut self, buf: &mut String) -> io::Result<usize> {
self.inner.read_definition(buf)
}
pub fn read_sequence(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
self.inner.read_sequence(buf)
}
pub fn index(&self) -> &fai::Index {
&self.index
}
}
impl<R> IndexedReader<R>
where
R: BufRead + Seek,
{
pub fn query(&mut self, region: &Region) -> io::Result<Record> {
self.inner.query(&self.index, region)
}
}