pub struct BufferedSource { /* private fields */ }Expand description
Buffered, prefetching wrapper around any ReadSeek.
Implementations§
Source§impl BufferedSource
impl BufferedSource
Sourcepub fn new(inner: Box<dyn ReadSeek>, capacity: usize) -> Result<Self>
pub fn new(inner: Box<dyn ReadSeek>, capacity: usize) -> Result<Self>
Wrap inner, allocating up to capacity bytes for the prefetch
ring. Spawns one worker thread that takes ownership of inner.
capacity is rounded up to at least 4 * DEFAULT_BLOCK bytes
so the worker always has room to make forward progress.
Other knobs (block size, prefetch timeout, lookback fraction)
take their default values. Use BufferedSource::builder to
tune them.
Sourcepub fn builder() -> BufferedSourceBuilder
pub fn builder() -> BufferedSourceBuilder
Open a builder for fine-grained control over capacity, block size,
prefetch timeout, and lookback fraction. The builder consumes
itself on each setter, returning a fresh value, then build(inner)
yields the running BufferedSource.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the inner source is known to be empty. Returns false if
the length couldn’t be determined (treat as non-empty).
Sourcepub fn prefetch_timeout(&self) -> Duration
pub fn prefetch_timeout(&self) -> Duration
Effective prefetch timeout in use by this BufferedSource (after
builder clamping). Useful for diagnostics where the caller wants
to confirm the value actually installed.
Trait Implementations§
Source§impl Drop for BufferedSource
impl Drop for BufferedSource
Source§impl Read for BufferedSource
impl Read for BufferedSource
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)Source§impl Seek for BufferedSource
impl Seek for BufferedSource
Source§fn seek(&mut self, from: SeekFrom) -> Result<u64>
fn seek(&mut self, from: SeekFrom) -> Result<u64>
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len)