pub trait ReadSeekExt: Read + Seek {
// Required methods
fn peek_exact_or_eof(&mut self, buffer: &mut [u8]) -> Result<usize>;
fn read_exact_or_eof_at(
&mut self,
offset: u64,
buffer: &mut [u8],
) -> Result<usize>;
}Expand description
Required Methods§
Sourcefn peek_exact_or_eof(&mut self, buffer: &mut [u8]) -> Result<usize>
fn peek_exact_or_eof(&mut self, buffer: &mut [u8]) -> Result<usize>
Reads from the current position and restores the original position.
This method has the same partial-EOF semantics as
crate::ReadExt::read_exact_or_eof, but it leaves the stream
positioned where it was before the call when restoration succeeds.
§Parameters
buffer: Destination buffer to fill.
§Returns
The number of bytes written into buffer.
§Errors
Returns an error when reading the current position, reading bytes, or restoring the original position fails. If both reading and restoration fail, the restoration error is returned because the caller’s stream position contract was not preserved.
Sourcefn read_exact_or_eof_at(
&mut self,
offset: u64,
buffer: &mut [u8],
) -> Result<usize>
fn read_exact_or_eof_at( &mut self, offset: u64, buffer: &mut [u8], ) -> Result<usize>
Reads from offset and restores the original position.
This method seeks to offset, reads until buffer is full or EOF is
reached, and then restores the position that was current before the
call.
§Parameters
offset: Absolute byte offset from the start of the stream.buffer: Destination buffer to fill.
§Returns
The number of bytes written into buffer.
§Errors
Returns an error when reading the current position, seeking to offset,
reading bytes, or restoring the original position fails. If restoration
fails, the restoration error is returned.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".