pub struct TranscodeDecodeInput<I>{ /* 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>
impl<I> TranscodeDecodeInput<I>
Sourcepub fn with_capacity(inner: I, capacity: usize) -> Self
pub fn with_capacity(inner: I, capacity: usize) -> Self
Sourcepub fn try_with_capacity(
inner: I,
capacity: usize,
) -> Result<Self, TryReserveError>
pub fn try_with_capacity( inner: I, capacity: usize, ) -> Result<Self, TryReserveError>
Sourcepub const fn inner(&self) -> &I
pub const fn inner(&self) -> &I
Returns a shared reference to the wrapped unit input.
The wrapped input can be physically positioned after units that remain unread in this adapter’s internal buffer.
§Returns
A shared reference to the wrapped unit input.
Sourcepub fn unread_len(&self) -> usize
pub fn unread_len(&self) -> usize
Returns the number of unread units currently buffered.
§Returns
The number of unread units in the internal buffer.
Sourcepub fn unread(&self) -> &[I::Item]
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.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the internal unit buffer capacity.
§Returns
The maximum number of units retained in the internal buffer.
Sourcepub fn fill_until(&mut self, count: usize) -> Result<bool>
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 allocation errors mapped to ErrorKind::OutOfMemory, or I/O
errors from the wrapped input while refilling.
Sourcepub fn transcode_step<D, M, Value>(
&mut self,
decoder: &mut D,
map_error: &mut M,
output: &mut [Value],
output_index: usize,
count: usize,
) -> Result<Option<TranscodeProgress>>
pub fn transcode_step<D, M, Value>( &mut self, decoder: &mut D, map_error: &mut M, output: &mut [Value], output_index: usize, count: usize, ) -> Result<Option<TranscodeProgress>>
Performs one decode step and preserves the transcoder stop status.
None means that the wrapped input reached EOF with no buffered units.
Consumed input is committed before this method returns. Callers can use
the returned TranscodeProgress to distinguish NeedOutput from an
incomplete input tail without guessing from the unread buffer alone.
Sourcepub fn consume(&mut self, count: usize)
pub fn consume(&mut self, count: usize)
Consumes unread units from the current buffer window.
§Parameters
count- Number of unread units to discard.
§Panics
Panics when count exceeds Self::unread_len.
Sourcepub unsafe fn copy_unread_to(
&self,
output: &mut [I::Item],
output_index: usize,
count: usize,
)
pub unsafe fn copy_unread_to( &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 insideoutput.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.unread_len(), and that the destination range does not
overlap with the unread units stored inside this buffer.
Sourcepub fn into_parts(self) -> (I, Buffer<I::Item>)
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.
Sourcepub unsafe fn read_unchecked(
&mut self,
output: &mut [I::Item],
output_index: usize,
count: usize,
) -> Result<usize>
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 insideoutput.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.
Sourcepub fn read_decoded_with<C, M>(
&mut self,
codec: &mut C,
map_error: M,
) -> Result<C::Value>
pub fn read_decoded_with<C, M>( &mut self, codec: &mut C, map_error: M, ) -> Result<C::Value>
Decodes one codec value from the buffered unit input.
This strict convenience method supports codecs whose decode reset and
finish phases do not emit values. Use
Self::read_decoded_lifecycle_with when those phases have output.
§Parameters
codec- Codec used for this single-value decode.map_error- Mapper for codec-domain invalid-input errors.
§Returns
Returns one decoded codec value.
§Errors
Returns ErrorKind::Unsupported before invoking the codec or reading
input when reset or finish may emit values. Otherwise, returns I/O
errors from the wrapped input, UnexpectedEof when EOF occurs before a
complete value is available, InvalidData when the codec reports an
impossible incomplete state, or the error returned by map_error for
codec reset, invalid input, or codec finish failures.
§Panics
Panics when the codec reports more reset or finish values than its declared bounds.
Sourcepub fn read_decoded_lifecycle_with<C, M>(
&mut self,
codec: &mut C,
map_error: M,
) -> Result<DecodeLifecycleOutput<C::Value>>
pub fn read_decoded_lifecycle_with<C, M>( &mut self, codec: &mut C, map_error: M, ) -> Result<DecodeLifecycleOutput<C::Value>>
Decodes one complete codec lifecycle and preserves every output phase.
The method allocates independent storage for values emitted by
decode_reset and decode_finish, so neither phase can overwrite the
other.
§Parameters
codec: Codec used to decode one complete lifecycle.map_error: Maps codec decode errors to I/O errors.
§Returns
Returns reset output, the main decoded value, and finish output.
§Errors
Returns I/O errors from the wrapped input, UnexpectedEof when EOF
occurs before a complete value is available, InvalidData when the
codec reports an impossible incomplete state, or the error returned
by map_error for codec reset, invalid input, or codec finish failures.
§Panics
Panics when the codec reports more reset or finish values than its declared bounds.
Sourcepub fn read_decoded_lifecycle_with_scratch<C, M>(
&mut self,
codec: &mut C,
reset_output: &mut [C::Value],
finish_output: &mut [C::Value],
map_error: M,
) -> Result<DecodeLifecycleProgress<C::Value>>
pub fn read_decoded_lifecycle_with_scratch<C, M>( &mut self, codec: &mut C, reset_output: &mut [C::Value], finish_output: &mut [C::Value], map_error: M, ) -> Result<DecodeLifecycleProgress<C::Value>>
Decodes one complete codec lifecycle into separate caller storage.
§Parameters
codec: Codec used to decode one complete lifecycle.reset_output: Reusable storage for values emitted byCodec::decode_reset.finish_output: Reusable storage for values emitted byCodec::decode_finish.map_error: Maps codec decode errors to I/O errors.
§Returns
Returns the main decoded value and the initialized lengths of both lifecycle output buffers.
§Errors
Returns ErrorKind::InvalidInput when either output buffer is shorter
than the corresponding codec bound. Returns I/O errors from the wrapped
input, UnexpectedEof when EOF occurs before a complete value is
available, InvalidData when the codec reports an impossible
incomplete state, or the error returned by map_error for codec reset,
invalid input, or codec finish failures.
§Panics
Panics when the codec reports more reset or finish values than its declared bounds.
Sourcepub fn reset<D, M, Value>(
&self,
decoder: &mut D,
map_error: &mut M,
output: &mut [Value],
output_index: usize,
count: usize,
) -> Result<usize>
pub fn reset<D, M, Value>( &self, decoder: &mut D, map_error: &mut M, output: &mut [Value], output_index: usize, count: usize, ) -> Result<usize>
Runs decoder reset into an indexed output range.
This method does not read or consume buffered input units.
§Errors
Returns invalid output ranges, insufficient declared output capacity,
capacity errors, or reset errors mapped by map_error.
§Panics
Panics when the decoder reports writing more values than its declared reset bound.
Sourcepub fn transcode<D, M, Value>(
&mut self,
decoder: &mut D,
map_error: &mut M,
output: &mut [Value],
output_index: usize,
count: usize,
) -> Result<usize>
pub fn transcode<D, M, Value>( &mut self, decoder: &mut D, map_error: &mut M, output: &mut [Value], output_index: usize, count: usize, ) -> Result<usize>
Decodes values into an indexed output range using a streaming
Transcoder.
§Parameters
decoder- Streaming decoder used for this operation.map_error- Function mapping transcode errors into I/O errors.output- Destination value storage.output_index- Start index insideoutput.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 transcode errors mapped by map_error.
Sourcepub fn finish<D, M, Value>(
&self,
decoder: &mut D,
map_error: &mut M,
output: &mut [Value],
output_index: usize,
count: usize,
) -> Result<usize>
pub fn finish<D, M, Value>( &self, decoder: &mut D, map_error: &mut M, output: &mut [Value], output_index: usize, count: usize, ) -> Result<usize>
Finishes a streaming decoder into an indexed output range.
§Parameters
decoder- Streaming decoder whose final output is being collected.map_error- Function mapping transcode errors into I/O errors.output- Destination value storage.output_index- Start index insideoutput.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 transcode finalization errors mapped to I/O errors.
§Panics
Panics when the decoder reports writing more values than its
Transcoder::max_finish_output_len bound.
Source§impl<I> TranscodeDecodeInput<I>
impl<I> TranscodeDecodeInput<I>
Trait Implementations§
Source§impl<I> Debug for TranscodeDecodeInput<I>
impl<I> Debug for TranscodeDecodeInput<I>
Source§impl<I> Read for TranscodeDecodeInput<I>
impl<I> Read for TranscodeDecodeInput<I>
Source§fn read(&mut self, output: &mut [u8]) -> Result<usize>
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>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(
&mut self,
cursor: BorrowedCursor<'_, u8>,
) -> Result<(), Error>
fn read_buf_exact( &mut self, cursor: BorrowedCursor<'_, u8>, ) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read more1.0.0 · Source§fn chain<R>(self, next: R) -> Chain<Self, R>
fn chain<R>(self, next: R) -> Chain<Self, R>
1.0.0 · Source§fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
limit bytes from it. Read moreSource§fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>where
Self: Sized,
fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>where
Self: Sized,
read_array)Source§impl<I> Seek for TranscodeDecodeInput<I>
impl<I> Seek for TranscodeDecodeInput<I>
Source§fn seek(&mut self, position: SeekFrom) -> Result<u64>
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>
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)Auto Trait Implementations§
impl<I> Freeze for TranscodeDecodeInput<I>
impl<I> RefUnwindSafe for TranscodeDecodeInput<I>
impl<I> Send for TranscodeDecodeInput<I>
impl<I> Sync for TranscodeDecodeInput<I>
impl<I> Unpin for TranscodeDecodeInput<I>
impl<I> UnsafeUnpin for TranscodeDecodeInput<I>
impl<I> UnwindSafe for TranscodeDecodeInput<I>
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
Source§impl<R> Input for R
impl<R> Input for R
Source§unsafe fn read_unchecked(
&mut self,
output: &mut [u8],
index: usize,
count: usize,
) -> Result<usize, Error>
unsafe fn read_unchecked( &mut self, output: &mut [u8], index: usize, count: usize, ) -> Result<usize, Error>
Reads bytes into a caller-validated indexed output range.
§Parameters
output: Destination byte slice.index: Start offset insideoutput.count: Maximum number of bytes to read.
§Returns
The number of bytes reported by the standard reader.
§Errors
Returns the error reported by the standard reader.
§Panics
Panics in debug builds if the requested destination range does not fit.
§Safety
The caller must ensure that index through index plus count is a valid range inside output without overflowing.
Source§fn read(&mut self, output: &mut [<R as Input>::Item]) -> Result<usize, Error>
fn read(&mut self, output: &mut [<R as Input>::Item]) -> Result<usize, Error>
Reads bytes into the complete output slice.
§Parameters
output: Destination byte slice.
§Returns
The number of bytes read into output.
§Errors
Returns std::io::ErrorKind::InvalidData if the reader reports more
bytes than output holds, or the error reported by the standard reader.
Source§fn is_buffered(&self) -> bool
fn is_buffered(&self) -> bool
Source§unsafe fn read_fully_unchecked(
&mut self,
output: &mut [Self::Item],
index: usize,
count: usize,
) -> Result<usize, Error>
unsafe fn read_fully_unchecked( &mut self, output: &mut [Self::Item], index: usize, count: usize, ) -> Result<usize, Error>
Source§impl<T> ReadExt for T
impl<T> ReadExt for T
Source§unsafe fn read_unchecked(
&mut self,
buffer: &mut [u8],
start_index: usize,
count: usize,
) -> Result<usize, Error>
unsafe fn read_unchecked( &mut self, buffer: &mut [u8], start_index: usize, count: usize, ) -> Result<usize, Error>
Reads bytes from an unchecked range into a standard Read value.
§Parameters
buffer: Destination buffer.start_index: Start offset insidebuffer.count: Maximum number of bytes to read.
§Returns
The number of bytes read into the requested range.
§Errors
Returns the error reported by Read::read.
§Panics
Panics in debug builds if the requested output range does not fit.
§Safety
The caller must guarantee that start_index..start_index + count is
valid inside buffer and that the addition does not overflow.
Source§unsafe fn read_exact_or_eof_unchecked(
&mut self,
buffer: &mut [u8],
start_index: usize,
count: usize,
) -> Result<usize, Error>
unsafe fn read_exact_or_eof_unchecked( &mut self, buffer: &mut [u8], start_index: usize, count: usize, ) -> Result<usize, Error>
Reads an unchecked range until it is full or EOF is reached.
§Parameters
buffer: Destination buffer.start_index: Start offset insidebuffer.count: Number of bytes to try to read.
§Returns
The number of bytes read into the requested range.
§Errors
Returns the first non-interrupted read error.
§Panics
Panics in debug builds if the requested output range does not fit.
§Safety
The caller must guarantee that start_index..start_index + count is
valid inside buffer and that the addition does not overflow.
Source§unsafe fn read_exact_unchecked(
&mut self,
buffer: &mut [u8],
start_index: usize,
count: usize,
) -> Result<(), Error>
unsafe fn read_exact_unchecked( &mut self, buffer: &mut [u8], start_index: usize, count: usize, ) -> Result<(), Error>
Reads exactly the requested unchecked range.
§Parameters
buffer: Destination buffer.start_index: Start offset insidebuffer.count: Number of bytes to read.
§Returns
Ok(()) after the requested range has been filled.
§Errors
Returns the error reported by Read::read_exact.
§Panics
Panics in debug builds if the requested output range does not fit.
§Safety
The caller must guarantee that start_index..start_index + count is
valid inside buffer and that the addition does not overflow.
Source§fn read_exact_array<const N: usize>(&mut self) -> Result<[u8; N], Error>
fn read_exact_array<const N: usize>(&mut self) -> Result<[u8; N], Error>
Reads exactly N bytes into an array.
§Type Parameters
N: Number of bytes in the returned array.
§Returns
An array containing exactly N bytes.
§Errors
Returns the error reported by Read::read_exact.
Source§fn read_exact_vec_limited(
&mut self,
len: usize,
max_len: usize,
) -> Result<Vec<u8>, Error>
fn read_exact_vec_limited( &mut self, len: usize, max_len: usize, ) -> Result<Vec<u8>, Error>
Reads an exactly sized vector within a configured limit.
§Parameters
len: Exact number of bytes to read.max_len: Maximum accepted exact read length.
§Returns
A vector containing exactly len bytes.
§Errors
Returns ErrorKind::OutOfMemory if the result vector cannot be
allocated, a read error, or ErrorKind::InvalidData when
len > max_len.
Source§fn read_exact_vec_limited_into(
&mut self,
output: &mut Vec<u8>,
len: usize,
max_len: usize,
) -> Result<(), Error>
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 a vector.
§Parameters
output: Destination vector.len: Exact number of bytes to read.max_len: Maximum accepted exact read length.
§Returns
Ok(()) after exactly len bytes have been appended.
§Errors
Returns ErrorKind::OutOfMemory if output cannot grow, a read
error, ErrorKind::InvalidData when len > max_len, or
ErrorKind::InvalidInput when output.len() + len overflows.
Source§fn copy_to_at_most(
&mut self,
writer: &mut dyn Write,
max_bytes: u64,
) -> Result<u64, Error>
fn copy_to_at_most( &mut self, writer: &mut dyn Write, max_bytes: u64, ) -> Result<u64, Error>
Copies at most the requested number of bytes to a writer.
§Parameters
writer: Destination writer.max_bytes: Maximum number of bytes to copy.
§Returns
The number of bytes copied.
§Errors
Returns ErrorKind::OutOfMemory if the temporary copy buffer cannot
be allocated, or the first non-interrupted read error or write error.
Source§fn copy_to_end_limited(
&mut self,
writer: &mut dyn Write,
max_bytes: u64,
) -> Result<u64, Error>
fn copy_to_end_limited( &mut self, writer: &mut dyn Write, max_bytes: u64, ) -> Result<u64, Error>
Copies the remaining input when it fits within a configured limit.
§Parameters
writer: Destination writer.max_bytes: Maximum accepted remaining byte count.
§Returns
The number of bytes copied.
§Errors
Returns ErrorKind::OutOfMemory if the temporary copy buffer cannot
be allocated, a read or write error, or ErrorKind::InvalidData when
the remaining input exceeds max_bytes.
Source§fn read_to_end_limited(&mut self, max_len: usize) -> Result<Vec<u8>, Error>
fn read_to_end_limited(&mut self, max_len: usize) -> Result<Vec<u8>, Error>
Reads the remaining bytes into a bounded vector.
§Parameters
max_len: Maximum accepted remaining byte count.
§Returns
A vector containing all remaining bytes.
§Errors
Returns ErrorKind::OutOfMemory if the result vector cannot grow, a
read error, or ErrorKind::InvalidData when the remaining input
exceeds max_len.
Source§fn read_to_end_limited_into(
&mut self,
output: &mut Vec<u8>,
max_len: usize,
) -> Result<usize, Error>
fn read_to_end_limited_into( &mut self, output: &mut Vec<u8>, max_len: usize, ) -> Result<usize, Error>
Appends the remaining bytes to a bounded vector.
§Parameters
output: Destination vector.max_len: Maximum accepted remaining byte count.
§Returns
The number of bytes appended to output.
§Errors
Returns ErrorKind::OutOfMemory if output cannot grow, a read
error, or ErrorKind::InvalidData when the remaining input
exceeds max_len.
Source§fn read_to_string_limited(&mut self, max_len: usize) -> Result<String, Error>
fn read_to_string_limited(&mut self, max_len: usize) -> Result<String, Error>
Reads the remaining bytes as bounded UTF-8 text.
§Parameters
max_len: Maximum accepted remaining byte count.
§Returns
The decoded UTF-8 string.
§Errors
Returns ErrorKind::OutOfMemory if the result buffer cannot grow, a
read error, or ErrorKind::InvalidData when the input exceeds
max_len or is not valid UTF-8.
Source§fn read_to_string_limited_into(
&mut self,
output: &mut String,
max_len: usize,
) -> Result<usize, Error>
fn read_to_string_limited_into( &mut self, output: &mut String, max_len: usize, ) -> Result<usize, Error>
Appends the remaining bounded UTF-8 text to a string.
§Parameters
output: Destination string.max_len: Maximum accepted remaining byte count.
§Returns
The number of bytes appended to output.
§Errors
Returns ErrorKind::OutOfMemory if the temporary byte buffer or
output cannot grow, a read error, or ErrorKind::InvalidData when
the input exceeds max_len or is not valid UTF-8.
impl<T> ReadSeek for T
Source§impl<T> ReadSeekExt for T
impl<T> ReadSeekExt for T
Source§fn read_exact_or_eof_at(
&mut self,
offset: u64,
buffer: &mut [u8],
) -> Result<usize, Error>
fn read_exact_or_eof_at( &mut self, offset: u64, buffer: &mut [u8], ) -> Result<usize, Error>
Reads from an absolute offset and restores the original position.
§Parameters
offset: Absolute byte offset to read from.buffer: Destination buffer.
§Returns
The number of bytes written into buffer.
§Errors
Returns an error when querying, changing, or restoring the stream position, or when reading fails.