pub struct Writer<const N: usize, W> { /* private fields */ }
Expand description
A BED writer.
Implementations§
source§impl<const N: usize, W> Writer<N, W>
impl<const N: usize, W> Writer<N, W>
sourcepub fn get_ref(&self) -> &W
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();
sourcepub fn get_mut(&mut self) -> &mut W
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();
sourcepub fn into_inner(self) -> W
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,
impl<const N: usize, W> Writer<N, W>where
W: Write,
sourcepub fn new(inner: W) -> Self
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
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,
impl<W> Writer<3, W>where
W: Write,
sourcepub fn write_record(&mut self, record: &Record<3>) -> Result<()>
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(())
}
sourcepub fn write_feature_record<R>(&mut self, record: &R) -> Result<()>where
R: Record<3>,
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,
impl<W> Writer<4, W>where
W: Write,
source§impl<W> Writer<5, W>where
W: Write,
impl<W> Writer<5, W>where
W: Write,
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> 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