pub trait Skip: Read {
// Provided methods
fn skip(&mut self, len: usize) -> Result<(), Error> { ... }
fn remaining_input(&self) -> Option<usize> { ... }
}Expand description
A trait that allows for efficient skipping forward while reading data.
Provided Methods§
Sourcefn skip(&mut self, len: usize) -> Result<(), Error>
fn skip(&mut self, len: usize) -> Result<(), Error>
Advance the cursor by len bytes.
If possible, the implementation should be more efficient than calling
Read::read and discarding the resulting bytes.
Calling skip with a len that advances the cursor past the end of the
underlying data source is permissible. The only requirement is that the
next call to Read::read indicates EOF.
§Errors
Can return an error in all the same cases that Read::read can.
TODO: Remove this clippy suppression when the issue is fixed. See https://github.com/rust-lang/rust-clippy/issues/12519
Sourcefn remaining_input(&self) -> Option<usize>
fn remaining_input(&self) -> Option<usize>
An upper bound, if cheaply known, on the number of bytes still readable
from this source. Used to reject an array/map block that claims more
elements than the input could possibly contain: each element consumes at
least zero bytes, so a block longer than the remaining input only happens
when a small (or hostile) message claims a huge count, which would
otherwise drive an unbounded Vec allocation (length amplification).
Streaming sources that can’t answer cheaply return None.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".