pub struct BufferedReader<'a, const N: usize> { /* private fields */ }Expand description
read a file a large buffer at a time and provide access to a slice in that buffer
Implementations§
Trait Implementations§
Source§impl<const N: usize> BufRead for BufferedReader<'_, N>
BufferedReader implements a more permissive API compared to BufRead
by allowing consume to advance beyond the end of the buffer returned by fill_buf.
impl<const N: usize> BufRead for BufferedReader<'_, N>
BufferedReader implements a more permissive API compared to BufRead
by allowing consume to advance beyond the end of the buffer returned by fill_buf.
Source§fn consume(&mut self, amt: usize)
fn consume(&mut self, amt: usize)
Advance the buffer position by amt, clamped to the end of the currently buffered data.
This follows the standard BufRead::consume contract: amt must not exceed the buffer
length returned by the preceding fill_buf. To skip bytes beyond the current buffer,
use FileBufRead::consume_or_skip instead.
Source§fn has_data_left(&mut self) -> Result<bool, Error>
fn has_data_left(&mut self) -> Result<bool, Error>
🔬This is a nightly-only experimental API. (
buf_read_has_data_left)Checks if there is any data left to be
read. Read more1.83.0 · Source§fn skip_until(&mut self, byte: u8) -> Result<usize, Error>
fn skip_until(&mut self, byte: u8) -> Result<usize, Error>
Skips all bytes until the delimiter
byte or EOF is reached. Read moreSource§impl<'a, const N: usize> FileBufRead<'a> for BufferedReader<'a, N>
impl<'a, const N: usize> FileBufRead<'a> for BufferedReader<'a, N>
Source§fn add_file_to_prefetch(
&mut self,
_file: &'a File,
_read_limit: FileSize,
) -> Result<()>
fn add_file_to_prefetch( &mut self, _file: &'a File, _read_limit: FileSize, ) -> Result<()>
BufferedReader does not perform read-ahead — the call is a no-op and
the file becomes active only when set_file is later invoked.
Source§fn set_file(&mut self, file: &'a File, read_limit: FileSize) -> Result<()>
fn set_file(&mut self, file: &'a File, read_limit: FileSize) -> Result<()>
Activate the given
file as source of reads of this reader. Read moreSource§fn get_file_offset(&self) -> FileSize
fn get_file_offset(&self) -> FileSize
Returns the current file offset corresponding to the start of the buffer
that will be returned by the next call to
fill_buf. Read moreSource§fn consume_or_skip(&mut self, amt: usize)
fn consume_or_skip(&mut self, amt: usize)
Advance the offset by
amt bytes, potentially skipping past the current buffer
into the underlying file. Read moreSource§impl<const N: usize> Read for BufferedReader<'_, N>
impl<const N: usize> Read for BufferedReader<'_, N>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning
how many bytes were read. Read more
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>
Like
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
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>
Reads all bytes until EOF in this source, placing them into
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>
Reads all bytes until EOF in this source, appending them to
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>
Reads the exact number of bytes required to fill
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf)Pull some bytes from this source into the specified buffer. Read more
Source§fn read_buf_exact(
&mut self,
cursor: BorrowedCursor<'_, u8>,
) -> Result<(), Error>
fn read_buf_exact( &mut self, cursor: BorrowedCursor<'_, u8>, ) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf)Reads the exact number of bytes required to fill
cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Creates a “by reference” adapter for this instance of
Read. Read more1.0.0 · Source§fn chain<R>(self, next: R) -> Chain<Self, R> ⓘ
fn chain<R>(self, next: R) -> Chain<Self, R> ⓘ
Creates an adapter which will chain this stream with another. Read more
1.0.0 · Source§fn take(self, limit: u64) -> Take<Self> ⓘwhere
Self: Sized,
fn take(self, limit: u64) -> Take<Self> ⓘwhere
Self: Sized,
Creates an adapter which will read at most
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,
🔬This is a nightly-only experimental API. (
read_array)Read and return a fixed array of bytes from this source. Read more
Source§impl<const N: usize> RequiredLenBufRead for BufferedReader<'_, N>
Supported required_len is limited by backing buffer size without ability to grow.
impl<const N: usize> RequiredLenBufRead for BufferedReader<'_, N>
Supported required_len is limited by backing buffer size without ability to grow.
Auto Trait Implementations§
impl<'a, const N: usize> Freeze for BufferedReader<'a, N>where
Stack<N>: Freeze,
impl<'a, const N: usize> RefUnwindSafe for BufferedReader<'a, N>where
Stack<N>: RefUnwindSafe,
impl<'a, const N: usize> Send for BufferedReader<'a, N>where
Stack<N>: Send,
impl<'a, const N: usize> Sync for BufferedReader<'a, N>where
Stack<N>: Sync,
impl<'a, const N: usize> Unpin for BufferedReader<'a, N>where
Stack<N>: Unpin,
impl<'a, const N: usize> UnsafeUnpin for BufferedReader<'a, N>where
Stack<N>: UnsafeUnpin,
impl<'a, const N: usize> UnwindSafe for BufferedReader<'a, N>where
Stack<N>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more