pub struct BufReader<R> { /* private fields */ }Expand description
A reader with a buffer in front: small reads take from the buffer, which is filled by large reads of the reader. Writes, if the reader is also a writer, go straight through.
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
A reader with a buffer of capacity bytes in front of inner.
Sourcepub fn get_mut(&mut self) -> &mut R
pub fn get_mut(&mut self) -> &mut R
The reader inside, to change (reading it directly skips the bytes buffered).
Sourcepub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut R>where
R: Unpin,
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut R>where
R: Unpin,
The reader inside, pinned.
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
The reader inside, taken back; the bytes buffered are lost.
Trait Implementations§
Source§impl<R: AsyncRead + Unpin> AsyncBufRead for BufReader<R>
impl<R: AsyncRead + Unpin> AsyncBufRead for BufReader<R>
Source§impl<R: AsyncRead + Unpin> AsyncRead for BufReader<R>
impl<R: AsyncRead + Unpin> AsyncRead for BufReader<R>
Source§impl<R: AsyncWrite + Unpin> AsyncWrite for BufReader<R>
impl<R: AsyncWrite + Unpin> AsyncWrite for BufReader<R>
Source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>
Attempt to write bytes from
buf into the object. Read moreSource§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize>>
Attempt to write bytes from
bufs into the object using vectored
IO operations. 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> UnsafeUnpin for BufReader<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for BufReader<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<R> AsyncBufReadExt for Rwhere
R: AsyncBufRead + ?Sized,
impl<R> AsyncBufReadExt for Rwhere
R: AsyncBufRead + ?Sized,
Source§fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> ReadUntil<'a, Self> ⓘwhere
Self: Unpin,
fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> ReadUntil<'a, Self> ⓘwhere
Self: Unpin,
Reads up to and including
byte (or to the end), appending to buf;
answers how many bytes it appended (0 at the end).Source§fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self> ⓘwhere
Self: Unpin,
fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self> ⓘwhere
Self: Unpin,
Reads up to and including a newline (or to the end), appending to
buf if what it read is UTF-8 (an
InvalidData error and buf as it was
otherwise); answers how many bytes it appended (0 at the end).Source§fn split(self, byte: u8) -> Split<Self>where
Self: Sized,
fn split(self, byte: u8) -> Split<Self>where
Self: Sized,
The segments between
bytes, without it, one by one through
Split::next_segment.Source§impl<R> AsyncReadExt for R
impl<R> AsyncReadExt for R
Source§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> ⓘwhere
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> ⓘwhere
Self: Unpin,
Reads some bytes into
buf, answering how many (0 at the end).Source§fn read_buf<'a, 'b>(
&'a mut self,
buf: &'a mut ReadBuf<'b>,
) -> ReadBufFuture<'a, 'b, Self> ⓘwhere
Self: Unpin,
fn read_buf<'a, 'b>(
&'a mut self,
buf: &'a mut ReadBuf<'b>,
) -> ReadBufFuture<'a, 'b, Self> ⓘwhere
Self: Unpin,
Reads some bytes into the unfilled part of
buf and counts them
filled, answering how many (0 at the end, or when buf is full).Source§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> ⓘwhere
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> ⓘwhere
Self: Unpin,
Fills
buf exactly, answering its length; an end of the stream
first is an UnexpectedEof error.Source§fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self> ⓘwhere
Self: Unpin,
fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self> ⓘwhere
Self: Unpin,
Reads to the end of the stream, appending to
buf; answers how many
bytes it appended.Source§fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToString<'a, Self> ⓘwhere
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToString<'a, Self> ⓘwhere
Self: Unpin,
Reads to the end of the stream, appending to
buf if what it read is
UTF-8 (an InvalidData error and buf
as it was otherwise); answers how many bytes it appended.Source§fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
A reader that ends after
limit bytes of this one.Source§fn chain<R: AsyncRead>(self, next: R) -> Chain<Self, R>where
Self: Sized,
fn chain<R: AsyncRead>(self, next: R) -> Chain<Self, R>where
Self: Sized,
A reader that reads this one to its end, then
next.Source§fn read_u8(&mut self) -> ReadNumber<'_, Self, u8, 1> ⓘwhere
Self: Unpin,
fn read_u8(&mut self) -> ReadNumber<'_, Self, u8, 1> ⓘwhere
Self: Unpin,
Reads an unsigned byte (1 bytes, exactly).
Source§fn read_i8(&mut self) -> ReadNumber<'_, Self, i8, 1> ⓘwhere
Self: Unpin,
fn read_i8(&mut self) -> ReadNumber<'_, Self, i8, 1> ⓘwhere
Self: Unpin,
Reads a signed byte (1 bytes, exactly).
Source§fn read_u16(&mut self) -> ReadNumber<'_, Self, u16, 2> ⓘwhere
Self: Unpin,
fn read_u16(&mut self) -> ReadNumber<'_, Self, u16, 2> ⓘwhere
Self: Unpin,
Reads a big-endian
u16 (2 bytes, exactly).Source§fn read_u16_le(&mut self) -> ReadNumber<'_, Self, u16, 2> ⓘwhere
Self: Unpin,
fn read_u16_le(&mut self) -> ReadNumber<'_, Self, u16, 2> ⓘwhere
Self: Unpin,
Reads a little-endian
u16 (2 bytes, exactly).Source§fn read_i16(&mut self) -> ReadNumber<'_, Self, i16, 2> ⓘwhere
Self: Unpin,
fn read_i16(&mut self) -> ReadNumber<'_, Self, i16, 2> ⓘwhere
Self: Unpin,
Reads a big-endian
i16 (2 bytes, exactly).Source§fn read_i16_le(&mut self) -> ReadNumber<'_, Self, i16, 2> ⓘwhere
Self: Unpin,
fn read_i16_le(&mut self) -> ReadNumber<'_, Self, i16, 2> ⓘwhere
Self: Unpin,
Reads a little-endian
i16 (2 bytes, exactly).Source§fn read_u32(&mut self) -> ReadNumber<'_, Self, u32, 4> ⓘwhere
Self: Unpin,
fn read_u32(&mut self) -> ReadNumber<'_, Self, u32, 4> ⓘwhere
Self: Unpin,
Reads a big-endian
u32 (4 bytes, exactly).Source§fn read_u32_le(&mut self) -> ReadNumber<'_, Self, u32, 4> ⓘwhere
Self: Unpin,
fn read_u32_le(&mut self) -> ReadNumber<'_, Self, u32, 4> ⓘwhere
Self: Unpin,
Reads a little-endian
u32 (4 bytes, exactly).Source§fn read_i32(&mut self) -> ReadNumber<'_, Self, i32, 4> ⓘwhere
Self: Unpin,
fn read_i32(&mut self) -> ReadNumber<'_, Self, i32, 4> ⓘwhere
Self: Unpin,
Reads a big-endian
i32 (4 bytes, exactly).Source§fn read_i32_le(&mut self) -> ReadNumber<'_, Self, i32, 4> ⓘwhere
Self: Unpin,
fn read_i32_le(&mut self) -> ReadNumber<'_, Self, i32, 4> ⓘwhere
Self: Unpin,
Reads a little-endian
i32 (4 bytes, exactly).Source§fn read_u64(&mut self) -> ReadNumber<'_, Self, u64, 8> ⓘwhere
Self: Unpin,
fn read_u64(&mut self) -> ReadNumber<'_, Self, u64, 8> ⓘwhere
Self: Unpin,
Reads a big-endian
u64 (8 bytes, exactly).Source§fn read_u64_le(&mut self) -> ReadNumber<'_, Self, u64, 8> ⓘwhere
Self: Unpin,
fn read_u64_le(&mut self) -> ReadNumber<'_, Self, u64, 8> ⓘwhere
Self: Unpin,
Reads a little-endian
u64 (8 bytes, exactly).Source§fn read_i64(&mut self) -> ReadNumber<'_, Self, i64, 8> ⓘwhere
Self: Unpin,
fn read_i64(&mut self) -> ReadNumber<'_, Self, i64, 8> ⓘwhere
Self: Unpin,
Reads a big-endian
i64 (8 bytes, exactly).Source§fn read_i64_le(&mut self) -> ReadNumber<'_, Self, i64, 8> ⓘwhere
Self: Unpin,
fn read_i64_le(&mut self) -> ReadNumber<'_, Self, i64, 8> ⓘwhere
Self: Unpin,
Reads a little-endian
i64 (8 bytes, exactly).Source§fn read_u128(&mut self) -> ReadNumber<'_, Self, u128, 16> ⓘwhere
Self: Unpin,
fn read_u128(&mut self) -> ReadNumber<'_, Self, u128, 16> ⓘwhere
Self: Unpin,
Reads a big-endian
u128 (16 bytes, exactly).Source§fn read_u128_le(&mut self) -> ReadNumber<'_, Self, u128, 16> ⓘwhere
Self: Unpin,
fn read_u128_le(&mut self) -> ReadNumber<'_, Self, u128, 16> ⓘwhere
Self: Unpin,
Reads a little-endian
u128 (16 bytes, exactly).Source§fn read_i128(&mut self) -> ReadNumber<'_, Self, i128, 16> ⓘwhere
Self: Unpin,
fn read_i128(&mut self) -> ReadNumber<'_, Self, i128, 16> ⓘwhere
Self: Unpin,
Reads a big-endian
i128 (16 bytes, exactly).Source§fn read_i128_le(&mut self) -> ReadNumber<'_, Self, i128, 16> ⓘwhere
Self: Unpin,
fn read_i128_le(&mut self) -> ReadNumber<'_, Self, i128, 16> ⓘwhere
Self: Unpin,
Reads a little-endian
i128 (16 bytes, exactly).Source§fn read_f32(&mut self) -> ReadNumber<'_, Self, f32, 4> ⓘwhere
Self: Unpin,
fn read_f32(&mut self) -> ReadNumber<'_, Self, f32, 4> ⓘwhere
Self: Unpin,
Reads a big-endian
f32 (4 bytes, exactly).Source§fn read_f32_le(&mut self) -> ReadNumber<'_, Self, f32, 4> ⓘwhere
Self: Unpin,
fn read_f32_le(&mut self) -> ReadNumber<'_, Self, f32, 4> ⓘwhere
Self: Unpin,
Reads a little-endian
f32 (4 bytes, exactly).Source§fn read_f64(&mut self) -> ReadNumber<'_, Self, f64, 8> ⓘwhere
Self: Unpin,
fn read_f64(&mut self) -> ReadNumber<'_, Self, f64, 8> ⓘwhere
Self: Unpin,
Reads a big-endian
f64 (8 bytes, exactly).Source§fn read_f64_le(&mut self) -> ReadNumber<'_, Self, f64, 8> ⓘwhere
Self: Unpin,
fn read_f64_le(&mut self) -> ReadNumber<'_, Self, f64, 8> ⓘwhere
Self: Unpin,
Reads a little-endian
f64 (8 bytes, exactly).Source§impl<S> AsyncSeekExt for S
impl<S> AsyncSeekExt for S
Source§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
Source§fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self> ⓘwhere
Self: Unpin,
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self> ⓘwhere
Self: Unpin,
Writes some of
buf, answering how many bytes.Source§fn write_vectored<'a, 'b>(
&'a mut self,
bufs: &'a [IoSlice<'b>],
) -> WriteVectored<'a, 'b, Self> ⓘwhere
Self: Unpin,
fn write_vectored<'a, 'b>(
&'a mut self,
bufs: &'a [IoSlice<'b>],
) -> WriteVectored<'a, 'b, Self> ⓘwhere
Self: Unpin,
Writes some of the slices
bufs, in order, answering how many bytes.Source§fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self> ⓘwhere
Self: Unpin,
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self> ⓘwhere
Self: Unpin,
Writes all of
buf; a writer that takes no more bytes is a
WriteZero error.Source§fn flush(&mut self) -> Flush<'_, Self> ⓘwhere
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self> ⓘwhere
Self: Unpin,
Writes out what the writer holds back, down to its destination.
Source§fn shutdown(&mut self) -> Shutdown<'_, Self> ⓘwhere
Self: Unpin,
fn shutdown(&mut self) -> Shutdown<'_, Self> ⓘwhere
Self: Unpin,
Flushes and closes the writing side (
poll_close): a socket sends
its end of stream, a pipe’s reader sees its end.Source§fn write_u8(&mut self, n: u8) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_u8(&mut self, n: u8) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes an unsigned byte, all of its bytes.
Source§fn write_i8(&mut self, n: i8) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_i8(&mut self, n: i8) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a signed byte, all of its bytes.
Source§fn write_u16(&mut self, n: u16) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_u16(&mut self, n: u16) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a big-endian
u16, all of its bytes.Source§fn write_u16_le(&mut self, n: u16) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_u16_le(&mut self, n: u16) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a little-endian
u16, all of its bytes.Source§fn write_i16(&mut self, n: i16) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_i16(&mut self, n: i16) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a big-endian
i16, all of its bytes.Source§fn write_i16_le(&mut self, n: i16) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_i16_le(&mut self, n: i16) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a little-endian
i16, all of its bytes.Source§fn write_u32(&mut self, n: u32) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_u32(&mut self, n: u32) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a big-endian
u32, all of its bytes.Source§fn write_u32_le(&mut self, n: u32) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_u32_le(&mut self, n: u32) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a little-endian
u32, all of its bytes.Source§fn write_i32(&mut self, n: i32) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_i32(&mut self, n: i32) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a big-endian
i32, all of its bytes.Source§fn write_i32_le(&mut self, n: i32) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_i32_le(&mut self, n: i32) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a little-endian
i32, all of its bytes.Source§fn write_u64(&mut self, n: u64) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_u64(&mut self, n: u64) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a big-endian
u64, all of its bytes.Source§fn write_u64_le(&mut self, n: u64) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_u64_le(&mut self, n: u64) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a little-endian
u64, all of its bytes.Source§fn write_i64(&mut self, n: i64) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_i64(&mut self, n: i64) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a big-endian
i64, all of its bytes.Source§fn write_i64_le(&mut self, n: i64) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_i64_le(&mut self, n: i64) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a little-endian
i64, all of its bytes.Source§fn write_u128(&mut self, n: u128) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_u128(&mut self, n: u128) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a big-endian
u128, all of its bytes.Source§fn write_u128_le(&mut self, n: u128) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_u128_le(&mut self, n: u128) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a little-endian
u128, all of its bytes.Source§fn write_i128(&mut self, n: i128) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_i128(&mut self, n: i128) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a big-endian
i128, all of its bytes.Source§fn write_i128_le(&mut self, n: i128) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_i128_le(&mut self, n: i128) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a little-endian
i128, all of its bytes.Source§fn write_f32(&mut self, n: f32) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_f32(&mut self, n: f32) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a big-endian
f32, all of its bytes.Source§fn write_f32_le(&mut self, n: f32) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_f32_le(&mut self, n: f32) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a little-endian
f32, all of its bytes.Source§fn write_f64(&mut self, n: f64) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_f64(&mut self, n: f64) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a big-endian
f64, all of its bytes.Source§fn write_f64_le(&mut self, n: f64) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
fn write_f64_le(&mut self, n: f64) -> WriteNumber<'_, Self, { _ }> ⓘwhere
Self: Unpin,
Writes a little-endian
f64, all of its bytes.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