pub struct ReadPos<P>where
P: PosRead,{ /* private fields */ }
Expand description
Re-implements Read
and Seek
over PosRead
using only positioned
reads, and by maintaining an instance independent position.
PosRead
is implemented for any Borrow<File>
so
this can own via ReadPos<File>
or use a shared reference, as in
ReadPos<&File>
or ReadPos<Arc<File>>
.
A fixed length
is passed on construction and used solely to interpret
SeekFrom::End
. Reads are not constrained by this length. The length is
neither checked against nor updated from the inner PosRead
(for example
via file metadata) and could deviate if concurrent writes or truncation is
possible. Reads beyond the end of the inner PosRead
will return 0
length. Seeking past the end is allowed by the platforms for File
, and
is also allowed for ReadPos
.
Implementations§
source§impl<P> ReadPos<P>where
P: PosRead,
impl<P> ReadPos<P>where
P: PosRead,
source§impl<P> ReadPos<P>where
P: PosRead + Clone,
impl<P> ReadPos<P>where
P: PosRead + Clone,
sourcepub fn subslice(&self, start: u64, end: u64) -> ReadSlice<P> ⓘ
pub fn subslice(&self, start: u64, end: u64) -> ReadSlice<P> ⓘ
Return a new and independent ReadSlice
by clone of the inner
PosRead
, for the range of byte offsets start..end
, and positoned
at start. This implementation panics if start is greater than
end. Note that the end parameter is not checked against the length of
self as passed on construction.
Trait Implementations§
source§impl<P> PosRead for ReadPos<P>where
P: PosRead,
impl<P> PosRead for ReadPos<P>where
P: PosRead,
source§fn pread(&self, buf: &mut [u8], offset: u64) -> Result<usize>
fn pread(&self, buf: &mut [u8], offset: u64) -> Result<usize>
source§impl<P> Read for ReadPos<P>where
P: PosRead,
impl<P> Read for ReadPos<P>where
P: PosRead,
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
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, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> 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<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> 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 more