Skip to main content

TranscodeDecodeInput

Struct TranscodeDecodeInput 

Source
pub struct TranscodeDecodeInput<I>
where I: Input, I::Item: Copy + Default,
{ /* private fields */ }
Expand description

Decodes an Input unit stream into an Input value stream.

This type owns only the unit-level qubit_io::BufferedInput. Callers pass a streaming Transcoder and error mapper to each decode operation, which lets one buffered input drive different decoders without nesting buffers or storing decoder-specific state in the buffer owner.

§Type Parameters

  • I - Wrapped unit input.

Implementations§

Source§

impl<I> TranscodeDecodeInput<I>
where I: Input, I::Item: Copy + Default,

Source

pub fn new(inner: I) -> Self

Creates a decoder input with the default unit buffer capacity.

§Parameters
  • inner - Unit input read by this adapter.
§Returns

A new buffered decoder input.

Source

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

Creates a decoder input with a unit buffer of at least capacity.

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

A new buffered decoder input.

Source

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

Returns a shared reference to the wrapped unit input.

§Returns

A shared reference to the wrapped unit input.

Source

pub fn inner_mut(&mut self) -> &mut I

Returns a mutable reference to the wrapped unit input.

§Returns

A mutable reference to the wrapped unit input.

Source

pub fn available(&self) -> usize

Returns the number of unread units currently buffered.

§Returns

The number of unread units in the internal buffer.

Source

pub fn unread(&self) -> &[I::Item]

Returns the currently buffered unread units.

§Returns

Returns a shared slice over the unread portion of the internal unit buffer. The slice is valid until this adapter is mutated.

Source

pub fn capacity(&self) -> usize

Returns the internal unit buffer capacity.

§Returns

The maximum number of units retained in the internal buffer.

Source

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

Refills the internal buffer until at least count unread units are available.

§Parameters
  • count - Minimum number of unread units required.
§Errors

Returns I/O errors from the wrapped input while refilling.

Source

pub fn consume(&mut self, count: usize)

Consumes unread units from the current buffer window.

§Parameters
  • count - Number of unread units to discard.
§Panics

In debug builds, panics when count exceeds Self::available.

Source

pub unsafe fn copy_unread_to( &mut self, output: &mut [I::Item], output_index: usize, count: usize, )

Copies unread units into an indexed output range without consuming them.

§Parameters
  • output - Destination storage that receives a copy of unread units.
  • output_index - Start index inside output.
  • count - Number of unread units to copy.
§Safety

The caller must guarantee that output_index..output_index + count is a valid range inside output, that the addition does not overflow, that count <= self.available(), and that the destination range does not overlap with the unread units stored inside this buffer.

Source

pub fn into_parts(self) -> (I, Buffer<I::Item>)

Consumes this adapter and returns its parts.

§Returns

The wrapped input and the buffer holding unread units.

Source

pub unsafe fn read_unchecked( &mut self, output: &mut [I::Item], output_index: usize, count: usize, ) -> Result<usize>

Reads buffered units into an indexed output range.

§Parameters
  • output - Destination unit storage.
  • output_index - Start index inside output.
  • count - Maximum number of units to read.
§Returns

The number of units copied into output.

§Errors

Returns input or buffer validation errors from the wrapped qubit_io::BufferedInput.

§Safety

The caller must guarantee that output_index..output_index + count is a valid range inside output and that the addition does not overflow.

Source

pub fn transcode_into<D, M, Value>( &mut self, decoder: &mut D, map_error: &mut M, output: &mut [Value], output_index: usize, count: usize, ) -> Result<usize>
where D: Transcoder<I::Item, Value>, M: FnMut(TranscodeError<D::Error>) -> Error,

Decodes values into an indexed output range using a streaming Transcoder.

§Parameters
  • decoder - Streaming decoder used for this operation.
  • map_error - Function mapping decoder errors into I/O errors.
  • output - Destination value storage.
  • output_index - Start index inside output.
  • count - Maximum number of values to write.
§Returns

The number of values written. Incomplete EOF tails are left buffered and reported as Ok(written), so callers can apply their own EOF policy.

§Errors

Returns input errors, invalid output ranges, capacity errors from the internal buffer, or decoder errors mapped by map_error.

Source

pub fn finish_transcode_into<D, M, Value>( &mut self, decoder: &mut D, map_error: &mut M, output: &mut [Value], output_index: usize, count: usize, ) -> Result<usize>
where D: Transcoder<I::Item, Value>, M: FnMut(TranscodeError<D::Error>) -> Error,

Finishes a streaming decoder into an indexed output range.

§Parameters
  • decoder - Streaming decoder whose final output is being collected.
  • map_error - Function mapping decoder errors into I/O errors.
  • output - Destination value storage.
  • output_index - Start index inside output.
  • count - Maximum number of finish values to write.
§Returns

The number of values written by the decoder finish operation.

§Errors

Returns invalid output ranges, capacity errors, or decoder finalization errors mapped to I/O errors.

Source§

impl<I> TranscodeDecodeInput<I>
where I: Input<Item = u8> + Seekable<Item = u8>,

Source

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

Seeks the wrapped byte input and discards buffered bytes after success.

§Parameters
  • position - Target seek position.
§Returns

The new stream position reported by the wrapped input.

§Errors

Returns seek errors from the wrapped input.

Trait Implementations§

Source§

impl<I> Debug for TranscodeDecodeInput<I>
where I: Input, I::Item: Copy + Default, BufferedInput<I>: Debug,

Source§

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

Formats this buffered decode input for debugging.

Source§

impl<I> Read for TranscodeDecodeInput<I>
where I: Input<Item = u8>,

Source§

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

Reads raw bytes through the internal buffer.

1.36.0 · Source§

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

Like read, except that it reads into a slice of buffers. Read more
Source§

fn is_read_vectored(&self) -> bool

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

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>

Reads all bytes until EOF in this source, placing them into buf. Read more
1.0.0 · Source§

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>

Reads all bytes until EOF in this source, appending them to buf. Read more
1.6.0 · Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>

Reads the exact number of bytes required to fill buf. Read more
Source§

fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
Source§

fn read_buf_exact( &mut self, cursor: BorrowedCursor<'_, u8>, ) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Reads the exact number of bytes required to fill cursor. 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 Read. Read more
1.0.0 · Source§

fn bytes(self) -> Bytes<Self>
where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
1.0.0 · Source§

fn chain<R>(self, next: R) -> Chain<Self, R>
where R: Read, Self: Sized,

Creates an adapter which will chain this stream with another. Read more
1.0.0 · Source§

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. Read more
Source§

fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>
where Self: Sized,

🔬This is a nightly-only experimental API. (read_array)
Read and return a fixed array of bytes from this source. Read more
Source§

fn read_le<T>(&mut self) -> Result<T, Error>
where T: FromEndianBytes, Self: Sized,

🔬This is a nightly-only experimental API. (read_le)
Read and return a type (e.g. an integer) in little-endian order. Read more
Source§

fn read_be<T>(&mut self) -> Result<T, Error>
where T: FromEndianBytes, Self: Sized,

🔬This is a nightly-only experimental API. (read_le)
Read and return a type (e.g. an integer) in big-endian order. Read more
Source§

impl<I> Seek for TranscodeDecodeInput<I>
where I: Input<Item = u8> + Seekable<Item = u8>,

Source§

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

Seeks the wrapped byte input and discards buffered bytes after success.

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

Auto Trait Implementations§

§

impl<I> Freeze for TranscodeDecodeInput<I>
where <I as Input>::Item: Sized, I: Freeze,

§

impl<I> RefUnwindSafe for TranscodeDecodeInput<I>

§

impl<I> Send for TranscodeDecodeInput<I>
where <I as Input>::Item: Sized + Send, I: Send,

§

impl<I> Sync for TranscodeDecodeInput<I>
where <I as Input>::Item: Sized + Sync, I: Sync,

§

impl<I> Unpin for TranscodeDecodeInput<I>
where <I as Input>::Item: Sized + Unpin, I: Unpin,

§

impl<I> UnsafeUnpin for TranscodeDecodeInput<I>
where <I as Input>::Item: Sized, I: UnsafeUnpin,

§

impl<I> UnwindSafe for TranscodeDecodeInput<I>
where <I as Input>::Item: Sized + UnwindSafe, I: 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<R> Input for R
where R: Read + ?Sized,

Source§

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

Reads bytes from a standard Read value into an indexed range.

Source§

fn read(&mut self, output: &mut [<R as Input>::Item]) -> Result<usize, Error>

Reads items into the full output slice.

Source§

type Item = u8

The item type read from this input.
Source§

impl<T> InputExt for T
where T: Input + ?Sized,

Source§

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

Reads exactly enough items to fill output. Read more
Source§

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

Reads exactly count items into an indexed output range without checking the range bounds in release builds. Read more
Source§

fn read_exact_or_eof( &mut self, output: &mut [Self::Item], ) -> Result<usize, Error>

Reads items until output is full or EOF is reached. Read more
Source§

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

Reads items into an indexed output range until that range is full or EOF is reached, without checking the range bounds in release builds. Read more
Source§

fn copy_to<O>(&mut self, output: &mut O) -> Result<u64, Error>
where O: Output<Item = Self::Item> + ?Sized, Self::Item: Copy + Default,

Copies all remaining items from this input into output. Read more
Source§

fn copy_to_at_most<O>( &mut self, output: &mut O, max_units: u64, ) -> Result<u64, Error>
where O: Output<Item = Self::Item> + ?Sized, Self::Item: Copy + Default,

Copies at most max_units items from this input into output. Read more
Source§

fn copy_to_end_limited<O>( &mut self, output: &mut O, max_units: u64, ) -> Result<u64, Error>
where O: Output<Item = Self::Item> + ?Sized, Self::Item: Copy + Default,

Copies the remaining input if its total length is at most max_units. Read more
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<T> ReadExt for T
where T: Read + ?Sized,

Source§

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

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

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

Reads bytes into a range of buffer until that range is full or EOF is reached, without checking the range bounds in release builds. Read more
Source§

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

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

fn read_exact_or_eof(&mut self, buffer: &mut [u8]) -> Result<usize, Error>

Reads bytes until buffer is full or EOF is reached. Read more
Source§

fn read_exact_array<const N: usize>(&mut self) -> Result<[u8; N], Error>

Reads exactly N bytes into a stack-allocated array. Read more
Source§

fn read_exact_vec_limited( &mut self, len: usize, max_len: usize, ) -> Result<Vec<u8>, Error>

Reads exactly len bytes into a new vector after checking a limit. Read more
Source§

fn read_exact_vec_limited_into( &mut self, output: &mut Vec<u8>, len: usize, max_len: usize, ) -> Result<(), Error>

Reads exactly len bytes and appends them to output. Read more
Source§

fn discard_exact_or_eof(&mut self, bytes: u64) -> Result<u64, Error>

Discards up to bytes bytes from this reader. Read more
Source§

fn copy_to(&mut self, writer: &mut dyn Write) -> Result<u64, Error>

Copies all remaining bytes from this reader into writer. Read more
Source§

fn copy_to_at_most( &mut self, writer: &mut dyn Write, max_bytes: u64, ) -> Result<u64, Error>

Copies at most max_bytes bytes from this reader into writer. Read more
Source§

fn copy_to_end_limited( &mut self, writer: &mut dyn Write, max_bytes: u64, ) -> Result<u64, Error>

Copies the remaining input if its total length is at most max_bytes. Read more
Source§

fn read_to_end_limited(&mut self, max_len: usize) -> Result<Vec<u8>, Error>

Reads the remaining bytes into a vector with a maximum accepted length. Read more
Source§

fn read_to_end_limited_into( &mut self, output: &mut Vec<u8>, max_len: usize, ) -> Result<usize, Error>

Reads the remaining bytes into output with a maximum accepted length. Read more
Source§

fn read_to_string_limited(&mut self, max_len: usize) -> Result<String, Error>

Reads the remaining bytes as UTF-8 text with a maximum accepted length. Read more
Source§

fn read_to_string_limited_into( &mut self, output: &mut String, max_len: usize, ) -> Result<usize, Error>

Reads the remaining bytes as UTF-8 text and appends to output. Read more
Source§

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

Source§

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

Source§

fn peek_exact_or_eof(&mut self, buffer: &mut [u8]) -> Result<usize, Error>

Reads from the current position and restores the original position. Read more
Source§

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

Reads from offset and restores the original position. 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.