pub struct BufferedReadAt<R: Read> { /* private fields */ }Expand description
ReadAt over a sequential std::io::Read stream, buffered per a
BufferPolicy.
Buffering manufactures the seeks the stream cannot provide, at an explicit price: a windowed source fails a far-back read, a spool fails past its cap. It never silently grows or returns wrong bytes.
Implementations§
Source§impl<R: Read> BufferedReadAt<R>
impl<R: Read> BufferedReadAt<R>
Sourcepub fn new(reader: R, policy: BufferPolicy) -> Self
pub fn new(reader: R, policy: BufferPolicy) -> Self
Create a buffered source over reader with policy.
Sourcepub fn retained_bytes(&self) -> usize
pub fn retained_bytes(&self) -> usize
Payload bytes retained for later random/backtrack reads. Excludes the caller’s destination and fixed stack scratch used while skipping.
Trait Implementations§
Source§impl<R: Read> ReadAt for BufferedReadAt<R>
impl<R: Read> ReadAt for BufferedReadAt<R>
Source§fn len(&mut self) -> Result<u64, Self::Error>
fn len(&mut self) -> Result<u64, Self::Error>
Consumes the stream to EOF. Under a window policy the bytes are evicted as they pass, so the length is known but early bytes are gone; under a spool they are retained up to the cap. At the exact spool cap, a one-byte stack probe distinguishes EOF from excess input. Excess consumes that one byte and makes subsequent operations fail; retained payload never exceeds the cap. This is not a total-input-byte limit.
Source§fn read_at(&mut self, offset: u64, out: &mut [u8]) -> Result<usize, Self::Error>
fn read_at(&mut self, offset: u64, out: &mut [u8]) -> Result<usize, Self::Error>
Reads forward only as far as offset + out.len(): the end of the
stream is found by a short read, never by consuming it to learn the
length.
Source§type Error = StdSourceError
type Error = StdSourceError
Source§fn read_exact_at(
&mut self,
offset: u64,
out: &mut [u8],
) -> Result<(), Self::Error>
fn read_exact_at( &mut self, offset: u64, out: &mut [u8], ) -> Result<(), Self::Error>
out with the bytes at offset. Fails rather than returning
a short read.Source§fn len_hint(&self) -> Option<u64>
fn len_hint(&self) -> Option<u64>
None.