Struct BufWriter
struct BufWriter<W> { ... }
Wraps a writer and buffers its output.
It can be excessively inefficient to work directly with something that
implements AsyncWrite. A BufWriter keeps an in-memory buffer of data and
writes it to an underlying writer in large, infrequent batches.
BufWriter can improve the speed of programs that make small and
repeated write calls to the same file or network socket. It does not
help when writing very large amounts at once, or writing just one or a few
times. It also provides no advantage when writing to a destination that is
in memory, like a Vec<u8>.
When the BufWriter is dropped, the contents of its buffer will be
discarded. Creating multiple instances of a BufWriter on the same
stream can cause data loss. If you need to write out the contents of its
buffer, you must manually call flush before the writer is dropped.
Implementations
impl<W> BufWriter<W>
fn get_ref(self: &Self) -> &WAcquires a reference to the underlying sink or stream that this combinator is pulling from.
fn get_mut(self: &mut Self) -> &mut WAcquires a mutable reference to the underlying sink or stream that this combinator is pulling from.
Note that care must be taken to avoid tampering with the state of the sink or stream which may otherwise confuse this combinator.
fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut W>Acquires a pinned mutable reference to the underlying sink or stream that this combinator is pulling from.
Note that care must be taken to avoid tampering with the state of the sink or stream which may otherwise confuse this combinator.
fn into_inner(self: Self) -> WConsumes this combinator, returning the underlying sink or stream.
Note that this may discard intermediate state of this combinator, so care should be taken to avoid losing resources when this is called.
fn buffer(self: &Self) -> &[u8]Returns a reference to the internally buffered data.
impl<W: AsyncWrite> BufWriter<W>
fn new(inner: W) -> SelfCreates a new
BufWriterwith a default buffer capacity. The default is currently 8 KB, but may change in the future.fn with_capacity(cap: usize, inner: W) -> SelfCreates a new
BufWriterwith the specified buffer capacity.
impl<'__pin, W> Unpin for BufWriter<W>
impl<R> AsyncBufReadExt for BufWriter<W>
impl<R> AsyncReadExt for BufWriter<W>
impl<S> AsyncSeekExt for BufWriter<W>
impl<T> Any for BufWriter<W>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for BufWriter<W>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for BufWriter<W>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for BufWriter<W>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for BufWriter<W>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for BufWriter<W>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for BufWriter<W>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<W> AsyncWriteExt for BufWriter<W>
impl<W> Freeze for BufWriter<W>
impl<W> RefUnwindSafe for BufWriter<W>
impl<W> Send for BufWriter<W>
impl<W> Sync for BufWriter<W>
impl<W> UnsafeUnpin for BufWriter<W>
impl<W> UnwindSafe for BufWriter<W>
impl<W: AsyncBufRead> AsyncBufRead for BufWriter<W>
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>>fn consume(self: Pin<&mut Self>, amt: usize)
impl<W: AsyncRead> AsyncRead for BufWriter<W>
fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<Result<usize>>fn poll_read_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>]) -> Poll<Result<usize>>
impl<W: AsyncWrite + AsyncSeek> AsyncSeek for BufWriter<W>
fn poll_seek(self: Pin<&mut Self>, cx: &mut Context<'_>, pos: SeekFrom) -> Poll<Result<u64>>Seek to the offset, in bytes, in the underlying writer.
Seeking always writes out the internal buffer before seeking.
impl<W: AsyncWrite> AsyncWrite for BufWriter<W>
fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>>fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>]) -> Poll<Result<usize>>fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
impl<W: fmt::Debug> Debug for BufWriter<W>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result