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 const fn inner(&self) -> &I
pub const fn inner(&self) -> &I
Returns a shared reference to the wrapped unit input.
§Returns
A shared reference to the wrapped unit input.
Sourcepub fn inner_mut(&mut self) -> &mut I
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.
Sourcepub fn available(&self) -> usize
pub fn available(&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>
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
In debug builds, panics when count exceeds Self::available.
Sourcepub unsafe fn copy_unread_to(
&mut self,
output: &mut [I::Item],
output_index: usize,
count: usize,
)
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 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.available(), 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 transcode_into<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_into<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 decoder 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 decoder errors mapped by map_error.
Sourcepub 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>
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>
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 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 decoder finalization errors mapped to I/O errors.
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 from a standard Read value into an indexed range.
Source§impl<T> InputExt for T
impl<T> InputExt for T
Source§fn read_exact(&mut self, output: &mut [Self::Item]) -> Result<(), Error>
fn read_exact(&mut self, output: &mut [Self::Item]) -> Result<(), Error>
output. Read moreSource§unsafe fn read_exact_unchecked(
&mut self,
output: &mut [Self::Item],
index: usize,
count: usize,
) -> Result<(), Error>
unsafe fn read_exact_unchecked( &mut self, output: &mut [Self::Item], index: usize, count: usize, ) -> Result<(), Error>
count items into an indexed output range without
checking the range bounds in release builds. Read moreSource§fn read_exact_or_eof(
&mut self,
output: &mut [Self::Item],
) -> Result<usize, Error>
fn read_exact_or_eof( &mut self, output: &mut [Self::Item], ) -> Result<usize, Error>
output is full or EOF is reached. Read moreSource§unsafe fn read_exact_or_eof_unchecked(
&mut self,
output: &mut [Self::Item],
index: usize,
count: usize,
) -> Result<usize, Error>
unsafe fn read_exact_or_eof_unchecked( &mut self, output: &mut [Self::Item], index: usize, count: usize, ) -> Result<usize, Error>
Source§fn copy_to<O>(&mut self, output: &mut O) -> Result<u64, Error>
fn copy_to<O>(&mut self, output: &mut O) -> Result<u64, Error>
output. Read moreSource§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>
buffer without checking the range bounds
in release builds. Read moreSource§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>
buffer until that range is full or EOF is
reached, without checking the range bounds in release builds. Read moreSource§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>
count bytes into a range of buffer without checking
the range bounds in release builds. Read moreSource§fn read_exact_or_eof(&mut self, buffer: &mut [u8]) -> Result<usize, Error>
fn read_exact_or_eof(&mut self, buffer: &mut [u8]) -> Result<usize, Error>
buffer is full or EOF is reached. Read moreSource§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>
N bytes into a stack-allocated array. Read moreSource§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>
len bytes into a new vector after checking a limit. Read moreSource§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>
Source§fn discard_exact_or_eof(&mut self, bytes: u64) -> Result<u64, Error>
fn discard_exact_or_eof(&mut self, bytes: u64) -> Result<u64, Error>
bytes bytes from this reader. Read moreSource§fn copy_to(&mut self, writer: &mut dyn Write) -> Result<u64, Error>
fn copy_to(&mut self, writer: &mut dyn Write) -> Result<u64, Error>
writer. Read moreSource§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>
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>
max_bytes. Read moreSource§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>
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>
output with a maximum accepted length. Read more