pub struct BufReader<R> { /* private fields */ }
Expand description
BufReader is a struct with a buffer. BufReader implements AsyncBufRead and AsyncReadRent, and if the inner io implements AsyncWriteRent, it will delegate the implementation.
Implementations§
Source§impl<R> BufReader<R>
impl<R> BufReader<R>
Sourcepub fn with_capacity(capacity: usize, inner: R) -> Self
pub fn with_capacity(capacity: usize, inner: R) -> Self
Create BufReader with given buffer size
Sourcepub const fn get_ref(&self) -> &R
pub const fn get_ref(&self) -> &R
Gets a reference to the underlying reader.
It is inadvisable to directly read from the underlying reader.
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Consumes this BufReader
, returning the underlying reader.
Note that any leftover data in the internal buffer is lost.
Trait Implementations§
Source§impl<R: AsyncReadRent> AsyncBufRead for BufReader<R>
impl<R: AsyncReadRent> AsyncBufRead for BufReader<R>
Source§impl<R: AsyncReadRent> AsyncReadRent for BufReader<R>
impl<R: AsyncReadRent> AsyncReadRent for BufReader<R>
Source§impl<R: AsyncReadRent + AsyncWriteRent> AsyncWriteRent for BufReader<R>
impl<R: AsyncReadRent + AsyncWriteRent> AsyncWriteRent for BufReader<R>
Source§fn write<T: IoBuf>(
&mut self,
buf: T,
) -> impl Future<Output = BufResult<usize, T>>
fn write<T: IoBuf>( &mut self, buf: T, ) -> impl Future<Output = BufResult<usize, T>>
Writes the contents of a buffer into this writer, returning the number of bytes written. Read more
Source§fn writev<T: IoVecBuf>(
&mut self,
buf_vec: T,
) -> impl Future<Output = BufResult<usize, T>>
fn writev<T: IoVecBuf>( &mut self, buf_vec: T, ) -> impl Future<Output = BufResult<usize, T>>
This function attempts to write the entire contents of
buf_vec
, but the write may not
fully succeed, and it might also result in an error. The bytes will be written starting at
the specified offset. Read moreAuto Trait Implementations§
impl<R> Freeze for BufReader<R>where
R: Freeze,
impl<R> RefUnwindSafe for BufReader<R>where
R: RefUnwindSafe,
impl<R> Send for BufReader<R>where
R: Send,
impl<R> Sync for BufReader<R>where
R: Sync,
impl<R> Unpin for BufReader<R>where
R: Unpin,
impl<R> UnwindSafe for BufReader<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<A> AsyncBufReadExt for Awhere
A: AsyncBufRead + ?Sized,
impl<A> AsyncBufReadExt for Awhere
A: AsyncBufRead + ?Sized,
Source§fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> impl Future<Output = Result<usize, Error>>
fn read_until<'a>( &'a mut self, byte: u8, buf: &'a mut Vec<u8>, ) -> impl Future<Output = Result<usize, Error>>
This function will read bytes from the underlying stream until the delimiter or EOF is
found. Once found, all bytes up to, and including, the delimiter (if found) will be appended
to buf. Read more
Source§async fn read_line<'a>(
&'a mut self,
buf: &'a mut String,
) -> Result<usize, Error>
async fn read_line<'a>( &'a mut self, buf: &'a mut String, ) -> Result<usize, Error>
This function will read bytes from the underlying stream until the newline delimiter (the
0xA byte) or EOF is found. Once found, all bytes up to, and including, the delimiter (if
found) will be appended to buf. Read more
Source§impl<A> AsyncReadRentExt for Awhere
A: AsyncReadRent + ?Sized,
impl<A> AsyncReadRentExt for Awhere
A: AsyncReadRent + ?Sized,
Source§async fn read_exact<T>(&mut self, buf: T) -> (Result<usize, Error>, T)where
T: IoBufMut + 'static,
async fn read_exact<T>(&mut self, buf: T) -> (Result<usize, Error>, T)where
T: IoBufMut + 'static,
Read until buf capacity is fulfilled
Source§async fn read_vectored_exact<T>(&mut self, buf: T) -> (Result<usize, Error>, T)where
T: IoVecBufMut + 'static,
async fn read_vectored_exact<T>(&mut self, buf: T) -> (Result<usize, Error>, T)where
T: IoVecBufMut + 'static,
Readv until buf capacity is fulfilled
Source§impl<A> AsyncWriteRentExt for Awhere
A: AsyncWriteRent + ?Sized,
impl<A> AsyncWriteRentExt for Awhere
A: AsyncWriteRent + ?Sized,
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