[][src]Trait futures_lite::io::AsyncWriteExt

pub trait AsyncWriteExt: AsyncWrite {
    fn write<'a>(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self>

Important traits for WriteFuture<'_, T>

impl<T: AsyncWrite + Unpin + ?Sized, '_> Future for WriteFuture<'_, T> type Output = Result<usize>;

    where
        Self: Unpin
, { ... }
fn write_vectored<'a>(
        &'a mut self,
        bufs: &'a [IoSlice<'a>]
    ) -> WriteVectoredFuture<'a, Self>

Important traits for WriteVectoredFuture<'_, T>

impl<T: AsyncWrite + Unpin + ?Sized, '_> Future for WriteVectoredFuture<'_, T> type Output = Result<usize>;

    where
        Self: Unpin
, { ... }
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self>

Important traits for WriteAllFuture<'_, T>

impl<T: AsyncWrite + Unpin + ?Sized, '_> Future for WriteAllFuture<'_, T> type Output = Result<()>;

    where
        Self: Unpin
, { ... }
fn flush(&mut self) -> FlushFuture<Self>

Important traits for FlushFuture<'_, T>

impl<T: AsyncWrite + Unpin + ?Sized, '_> Future for FlushFuture<'_, T> type Output = Result<()>;

    where
        Self: Unpin
, { ... }
fn close(&mut self) -> CloseFuture<Self>

Important traits for CloseFuture<'_, T>

impl<T: AsyncWrite + Unpin + ?Sized, '_> Future for CloseFuture<'_, T> type Output = Result<()>;

    where
        Self: Unpin
, { ... } }

Extension trait for AsyncWrite.

Provided methods

fn write<'a>(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self>

Important traits for WriteFuture<'_, T>

impl<T: AsyncWrite + Unpin + ?Sized, '_> Future for WriteFuture<'_, T> type Output = Result<usize>;
where
    Self: Unpin

Writes some bytes into the byte stream.

Returns the number of bytes written from the start of the buffer.

If the return value is Ok(n) then it must be guaranteed that 0 <= n <= buf.len(). A return value of 0 typically means that the underlying object is no longer able to accept bytes and will likely not be able to in the future as well, or that the provided buffer is empty.

Examples

use futures_lite::*;

let mut output = Vec::new();
let mut writer = io::BufWriter::new(&mut output);

let n = writer.write(b"hello").await?;

fn write_vectored<'a>(
    &'a mut self,
    bufs: &'a [IoSlice<'a>]
) -> WriteVectoredFuture<'a, Self>

Important traits for WriteVectoredFuture<'_, T>

impl<T: AsyncWrite + Unpin + ?Sized, '_> Future for WriteVectoredFuture<'_, T> type Output = Result<usize>;
where
    Self: Unpin

Like write(), except that it writes a slice of buffers.

Data is copied from each buffer in order, with the final buffer possibly being only partially consumed. This method must behave same as a call to write() with the buffers concatenated would.

fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self>

Important traits for WriteAllFuture<'_, T>

impl<T: AsyncWrite + Unpin + ?Sized, '_> Future for WriteAllFuture<'_, T> type Output = Result<()>;
where
    Self: Unpin

Writes an entire buffer into the byte stream.

This method will keep calling write() until there is no more data to be written or an error occurs. It will not return before the entire buffer is successfully written or an error occurs.

Examples

use futures_lite::*;

let mut output = Vec::new();
let mut writer = io::BufWriter::new(&mut output);

let n = writer.write_all(b"hello").await?;

fn flush(&mut self) -> FlushFuture<Self>

Important traits for FlushFuture<'_, T>

impl<T: AsyncWrite + Unpin + ?Sized, '_> Future for FlushFuture<'_, T> type Output = Result<()>;
where
    Self: Unpin

Flushes the stream to ensure that all buffered contents reach their destination.

Examples

use futures_lite::*;

let mut output = Vec::new();
let mut writer = io::BufWriter::new(&mut output);

writer.write_all(b"hello").await?;
writer.flush().await?;

fn close(&mut self) -> CloseFuture<Self>

Important traits for CloseFuture<'_, T>

impl<T: AsyncWrite + Unpin + ?Sized, '_> Future for CloseFuture<'_, T> type Output = Result<()>;
where
    Self: Unpin

Closes the writer.

Examples

use futures_lite::*;

let mut output = Vec::new();
let mut writer = io::BufWriter::new(&mut output);

writer.close().await?;
Loading content...

Implementors

impl<R: AsyncWrite + ?Sized> AsyncWriteExt for R[src]

Loading content...