[−][src]Trait futures::prelude::AsyncWrite
Write bytes asynchronously.
This trait is analogous to the std::io::Write
trait, but integrates
with the asynchronous task system. In particular, the poll_write
method, unlike Write::write
, will automatically queue the current task
for wakeup and return if data is not yet available, rather than blocking
the calling thread.
Required Methods
fn poll_write(
&mut self,
cx: &mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
&mut self,
cx: &mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
Attempt to write bytes from buf
into the object.
On success, returns Ok(Async::Ready(num_bytes_written))
.
If the object is not ready for writing, the method returns
Ok(Async::Pending)
and arranges for the current task (via
cx.waker()
) to receive a notification when the object becomes
readable or is closed.
Implementation
This function may not return errors of kind WouldBlock
or
Interrupted
. Implementations must convert WouldBlock
into
Async::Pending
and either internally retry or convert
Interrupted
into another error kind.
fn poll_flush(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
Attempt to flush the object, ensuring that any buffered data reach their destination.
On success, returns Ok(Async::Ready(()))
.
If flushing cannot immediately complete, this method returns
Ok(Async::Pending)
and arranges for the current task (via
cx.waker()
) to receive a notification when the object can make
progress towards flushing.
Implementation
This function may not return errors of kind WouldBlock
or
Interrupted
. Implementations must convert WouldBlock
into
Async::Pending
and either internally retry or convert
Interrupted
into another error kind.
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
Attempt to close the object.
On success, returns Ok(Async::Ready(()))
.
If closing cannot immediately complete, this function returns
Ok(Async::Pending)
and arranges for the current task (via
cx.waker()
) to receive a notification when the object can make
progress towards closing.
Implementation
This function may not return errors of kind WouldBlock
or
Interrupted
. Implementations must convert WouldBlock
into
Async::Pending
and either internally retry or convert
Interrupted
into another error kind.
Provided Methods
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
Attempt to write bytes from vec
into the object using vectored
IO operations.
This method is similar to poll_write
, but allows data from multiple buffers to be written
using a single operation.
On success, returns Ok(Async::Ready(num_bytes_written))
.
If the object is not ready for writing, the method returns
Ok(Async::Pending)
and arranges for the current task (via
cx.waker()
) to receive a notification when the object becomes
readable or is closed.
By default, this method delegates to using poll_write
on the first
buffer in vec
. Objects which support vectored IO should override
this method.
Implementation
This function may not return errors of kind WouldBlock
or
Interrupted
. Implementations must convert WouldBlock
into
Async::Pending
and either internally retry or convert
Interrupted
into another error kind.
Implementations on Foreign Types
impl<'a> AsyncWrite for Cursor<&'a mut [u8]>
[src]
impl<'a> AsyncWrite for Cursor<&'a mut [u8]>
fn poll_write(
&mut self,
&mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
[src]
fn poll_write(
&mut self,
&mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
fn poll_flush(&mut self, &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_flush(&mut self, &mut Context) -> Result<Async<()>, Error>
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
[src]
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
impl<'a, T> AsyncWrite for &'a mut T where
T: AsyncWrite + ?Sized,
[src]
impl<'a, T> AsyncWrite for &'a mut T where
T: AsyncWrite + ?Sized,
fn poll_write(
&mut self,
cx: &mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
[src]
fn poll_write(
&mut self,
cx: &mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
[src]
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
fn poll_flush(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_flush(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
impl AsyncWrite for Sink
[src]
impl AsyncWrite for Sink
fn poll_write(
&mut self,
&mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
[src]
fn poll_write(
&mut self,
&mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
fn poll_flush(&mut self, &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_flush(&mut self, &mut Context) -> Result<Async<()>, Error>
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
[src]
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
impl<T> AsyncWrite for Box<T> where
T: AsyncWrite + ?Sized,
[src]
impl<T> AsyncWrite for Box<T> where
T: AsyncWrite + ?Sized,
fn poll_write(
&mut self,
cx: &mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
[src]
fn poll_write(
&mut self,
cx: &mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
[src]
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
fn poll_flush(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_flush(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
impl AsyncWrite for Cursor<Box<[u8]>>
[src]
impl AsyncWrite for Cursor<Box<[u8]>>
fn poll_write(
&mut self,
&mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
[src]
fn poll_write(
&mut self,
&mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
fn poll_flush(&mut self, &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_flush(&mut self, &mut Context) -> Result<Async<()>, Error>
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
[src]
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
impl AsyncWrite for Cursor<Vec<u8>>
[src]
impl AsyncWrite for Cursor<Vec<u8>>
fn poll_write(
&mut self,
&mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
[src]
fn poll_write(
&mut self,
&mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
fn poll_flush(&mut self, &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_flush(&mut self, &mut Context) -> Result<Async<()>, Error>
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
[src]
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
Implementors
impl<T> AsyncWrite for AllowStdIo<T> where
T: Write,
[src]
impl<T> AsyncWrite for AllowStdIo<T> where
T: Write,
fn poll_write(
&mut self,
&mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
[src]
fn poll_write(
&mut self,
&mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
fn poll_flush(&mut self, &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_flush(&mut self, &mut Context) -> Result<Async<()>, Error>
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
[src]
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
impl<T> AsyncWrite for WriteHalf<T> where
T: AsyncWrite,
[src]
impl<T> AsyncWrite for WriteHalf<T> where
T: AsyncWrite,
fn poll_write(
&mut self,
cx: &mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
[src]
fn poll_write(
&mut self,
cx: &mut Context,
buf: &[u8]
) -> Result<Async<usize>, Error>
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
[src]
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
fn poll_flush(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_flush(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>
[src]
fn poll_close(&mut self, cx: &mut Context) -> Result<Async<()>, Error>