Skip to main content

BufferedReader

Struct BufferedReader 

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

Source§

impl<'a, const N: usize> BufferedReader<'a, N>

Source

pub const fn new() -> Self

Source

pub fn with_file(self, file: &'a File, read_limit: FileSize) -> Self

Source

pub fn rebind<'b>(self) -> Result<BufferedReader<'b, N>>

Reset to idle state and re-type with a fresh lifetime 'b.

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.

Source§

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 fill_buf(&mut self) -> Result<&[u8]>

Returns the contents of the internal buffer, filling it with more data, via Read methods, if empty. Read more
Source§

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 more
1.0.0 · Source§

fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize, Error>

Reads all bytes into buf until the delimiter byte or EOF is reached. Read more
1.83.0 · Source§

fn skip_until(&mut self, byte: u8) -> Result<usize, Error>

Skips all bytes until the delimiter byte or EOF is reached. Read more
1.0.0 · Source§

fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>

Reads all bytes until a newline (the 0xA byte) is reached, and append them to the provided String buffer. Read more
1.0.0 · Source§

fn split(self, byte: u8) -> Split<Self>
where Self: Sized,

Returns an iterator over the contents of this reader split on the byte byte. Read more
1.0.0 · Source§

fn lines(self) -> Lines<Self>
where Self: Sized,

Returns an iterator over the lines of this reader. Read more
Source§

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<()>

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<()>

Activate the given file as source of reads of this reader. Read more
Source§

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

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

impl<const N: usize> Read for BufferedReader<'_, N>

Source§

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>

Like read, except that it reads into a slice of buffers. Read more
Source§

fn is_read_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
1.0.0 · Source§

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 more
1.0.0 · Source§

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 more
1.6.0 · Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>

Reads the exact number of bytes required to fill buf. Read more
Source§

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>

🔬This is a nightly-only experimental API. (read_buf)
Reads the exact number of bytes required to fill cursor. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Read. Read more
1.0.0 · Source§

fn bytes(self) -> Bytes<Self>
where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
1.0.0 · Source§

fn chain<R>(self, next: R) -> Chain<Self, R>
where R: Read, Self: Sized,

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,

Creates an adapter which will read at most limit bytes from it. Read more
Source§

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§

fn read_le<T>(&mut self) -> Result<T, Error>
where T: FromEndianBytes, Self: Sized,

🔬This is a nightly-only experimental API. (read_le)
Read and return a type (e.g. an integer) in little-endian order. Read more
Source§

fn read_be<T>(&mut self) -> Result<T, Error>
where T: FromEndianBytes, Self: Sized,

🔬This is a nightly-only experimental API. (read_le)
Read and return a type (e.g. an integer) in big-endian order. Read more
Source§

impl<const N: usize> RequiredLenBufRead for BufferedReader<'_, N>

Supported required_len is limited by backing buffer size without ability to grow.

Source§

fn fill_buf_required(&mut self, required_len: usize) -> Result<&[u8]>

Ensures the internal buffer contains at least required_len contiguous bytes, and returns a slice of that buffer. Read more

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> 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<'a, T> RequiredLenBufFileRead<'a> for T

Source§

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

Source§

type Error = !

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.