noodles_bed::io::reader

Struct Reader

source
pub struct Reader<const N: usize, R> { /* private fields */ }
Expand description

A BED reader.

Implementations§

source§

impl<R, const N: usize> Reader<N, R>

source

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();
source

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();
source

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<const N: usize, R> Reader<N, R>
where R: BufRead,

source

pub fn new(inner: R) -> Self

Creates a BED reader.

§Examples
use noodles_bed as bed;
let reader = bed::io::Reader::<3, _>::new(io::empty());
source§

impl<R> Reader<3, R>
where R: BufRead,

source

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
Hide additional 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(())
}
source§

impl<R> Reader<4, R>
where R: BufRead,

source

pub fn read_record(&mut self, record: &mut Record<4>) -> Result<usize>

Reads a BED4+ record.

§Examples
use noodles_bed as bed;
let mut reader = bed::io::Reader::<4, _>::new(io::empty());
let mut record = bed::Record::default();
reader.read_record(&mut record)?;
source§

impl<R> Reader<5, R>
where R: BufRead,

source

pub fn read_record(&mut self, record: &mut Record<5>) -> Result<usize>

Reads a BED5+ record.

§Examples
use noodles_bed as bed;
let mut reader = bed::io::Reader::<5, _>::new(io::empty());
let mut record = bed::Record::default();
reader.read_record(&mut record)?;
source§

impl<R> Reader<6, R>
where R: BufRead,

source

pub fn read_record(&mut self, record: &mut Record<6>) -> Result<usize>

Reads a BED6+ record.

§Examples
use noodles_bed as bed;
let mut reader = bed::io::Reader::<6, _>::new(io::empty());
let mut record = bed::Record::default();
reader.read_record(&mut record)?;

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.