Struct buffered_reader::BufferedReaderDup
source · pub struct BufferedReaderDup<'a, C> { /* private fields */ }
Expand description
Duplicates the underlying BufferedReader
without consuming any
of the data.
Note: this will likely cause the underlying stream to buffer as
much data as you read. Thus, it should only be used for peeking
at the underlying BufferedReader
.
Implementations§
source§impl<'a> BufferedReaderDup<'a, ()>
impl<'a> BufferedReaderDup<'a, ()>
sourcepub fn new(reader: Box<dyn BufferedReader<()> + 'a>) -> Self
pub fn new(reader: Box<dyn BufferedReader<()> + 'a>) -> Self
Instantiates a new BufferedReaderDup
buffered reader.
reader
is the BufferedReader
to duplicate.
source§impl<'a, C> BufferedReaderDup<'a, C>
impl<'a, C> BufferedReaderDup<'a, C>
Like new()
, but uses a cookie.
The cookie can be retrieved using the cookie_ref
and
cookie_mut
methods, and set using the cookie_set
method.
Trait Implementations§
source§impl<'a, C> BufferedReader<C> for BufferedReaderDup<'a, C>
impl<'a, C> BufferedReader<C> for BufferedReaderDup<'a, C>
source§fn data(&mut self, amount: usize) -> Result<&[u8], Error>
fn data(&mut self, amount: usize) -> Result<&[u8], Error>
Ensures that the internal buffer has at least
amount
bytes
of data, and returns it. Read moresource§fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>>
fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>>
Returns a mutable reference to the inner
BufferedReader
, if
any. Read moresource§fn get_ref(&self) -> Option<&dyn BufferedReader<C>>
fn get_ref(&self) -> Option<&dyn BufferedReader<C>>
Returns a reference to the inner
BufferedReader
, if any.source§fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>>where
Self: 'b,
fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>>where
Self: 'b,
Returns the underlying reader, if any. Read more
Sets the
BufferedReader
’s cookie and returns the old value.Returns a reference to the
BufferedReader
’s cookie.Returns a mutable reference to the
BufferedReader
’s cookie.source§fn data_eof(&mut self) -> Result<&[u8], Error>
fn data_eof(&mut self) -> Result<&[u8], Error>
Returns all of the data until EOF. Like
data()
, this does not
actually consume the data that is read. Read moresource§fn read_be_u16(&mut self) -> Result<u16, Error>
fn read_be_u16(&mut self) -> Result<u16, Error>
A convenience function for reading a 16-bit unsigned integer
in big endian format. Read more
source§fn read_be_u32(&mut self) -> Result<u32, Error>
fn read_be_u32(&mut self) -> Result<u32, Error>
A convenience function for reading a 32-bit unsigned integer
in big endian format. Read more
source§fn read_to(&mut self, terminal: u8) -> Result<&[u8], Error>
fn read_to(&mut self, terminal: u8) -> Result<&[u8], Error>
Reads until either
terminal
is encountered or EOF. Read moresource§fn steal(&mut self, amount: usize) -> Result<Vec<u8>, Error>
fn steal(&mut self, amount: usize) -> Result<Vec<u8>, Error>
Like
data_consume_hard()
, but returns the data in a
caller-owned buffer. Read moresource§impl<'a, C> Debug for BufferedReaderDup<'a, C>
impl<'a, C> Debug for BufferedReaderDup<'a, C>
source§impl<'a, C> Display for BufferedReaderDup<'a, C>
impl<'a, C> Display for BufferedReaderDup<'a, C>
source§impl<'a, C> Read for BufferedReaderDup<'a, C>
impl<'a, C> Read for BufferedReaderDup<'a, C>
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
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, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
Read 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>
Read 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>
Read the exact number of bytes required to fill
buf
. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> 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<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf
)Read 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” adaptor for this instance of
Read
. Read more