noodles_bed::io::writer

Struct Writer

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

A BED writer.

Implementations§

source§

impl<const N: usize, W> Writer<N, W>

source

pub fn get_ref(&self) -> &W

Returns a reference to the underlying writer.

§Examples
use noodles_bed as bed;
let writer = bed::io::Writer::<3, _>::new(io::sink());
let _inner = writer.get_ref();
source

pub fn get_mut(&mut self) -> &mut W

Returns a mutable reference to the underlying writer.

§Examples
use noodles_bed as bed;
let mut writer = bed::io::Writer::<3, _>::new(io::sink());
let _inner = writer.get_mut();
source

pub fn into_inner(self) -> W

Returns the underlying writer.

§Examples
use noodles_bed as bed;
let writer = bed::io::Writer::<3, _>::new(io::sink());
let _inner = writer.into_inner();
source§

impl<const N: usize, W> Writer<N, W>
where W: Write,

source

pub fn new(inner: W) -> Self

Creates a BED writer.

§Examples
use noodles_bed as bed;
let writer = bed::io::Writer::<3, _>::new(io::sink());
Examples found in repository?
examples/bed_write.rs (line 12)
10
11
12
13
14
15
16
17
18
19
20
21
22
23
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let stdout = io::stdout().lock();
    let mut writer = bed::io::Writer::<3, _>::new(stdout);

    let record = RecordBuf::<3>::builder()
        .set_reference_sequence_name("sq0")
        .set_feature_start(Position::try_from(8)?)
        .set_feature_end(Position::try_from(13)?)
        .build();

    writer.write_feature_record(&record)?;

    Ok(())
}
More examples
Hide additional examples
examples/bed_view.rs (line 13)
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<W> Writer<3, W>
where W: Write,

source

pub fn write_record(&mut self, record: &Record<3>) -> Result<()>

Writes a record.

§Examples
use noodles_bed as bed;
let mut writer = bed::io::Writer::<3, _>::new(io::sink());
let record = bed::Record::default();
writer.write_record(&record)?;
Examples found in repository?
examples/bed_view.rs (line 18)
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

pub fn write_feature_record<R>(&mut self, record: &R) -> Result<()>
where R: Record<3>,

Writes a feature record.

§Examples
use noodles_bed as bed;
let mut writer = bed::io::Writer::<3, _>::new(io::sink());
let record = bed::Record::default();
writer.write_feature_record(&record)?;
Examples found in repository?
examples/bed_write.rs (line 20)
10
11
12
13
14
15
16
17
18
19
20
21
22
23
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let stdout = io::stdout().lock();
    let mut writer = bed::io::Writer::<3, _>::new(stdout);

    let record = RecordBuf::<3>::builder()
        .set_reference_sequence_name("sq0")
        .set_feature_start(Position::try_from(8)?)
        .set_feature_end(Position::try_from(13)?)
        .build();

    writer.write_feature_record(&record)?;

    Ok(())
}
source§

impl<W> Writer<4, W>
where W: Write,

source

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

Writes a record.

§Examples
use noodles_bed as bed;
let mut writer = bed::io::Writer::<4, _>::new(io::sink());
let record = bed::Record::default();
writer.write_record(&record)?;
source

pub fn write_feature_record<R>(&mut self, record: &R) -> Result<()>
where R: Record<4>,

Writes a feature record.

§Examples
use noodles_bed as bed;
let mut writer = bed::io::Writer::<4, _>::new(io::sink());
let record = bed::Record::default();
writer.write_feature_record(&record)?;
source§

impl<W> Writer<5, W>
where W: Write,

source

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

Writes a record.

§Examples
use noodles_bed as bed;
let mut writer = bed::io::Writer::<5, _>::new(io::sink());
let record = bed::Record::default();
writer.write_record(&record)?;
source

pub fn write_feature_record<R>(&mut self, record: &R) -> Result<()>
where R: Record<5>,

Writes a feature record.

§Examples
use noodles_bed as bed;
let mut writer = bed::io::Writer::<5, _>::new(io::sink());
let record = bed::Record::default();
writer.write_feature_record(&record)?;
source§

impl<W> Writer<6, W>
where W: Write,

source

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

Writes a record.

§Examples
use noodles_bed as bed;
let mut writer = bed::io::Writer::<6, _>::new(io::sink());
let record = bed::Record::default();
writer.write_record(&record)?;
source

pub fn write_feature_record<R>(&mut self, record: &R) -> Result<()>
where R: Record<6>,

Writes a feature record.

§Examples
use noodles_bed as bed;
let mut writer = bed::io::Writer::<6, _>::new(io::sink());
let record = bed::Record::default();
writer.write_feature_record(&record)?;

Auto Trait Implementations§

§

impl<const N: usize, W> Freeze for Writer<N, W>
where W: Freeze,

§

impl<const N: usize, W> RefUnwindSafe for Writer<N, W>
where W: RefUnwindSafe,

§

impl<const N: usize, W> Send for Writer<N, W>
where W: Send,

§

impl<const N: usize, W> Sync for Writer<N, W>
where W: Sync,

§

impl<const N: usize, W> Unpin for Writer<N, W>
where W: Unpin,

§

impl<const N: usize, W> UnwindSafe for Writer<N, W>
where W: 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.