pub struct StreamWriter<W: Write> { /* private fields */ }Expand description
A streaming writer for binary sequence data
This writer buffers data before writing it to the underlying writer, providing efficient streaming capabilities suitable for:
- Writing to network connections
- Processing very large datasets
- Pipeline processing
The StreamWriter is a specialized version of Writer that
adds internal buffering and is optimized for streaming scenarios.
Implementations§
Source§impl<W: Write> StreamWriter<W>
impl<W: Write> StreamWriter<W>
Sourcepub fn new(
inner: W,
header: FileHeader,
policy: Policy,
headless: bool,
) -> Result<Self>
pub fn new( inner: W, header: FileHeader, policy: Policy, headless: bool, ) -> Result<Self>
Creates a new StreamWriter with the default buffer size
This constructor initializes a StreamWriter with an 8K buffer
for efficient writing to the underlying writer.
§Arguments
inner- The writer to write binary sequence data toheader- The header defining sequence lengths and formatpolicy- The policy for handling invalid nucleotidesheadless- Whether to skip writing the header
§Returns
Ok(StreamWriter)- A new streaming writerErr(Error)- If initialization fails
Sourcepub fn with_capacity(
inner: W,
capacity: usize,
header: FileHeader,
policy: Policy,
headless: bool,
) -> Result<Self>
pub fn with_capacity( inner: W, capacity: usize, header: FileHeader, policy: Policy, headless: bool, ) -> Result<Self>
Creates a new StreamWriter with a specified buffer capacity
This constructor allows customizing the buffer size based on expected usage patterns and performance requirements.
§Arguments
inner- The writer to write binary sequence data tocapacity- The size of the internal buffer in bytesheader- The header defining sequence lengths and formatpolicy- The policy for handling invalid nucleotidesheadless- Whether to skip writing the header
§Returns
Ok(StreamWriter)- A new streaming writer with the specified buffer capacityErr(Error)- If initialization fails
pub fn write_record( &mut self, flag: Option<u64>, primary: &[u8], ) -> Result<bool>
use push method with SequencingRecord instead
pub fn write_paired_record( &mut self, flag: Option<u64>, primary: &[u8], extended: &[u8], ) -> Result<bool>
use push method with SequencingRecord instead
Sourcepub fn push(&mut self, record: SequencingRecord<'_>) -> Result<bool>
pub fn push(&mut self, record: SequencingRecord<'_>) -> Result<bool>
Writes a record using the unified SequencingRecord API
Sourcepub fn flush(&mut self) -> Result<()>
pub fn flush(&mut self) -> Result<()>
Flushes any buffered data to the underlying writer
§Returns
Ok(())- If the flush was successfulErr(Error)- If flushing failed
Sourcepub fn into_inner(self) -> Result<W>
pub fn into_inner(self) -> Result<W>
Consumes the streaming writer and returns the inner writer after flushing
This method is useful when you need access to the underlying writer after all writing is complete.
§Returns
Ok(W)- The inner writer after flushing all dataErr(Error)- If flushing failed
Auto Trait Implementations§
impl<W> Freeze for StreamWriter<W>where
W: Freeze,
impl<W> RefUnwindSafe for StreamWriter<W>where
W: RefUnwindSafe,
impl<W> Send for StreamWriter<W>where
W: Send,
impl<W> Sync for StreamWriter<W>where
W: Sync,
impl<W> Unpin for StreamWriter<W>where
W: Unpin,
impl<W> UnsafeUnpin for StreamWriter<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for StreamWriter<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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more