Struct noodles_cram::crai::Writer
source · pub struct Writer<W>where
W: Write,{ /* private fields */ }
Expand description
A CRAM index writer.
Implementations§
source§impl<W> Writer<W>where
W: Write,
impl<W> Writer<W>where
W: Write,
sourcepub fn new(inner: W) -> Self
pub fn new(inner: W) -> Self
Creates a CRAM index writer.
§Examples
use noodles_cram::crai;
let writer = crai::Writer::new(Vec::new());
sourcepub fn get_ref(&self) -> &W
pub fn get_ref(&self) -> &W
Returns a reference to the underlying writer.
§Examples
use noodles_cram::crai;
let writer = crai::Writer::new(Vec::new());
assert!(writer.get_ref().is_empty());
sourcepub fn finish(self) -> Result<W>
pub fn finish(self) -> Result<W>
Attempts to finish the output stream and returns the underlying writer.
This is typically only manually called if the underlying stream is needed before the writer is dropped.
§Examples
use noodles_cram::crai;
let writer = crai::Writer::new(Vec::new());
let empty_gz = [31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0];
assert_eq!(writer.finish()?, empty_gz);
sourcepub fn write_index(&mut self, index: &[Record]) -> Result<()>
pub fn write_index(&mut self, index: &[Record]) -> Result<()>
Writes a CRAM index.
§Examples
use noodles_core::Position;
use noodles_cram::crai;
let mut writer = crai::Writer::new(Vec::new());
let index = vec![crai::Record::new(
Some(0),
Position::new(10946),
6765,
17711,
233,
317811,
)];
writer.write_index(&index)?;
Auto Trait Implementations§
impl<W> Freeze for Writer<W>where
W: Freeze,
impl<W> RefUnwindSafe for Writer<W>where
W: RefUnwindSafe,
impl<W> Send for Writer<W>where
W: Send,
impl<W> Sync for Writer<W>where
W: Sync,
impl<W> Unpin for Writer<W>where
W: Unpin,
impl<W> UnwindSafe for Writer<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