Skip to main content

TranscodeEncodeOutput

Struct TranscodeEncodeOutput 

Source
pub struct TranscodeEncodeOutput<O>
where O: Output, O::Item: Copy + Default,
{ /* 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>
where O: Output, O::Item: Copy + Default,

Source

pub fn new(inner: O) -> Self

Creates an encoder output with the default unit buffer capacity.

§Parameters
  • inner - Unit output written by this adapter.
§Returns

A new buffered encoder output.

Source

pub fn with_capacity(inner: O, capacity: usize) -> Self

Creates an encoder output with a unit buffer of at least capacity.

§Parameters
  • inner - Unit output written by this adapter.
  • capacity - Requested internal unit buffer capacity.
§Returns

A new buffered encoder output.

Source

pub const fn inner(&self) -> &O

Returns a shared reference to the wrapped unit output.

§Returns

A shared reference to the wrapped unit output.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn ensure_spare_capacity(&mut self, count: usize) -> Result<()>

Ensures that at least count spare units are available.

§Parameters
  • count - Number of spare units required.
§Errors

Returns I/O errors from the wrapped output while flushing pending units.

Source

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.

Source

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.

Source

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>
where E: Transcoder<Value, O::Item>, M: FnMut(TranscodeError<E::Error>) -> Error,

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 inside input.
  • 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

pub fn finish<E, M, Value>( &mut self, encoder: &mut E, map_error: &mut M, ) -> Result<()>
where E: Transcoder<Value, O::Item>, M: FnMut(TranscodeError<E::Error>) -> Error,

Finishes the encoder and flushes the wrapped unit output.

§Parameters
  • encoder - Encoder whose final units are being collected.
  • map_error - Function mapping encoder errors into I/O errors.
§Errors

Returns capacity, encoder finalization, or wrapped output flush errors.

Source§

impl<O> TranscodeEncodeOutput<O>
where O: Output<Item = u8> + Seekable<Item = u8>,

Source

pub fn seek(&mut self, position: SeekFrom) -> Result<u64>

Flushes pending bytes, then seeks the wrapped byte output.

§Parameters
  • position - Target seek position.
§Returns

The new stream position reported by the wrapped output.

§Errors

Returns flush or seek errors from the wrapped output.

Trait Implementations§

Source§

impl<O> Debug for TranscodeEncodeOutput<O>
where O: Output, O::Item: Copy + Default, BufferedOutput<O>: Debug,

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats this buffered encode output for debugging.

Source§

impl<O> Seek for TranscodeEncodeOutput<O>
where O: Output<Item = u8> + Seekable<Item = u8>,

Source§

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>

Rewind to the beginning of a stream. Read more
Source§

fn stream_len(&mut self) -> Result<u64, Error>

🔬This is a nightly-only experimental API. (seek_stream_len)
Returns the length of this stream (in bytes). Read more
1.51.0 · Source§

fn stream_position(&mut self) -> Result<u64, Error>

Returns the current seek position from the start of the stream. Read more
1.80.0 · Source§

fn seek_relative(&mut self, offset: i64) -> Result<(), Error>

Seeks relative to the current position. Read more
Source§

impl<O> Write for TranscodeEncodeOutput<O>
where O: Output<Item = u8>,

Source§

fn write(&mut self, input: &[u8]) -> Result<usize>

Writes raw bytes through the internal buffer.

Source§

fn write_all(&mut self, input: &[u8]) -> Result<()>

Writes all raw bytes through the internal buffer.

Source§

fn flush(&mut self) -> Result<()>

Flushes buffered bytes to the wrapped output.

1.36.0 · Source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations§

§

impl<O> Freeze for TranscodeEncodeOutput<O>
where <O as Output>::Item: Sized, O: Freeze,

§

impl<O> RefUnwindSafe for TranscodeEncodeOutput<O>

§

impl<O> Send for TranscodeEncodeOutput<O>
where <O as Output>::Item: Sized + Send, O: Send,

§

impl<O> Sync for TranscodeEncodeOutput<O>
where <O as Output>::Item: Sized + Sync, O: Sync,

§

impl<O> Unpin for TranscodeEncodeOutput<O>
where <O as Output>::Item: Sized + Unpin, O: Unpin,

§

impl<O> UnsafeUnpin for TranscodeEncodeOutput<O>
where <O as Output>::Item: Sized, O: UnsafeUnpin,

§

impl<O> UnwindSafe for TranscodeEncodeOutput<O>
where <O as Output>::Item: Sized + UnwindSafe, O: 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<W> Output for W
where W: Write + ?Sized,

Source§

unsafe fn write_unchecked( &mut self, input: &[u8], index: usize, count: usize, ) -> Result<usize, Error>

Writes bytes to a standard Write value from an indexed range.

Source§

fn write(&mut self, input: &[<W as Output>::Item]) -> Result<usize, Error>

Writes items into the full output slice.

Source§

fn flush(&mut self) -> Result<(), Error>

Flushes a standard Write value.

Source§

type Item = u8

The item type written to this output.
Source§

impl<T> OutputExt for T
where T: Output + ?Sized,

Source§

fn write_all(&mut self, input: &[Self::Item]) -> Result<(), Error>

Writes all items from the full input slice. Read more
Source§

unsafe fn write_all_unchecked( &mut self, input: &[Self::Item], index: usize, count: usize, ) -> Result<(), Error>

Writes all items from an indexed input range without checking the range. Read more
Source§

impl<T> SeekExt for T
where T: Seek + ?Sized,

Source§

fn stream_size(&mut self) -> Result<u64, Error>

Gets the stream size without changing the final stream position. Read more
Source§

impl<S> Seekable for S
where S: Seek + ?Sized,

Source§

fn seek_to(&mut self, position: SeekFrom) -> Result<u64, Error>

Seeks a standard Seek value using byte offsets.

Source§

type Item = u8

The item type used to measure seek positions and offsets.
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.
Source§

impl<T> WriteExt for T
where T: Write + ?Sized,

Source§

unsafe fn write_unchecked( &mut self, buffer: &[u8], start_index: usize, count: usize, ) -> Result<usize, Error>

Writes bytes from a range of buffer without checking the range bounds in release builds. Read more
Source§

unsafe fn write_all_unchecked( &mut self, buffer: &[u8], start_index: usize, count: usize, ) -> Result<(), Error>

Writes exactly count bytes from a range of buffer without checking the range bounds in release builds. Read more
Source§

impl<T> WriteSeek for T
where T: Write + Seek + ?Sized,

Source§

impl<T> WriteSeekExt for T
where T: Write + Seek + ?Sized,

Source§

fn write_all_at_preserving_position( &mut self, offset: u64, buffer: &[u8], ) -> Result<(), Error>

Writes all bytes at offset and restores the original position. Read more