pub trait InputSource {
// Required methods
fn remaining(&self) -> usize;
fn peek_byte(&mut self) -> Result<u8>;
fn read_byte(&mut self) -> Result<u8>;
fn peek_bytes_exact<const N: usize>(&mut self) -> Result<&[u8; N]>;
fn read_bytes_exact<const N: usize>(&mut self) -> Result<&[u8; N]>;
fn peek_byte_slice_exact(&mut self, count: usize) -> Result<&[u8]>;
fn read_byte_slice_exact(&mut self, count: usize) -> Result<&[u8]>;
fn read_bytes_into_exact(&mut self, dest: &mut [u8]) -> Result<()>;
}Expand description
A trait for types that can be read from by a Slice decoder.
Required Methods§
Sourcefn remaining(&self) -> usize
fn remaining(&self) -> usize
Returns the number of unread bytes currently remaining in the source.
Sourcefn peek_byte(&mut self) -> Result<u8>
fn peek_byte(&mut self) -> Result<u8>
Returns the next byte available from this source without consuming it.
If there are no more bytes available from this source, an UnexpectedEob error is returned instead.
Sourcefn read_byte(&mut self) -> Result<u8>
fn read_byte(&mut self) -> Result<u8>
Returns the next byte available from this source, and advances past it (consuming it).
If there are no more bytes available from this source, an UnexpectedEob error is returned instead.
fn peek_bytes_exact<const N: usize>(&mut self) -> Result<&[u8; N]>
fn read_bytes_exact<const N: usize>(&mut self) -> Result<&[u8; N]>
fn peek_byte_slice_exact(&mut self, count: usize) -> Result<&[u8]>
fn read_byte_slice_exact(&mut self, count: usize) -> Result<&[u8]>
Sourcefn read_bytes_into_exact(&mut self, dest: &mut [u8]) -> Result<()>
fn read_bytes_into_exact(&mut self, dest: &mut [u8]) -> Result<()>
Reads bytes from this source into the provided buffer, and advances past them (consuming them).
This function reads exactly dest.len()-many bytes, or if it’s unable to, returns an error instead.
If such an error occurs, no guarantees are made about how many bytes were read from the source, except that it
is less than dest.len().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".