Skip to main content

BufferedReadAt

Struct BufferedReadAt 

Source
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>

Source

pub fn new(reader: R, policy: BufferPolicy) -> Self

Create a buffered source over reader with policy.

Source

pub fn watermark(&self) -> u64

Bytes consumed from the underlying reader so far.

Source

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>

Source§

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>

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

The source-specific error type.
Source§

fn read_exact_at( &mut self, offset: u64, out: &mut [u8], ) -> Result<(), Self::Error>

Fill out with the bytes at offset. Fails rather than returning a short read.
Source§

fn len_hint(&self) -> Option<u64>

Total length if it is known without reading ahead. Default None.
Source§

fn read_many_at( &mut self, reqs: &mut [(u64, &mut [u8])], ) -> Result<(), Self::Error>

Fill each buffer from its offset. The default serves requests in the order given; concurrent sources override to overlap them.
Source§

fn is_empty(&mut self) -> Result<bool, Self::Error>

Whether the source is empty.
Source§

fn as_slice(&self) -> Option<&[u8]>

The whole source as one slice, when it is already in memory. Drivers and codecs use it to read without copying. Default None.

Auto Trait Implementations§

§

impl<R> Freeze for BufferedReadAt<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for BufferedReadAt<R>
where R: RefUnwindSafe,

§

impl<R> Send for BufferedReadAt<R>
where R: Send,

§

impl<R> Sync for BufferedReadAt<R>
where R: Sync,

§

impl<R> Unpin for BufferedReadAt<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for BufferedReadAt<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for BufferedReadAt<R>
where R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.