pub struct ReadAtReader<S> { /* private fields */ }Expand description
Adapt a positional source to Read and Seek with an independent cursor.
This is for synchronous parsers that already require standard I/O. It adds
no buffering, prefetch, retry or asynchronous suspension. Wrap it in
std::io::BufReader only when its extra reads fit the transport’s plan.
Batched range requests remain available through ReadAt::read_many_at;
a parser making individual Read calls cannot express such a batch here.
End-relative seeks call ReadAt::len, which can consume a sequential source
to discover its length. Other seeks and Seek::stream_position do no I/O.
Seeking past EOF is allowed. A failed read or seek leaves the logical cursor
unchanged, but may have changed the source’s state or part of the read buffer.
Whether retry is valid remains a source contract.
Native std::io::Error values (including StdSourceError::Io) are returned
unchanged. Other errors retain their concrete value as an I/O payload, with
an underlying I/O kind when present. zencodec::find_cause inspects these
payloads as well as ordinary error chains.
Implementations§
Source§impl<S> ReadAtReader<S>
impl<S> ReadAtReader<S>
Sourcepub const fn new(source: S) -> Self
pub const fn new(source: S) -> Self
Take ownership of a source, starting the logical cursor at zero.
Sourcepub fn into_inner(self) -> S
pub fn into_inner(self) -> S
Recover the source. The bridge retains no buffered bytes.
Trait Implementations§
Source§impl<S: Debug> Debug for ReadAtReader<S>
impl<S: Debug> Debug for ReadAtReader<S>
Source§impl<S: ReadAt> Read for ReadAtReader<S>
impl<S: ReadAt> Read for ReadAtReader<S>
Source§fn read(&mut self, out: &mut [u8]) -> Result<usize>
fn read(&mut self, out: &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>) -> 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)