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.

§Examples

use std::io::Cursor;
use qubit_codec::TranscodeDecodeInput;

let input = TranscodeDecodeInput::with_capacity(Cursor::new(vec![1_u8]), 8);
assert!(input.unread_len() <= 8);

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 fn try_with_capacity( inner: I, capacity: usize, ) -> StdResult<Self, TryReserveError>

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

Returns a buffered adapter owning inner with at least the requested capacity.

§Errors

Returns an allocation error when the requested buffer cannot be allocated.

Source

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.

Source

pub fn unread_len(&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.
§Returns

Returns true when at least count units are buffered; false if EOF prevents reaching that count. Buffered units remain available in either case.

§Errors

Returns allocation errors mapped to ErrorKind::OutOfMemory, or I/O errors from the wrapped input while refilling.

Source

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>>
where D: Transcoder<Input = I::Item, Output = Value>, M: FnMut(D::Error) -> Error,

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.

§Type Parameters
  • D: Streaming decoder accepting the source unit type.
  • M: Mapper from decoder errors to I/O errors.
  • Value: Decoded destination value type.
§Parameters
  • decoder: Decoder for the current logical stream.
  • map_error: Mapper invoked for decoder errors.
  • output: Destination value storage.
  • output_index: Start of the writable range.
  • count: Maximum number of destination values available.
§Returns

Returns Some validated progress after a decode step, or None at EOF with no buffered units. A zero count returns Some zero progress.

§Errors

Returns invalid output-range or progress errors, input/refill errors, or decoder errors translated by map_error.

Source

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

Performs one decode step after the caller has established EOF.

This method does not read from the wrapped input. It passes the current unread buffer to Transcoder::transcode_eof, validates the returned progress, and commits consumed source units before returning.

§Type Parameters
  • D: Streaming decoder accepting the source unit type.
  • M: Mapper from decoder errors to I/O errors.
  • Value: Decoded destination value type.
§Parameters
  • decoder: Decoder for the current logical stream.
  • map_error: Mapper invoked for decoder errors.
  • output: Destination value storage.
  • output_index: Start of the writable range.
  • count: Maximum number of destination values available.
§Returns

Returns validated EOF progress. A zero output count returns zero progress without calling the decoder; an empty input is still passed to transcode_eof so decoders can handle EOF with retained state.

§Errors

Returns invalid output-range errors, or decoder errors mapped by map_error.

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

Panics when count exceeds Self::unread_len.

Source

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 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.unread_len(), 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.

§Panics

Debug builds panic if the destination range violates the safety contract.

§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 read_decoded_with<C, M>( &mut self, codec: &mut C, map_error: M, ) -> Result<C::Value>
where C: Codec<Unit = I::Item>, M: FnMut(C::DecodeError) -> Error,

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.

§Type Parameters
  • C: Codec accepting the wrapped input’s unit type.
  • M: Mapper from codec decode errors to I/O errors.
§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.

Source

pub fn read_decoded_lifecycle_with<C, M>( &mut self, codec: &mut C, map_error: M, ) -> Result<DecodeLifecycleOutput<C::Value>>
where C: Codec<Unit = I::Item>, C::Value: Default, M: FnMut(C::DecodeError) -> Error,

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.

§Type Parameters
  • C: Codec accepting the wrapped input’s unit type.
  • M: Mapper from codec decode errors to I/O errors.
§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.

Source

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>>
where C: Codec<Unit = I::Item>, M: FnMut(C::DecodeError) -> Error,

Decodes one complete codec lifecycle into separate caller storage.

§Type Parameters
  • C: Codec accepting the wrapped input’s unit type.
  • M: Mapper from codec decode errors to I/O errors.
§Parameters
  • codec: Codec used to decode one complete lifecycle.
  • reset_output: Reusable storage for values emitted by Codec::decode_reset.
  • finish_output: Reusable storage for values emitted by Codec::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.

Source

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

Runs decoder reset into an indexed output range.

This method does not read or consume buffered input units.

§Type Parameters
  • D: Streaming decoder accepting the source unit type.
  • M: Mapper from decoder errors to I/O errors.
  • Value: Decoded destination value type.
§Parameters
  • decoder: Decoder for the current logical stream.
  • map_error: Mapper invoked for decoder errors.
  • output: Destination value storage.
  • output_index: Start of the writable range.
  • count: Maximum number of destination values available.
§Returns

Returns the number of reset values initialized in the requested range.

§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.

Source

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>
where D: Transcoder<Input = I::Item, Output = Value>, M: FnMut(D::Error) -> Error,

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

§Type Parameters
  • D: Streaming decoder accepting the source unit type.
  • M: Mapper from decoder errors to I/O errors.
  • Value: Decoded destination value type.
§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 inside output.
  • count - Maximum number of values to write.
§Returns

The number of values written. When this method is driven through EOF with output capacity remaining, it passes the retained tail—or an empty input when no tail remains—to Transcoder::transcode_eof before returning.

§Errors

Returns input errors, invalid output ranges, capacity errors from the internal buffer, or transcode errors mapped by map_error. This operation is not transactional. An error may be returned after source units have been consumed and values have been written to output. Progress is not rolled back, and the error does not report the accumulated output length. Use transcode_step and commit each successful progress result when previously decoded values must remain observable after a later failure.

Source

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

Finishes a streaming decoder into an indexed output range.

§Type Parameters
  • D: Streaming decoder accepting the source unit type.
  • M: Mapper from decoder errors to I/O errors.
  • Value: Decoded destination value type.
§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 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 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>

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<'_>) -> FormatResult

Formats this buffered decode input for debugging.

§Parameters
  • formatter: Formatting sink receiving the struct and owned input.
§Returns

Returns success after writing the debug representation.

§Errors

Propagates a formatting error from the sink or wrapped input.

Source§

impl<I> Read for TranscodeDecodeInput<I>
where I: ByteInput,

Source§

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

Reads raw bytes through the internal buffer.

§Parameters
  • output: Destination for raw buffered bytes.
§Returns

Returns the number of bytes read; zero indicates EOF or an empty destination.

§Errors

Propagates wrapped input or buffer errors.

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>

Source§

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

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

§Parameters
  • position: Target byte-stream position.
§Returns

Returns the new byte offset after clearing buffered data.

§Errors

Propagates wrapped seek errors, preserving the buffer when seeking fails.

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§

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> ByteInput for T
where T: Input<Item = u8> + ?Sized,

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§

type Item = u8

Bytes read by the standard Read implementation.

Source§

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

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 read_vectored(&mut self, buffers: &mut [&mut [u8]]) -> Result<usize, Error>

Reads from the buffers in order using the standard reader’s vectored method. Returns InvalidInput if their total length overflows, OutOfMemory if descriptor preparation fails before I/O, or InvalidData if the reader reports more than the total capacity. Short progress and reader errors are returned without retrying or undoing underlying side effects.

Source§

fn into_std_read(self) -> StdRead<Self> ⓘ
where Self: Sized + ByteInput,

Converts this byte input into a standard library reader. Read more
Source§

fn is_buffered(&self) -> bool

Returns whether this input already buffers items internally. Read more
Source§

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

Reads items into an indexed output range until it is full or EOF is reached. Read more
Source§

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

Reads items into the full output slice until it is full or EOF is reached. Read more
Source§

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

Reads items until the full output slice is filled. 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 from an unchecked range into a standard Read value.

§Parameters
  • buffer: Destination buffer.
  • start_index: Start offset inside buffer.
  • 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>

Reads an unchecked range until it is full or EOF is reached.

§Parameters
  • buffer: Destination buffer.
  • start_index: Start offset inside buffer.
  • 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>

Reads exactly the requested unchecked range.

§Parameters
  • buffer: Destination buffer.
  • start_index: Start offset inside buffer.
  • 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_or_eof(&mut self, buffer: &mut [u8]) -> Result<usize, Error>

Reads the destination until it is full or EOF is reached.

§Parameters
  • buffer: Destination buffer.
§Returns

The number of bytes read into buffer.

§Errors

Returns the first non-interrupted read error.

Source§

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>

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>

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 discard_exact_or_eof(&mut self, bytes: u64) -> Result<u64, Error>

Discards at most the requested number of bytes.

§Parameters
  • bytes: Maximum number of bytes to discard.
§Returns

The number of bytes discarded before the limit or EOF was reached.

§Errors

Returns the first non-interrupted read error.

Source§

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

Copies all remaining bytes to a writer.

§Parameters
  • writer: Destination writer.
§Returns

The number of bytes copied.

§Errors

Returns the first read or write error.

Source§

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>

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>

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>

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>

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>

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.

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 it afterward.

§Parameters
  • buffer: Destination buffer.
§Returns

The number of bytes written into buffer.

§Errors

Returns an error when reading, querying, or restoring the stream position fails.

Source§

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.

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 its final position.

§Returns

The stream size in bytes.

§Errors

Returns an error when querying, changing, or restoring the stream position fails.

Source§

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

Source§

type Unit = u8

Bytes used by the standard Seek implementation.

Source§

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

Seeks using the standard byte offset semantics.

§Parameters
  • position: Standard-library seek origin and byte offset.
§Returns

The resulting byte offset from the start of the stream.

§Errors

Returns the error reported by the standard seeker.

Source§

impl<T> SeekableByteInput for T
where T: SeekableInput<Item = u8, Unit = u8> + ?Sized,

Source§

impl<T> SeekableInput for T
where T: Input + Seekable<Unit = <T as Input>::Item> + ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.