pub struct Reader<const N: usize, R> { /* private fields */ }
Expand description
A BED reader.
Implementations§
source§impl<R, const N: usize> Reader<N, R>
impl<R, const N: usize> Reader<N, R>
sourcepub fn get_ref(&self) -> &R
pub fn get_ref(&self) -> &R
Returns a reference to the underlying reader.
§Examples
use noodles_bed as bed;
let reader = bed::io::Reader::<3, _>::new(io::empty());
let _inner = reader.get_ref();
sourcepub fn get_mut(&mut self) -> &mut R
pub fn get_mut(&mut self) -> &mut R
Returns a mutable reference to the underlying reader.
§Examples
use noodles_bed as bed;
let mut reader = bed::io::Reader::<3, _>::new(io::empty());
let _inner = reader.get_mut();
sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Returns the underlying reader.
§Examples
use noodles_bed as bed;
let reader = bed::io::Reader::<3, _>::new(io::empty());
let _inner = reader.into_inner();
source§impl<R> Reader<3, R>where
R: BufRead,
impl<R> Reader<3, R>where
R: BufRead,
sourcepub fn read_record(&mut self, record: &mut Record<3>) -> Result<usize>
pub fn read_record(&mut self, record: &mut Record<3>) -> Result<usize>
Reads a BED3+ record.
§Examples
use noodles_bed as bed;
let mut reader = bed::io::Reader::<3, _>::new(io::empty());
let mut record = bed::Record::default();
reader.read_record(&mut record)?;
Examples found in repository?
examples/bed_count.rs (line 15)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
fn main() -> io::Result<()> {
let src = env::args().nth(1).expect("missing src");
let mut reader = bed::io::reader::Builder::<3>.build_from_path(src)?;
let mut record = bed::Record::default();
let mut n = 0;
while reader.read_record(&mut record)? != 0 {
n += 1;
}
println!("{n}");
Ok(())
}
More examples
examples/bed_view.rs (line 17)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
fn main() -> Result<(), Box<dyn std::error::Error>> {
let src = env::args().nth(1).expect("missing src");
let mut reader = bed::io::reader::Builder::<3>.build_from_path(src)?;
let stdout = io::stdout().lock();
let mut writer = bed::io::Writer::<3, _>::new(stdout);
let mut record = bed::Record::default();
while reader.read_record(&mut record)? != 0 {
writer.write_record(&record)?;
}
Ok(())
}
Auto Trait Implementations§
impl<const N: usize, R> Freeze for Reader<N, R>where
R: Freeze,
impl<const N: usize, R> RefUnwindSafe for Reader<N, R>where
R: RefUnwindSafe,
impl<const N: usize, R> Send for Reader<N, R>where
R: Send,
impl<const N: usize, R> Sync for Reader<N, R>where
R: Sync,
impl<const N: usize, R> Unpin for Reader<N, R>where
R: Unpin,
impl<const N: usize, R> UnwindSafe for Reader<N, R>where
R: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more