pub struct TranscodeEncodeOutput<O>{ /* private fields */ }Expand description
Encodes an Output value stream into an Output unit stream.
This type owns only the unit-level qubit_io::BufferedOutput. Callers
pass a crate::Codec and error mapper to each encode operation, which
lets one buffered output drive different encoders without nesting buffers or
storing codec-specific state in the buffer owner.
Self::flush only drains already buffered units. State-aware streaming
encoders can use Self::transcode_from and Self::finish explicitly.
§Type Parameters
O- Wrapped unit output.
Implementations§
Source§impl<O> TranscodeEncodeOutput<O>
impl<O> TranscodeEncodeOutput<O>
Sourcepub fn with_capacity(inner: O, capacity: usize) -> Self
pub fn with_capacity(inner: O, capacity: usize) -> Self
Sourcepub const fn inner(&self) -> &O
pub const fn inner(&self) -> &O
Returns a shared reference to the wrapped unit output.
§Returns
A shared reference to the wrapped unit output.
Sourcepub fn inner_mut(&mut self) -> &mut O
pub fn inner_mut(&mut self) -> &mut O
Returns a mutable reference to the wrapped unit output.
§Returns
A mutable reference to the wrapped unit output.
Sourcepub fn spare_capacity(&self) -> usize
pub fn spare_capacity(&self) -> usize
Returns the available capacity of the spare output buffer.
§Returns
The number of output units that can still be appended without flushing.
Sourcepub fn spare_raw_parts_mut(&mut self) -> (&mut [O::Item], usize, usize)
pub fn spare_raw_parts_mut(&mut self) -> (&mut [O::Item], usize, usize)
Returns raw spare-buffer parts for the internal output buffer.
§Returns
The full backing storage, the spare start index, and the spare unit count.
Sourcepub unsafe fn advance(&mut self, count: usize)
pub unsafe fn advance(&mut self, count: usize)
Marks count units from Self::spare_raw_parts_mut as written.
§Safety
The caller must guarantee that count <= Self::spare_capacity() and
that the corresponding units in the returned spare slice have been
initialized.
Sourcepub fn ensure_spare_capacity(&mut self, count: usize) -> Result<()>
pub fn ensure_spare_capacity(&mut self, count: usize) -> Result<()>
Sourcepub fn into_parts(self) -> (O, Buffer<O::Item>)
pub fn into_parts(self) -> (O, Buffer<O::Item>)
Consumes this adapter and returns its parts.
§Returns
The wrapped output and the buffer holding pending units.
Sourcepub fn flush(&mut self) -> Result<()>
pub fn flush(&mut self) -> Result<()>
Flushes buffered units without finishing any encoder stream.
§Errors
Returns errors from the wrapped output while flushing pending units.
Sourcepub fn transcode_from<E, M, Value>(
&mut self,
encoder: &mut E,
map_error: &mut M,
input: &[Value],
input_index: usize,
count: usize,
) -> Result<usize>
pub fn transcode_from<E, M, Value>( &mut self, encoder: &mut E, map_error: &mut M, input: &[Value], input_index: usize, count: usize, ) -> Result<usize>
Encodes values from an indexed input range using a streaming
Transcoder.
§Parameters
encoder- Streaming encoder used for this operation.map_error- Function mapping encoder errors into I/O errors.input- Source values.input_index- Start index insideinput.count- Maximum number of values to encode.
§Returns
The number of source values consumed.
§Errors
Returns invalid input ranges, capacity, encoder, or output errors.
Source§impl<O> TranscodeEncodeOutput<O>
impl<O> TranscodeEncodeOutput<O>
Trait Implementations§
Source§impl<O> Debug for TranscodeEncodeOutput<O>
impl<O> Debug for TranscodeEncodeOutput<O>
Source§impl<O> Seek for TranscodeEncodeOutput<O>
impl<O> Seek for TranscodeEncodeOutput<O>
Source§fn seek(&mut self, position: SeekFrom) -> Result<u64>
fn seek(&mut self, position: SeekFrom) -> Result<u64>
Flushes pending bytes, then seeks the wrapped byte output.
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len)Source§impl<O> Write for TranscodeEncodeOutput<O>
impl<O> Write for TranscodeEncodeOutput<O>
Source§fn write(&mut self, input: &[u8]) -> Result<usize>
fn write(&mut self, input: &[u8]) -> Result<usize>
Writes raw bytes through the internal buffer.
Source§fn write_all(&mut self, input: &[u8]) -> Result<()>
fn write_all(&mut self, input: &[u8]) -> Result<()>
Writes all raw bytes through the internal buffer.
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)