Trait hypermangle_core::console::AsyncWrite
pub trait AsyncWrite {
// Required methods
fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize, Error>>;
fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Result<(), Error>>;
fn poll_close(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Result<(), Error>>;
// Provided method
fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize, Error>> { ... }
}Expand description
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 the writer cannot take more data, rather than blocking
the calling thread.
Required Methods§
fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
Attempt to write bytes from buf into the object.
On success, returns Poll::Ready(Ok(num_bytes_written)).
If the object is not ready for writing, the method returns
Poll::Pending and arranges for the current task (via
cx.waker().wake_by_ref()) to receive a notification when the object becomes
writable or is closed.
Implementation
This function may not return errors of kind WouldBlock or
Interrupted. Implementations must convert WouldBlock into
Poll::Pending and either internally retry or convert
Interrupted into another error kind.
poll_write must try to make progress by flushing the underlying object if
that is the only way the underlying object can become writable again.
fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
Attempt to flush the object, ensuring that any buffered data reach their destination.
On success, returns Poll::Ready(Ok(())).
If flushing cannot immediately complete, this method returns
Poll::Pending and arranges for the current task (via
cx.waker().wake_by_ref()) 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
Poll::Pending and either internally retry or convert
Interrupted into another error kind.
It only makes sense to do anything here if you actually buffer data.
fn poll_close(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
Attempt to close the object.
On success, returns Poll::Ready(Ok(())).
If closing cannot immediately complete, this function returns
Poll::Pending and arranges for the current task (via
cx.waker().wake_by_ref()) 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
Poll::Pending and either internally retry or convert
Interrupted into another error kind.
Provided Methods§
fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
Attempt to write bytes from bufs 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 Poll::Ready(Ok(num_bytes_written)).
If the object is not ready for writing, the method returns
Poll::Pending and arranges for the current task (via
cx.waker().wake_by_ref()) to receive a notification when the object becomes
writable or is closed.
By default, this method delegates to using poll_write on the first
nonempty buffer in bufs, or an empty one if none exists. 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
Poll::Pending and either internally retry or convert
Interrupted into another error kind.
Implementations on Foreign Types§
§impl<W> AsyncWrite for LineWriter<W>where
W: AsyncWrite,
impl<W> AsyncWrite for LineWriter<W>where W: AsyncWrite,
§fn poll_flush(
self: Pin<&mut LineWriter<W>>,
cx: &mut Context<'_>
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut LineWriter<W>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
Forward to buf_writer ’s BufWriter::poll_flush()
§fn poll_close(
self: Pin<&mut LineWriter<W>>,
cx: &mut Context<'_>
) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut LineWriter<W>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
Forward to buf_writer ’s BufWriter::poll_close()
fn poll_write( self: Pin<&mut LineWriter<W>>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut LineWriter<W>>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
§impl<W> AsyncWrite for WriteHalf<W>where
W: AsyncWrite,
impl<W> AsyncWrite for WriteHalf<W>where W: AsyncWrite,
fn poll_write( self: Pin<&mut WriteHalf<W>>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut WriteHalf<W>>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut WriteHalf<W>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut WriteHalf<W>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
§impl AsyncWrite for Cursor<&mut Vec<u8, Global>>
impl AsyncWrite for Cursor<&mut Vec<u8, Global>>
fn poll_write( self: Pin<&mut Cursor<&mut Vec<u8, Global>>>, _: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Cursor<&mut Vec<u8, Global>>>, _: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut Cursor<&mut Vec<u8, Global>>>, _: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut Cursor<&mut Vec<u8, Global>>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
§impl<W> AsyncWrite for BufWriter<W>where
W: AsyncWrite,
impl<W> AsyncWrite for BufWriter<W>where W: AsyncWrite,
fn poll_write( self: Pin<&mut BufWriter<W>>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut BufWriter<W>>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut BufWriter<W>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut BufWriter<W>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
§impl<T> AsyncWrite for AllowStdIo<T>where
T: Write,
impl<T> AsyncWrite for AllowStdIo<T>where T: Write,
fn poll_write( self: Pin<&mut AllowStdIo<T>>, _: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut AllowStdIo<T>>, _: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut AllowStdIo<T>>, _: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut AllowStdIo<T>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
§impl<A, B> AsyncWrite for Either<A, B>where
A: AsyncWrite,
B: AsyncWrite,
impl<A, B> AsyncWrite for Either<A, B>where A: AsyncWrite, B: AsyncWrite,
fn poll_write( self: Pin<&mut Either<A, B>>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Either<A, B>>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut Either<A, B>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut Either<A, B>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
§impl<St> AsyncWrite for IntoAsyncRead<St>where
St: TryStream<Error = Error> + AsyncWrite,
<St as TryStream>::Ok: AsRef<[u8]>,
impl<St> AsyncWrite for IntoAsyncRead<St>where St: TryStream<Error = Error> + AsyncWrite, <St as TryStream>::Ok: AsRef<[u8]>,
fn poll_write( self: Pin<&mut IntoAsyncRead<St>>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut IntoAsyncRead<St>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut IntoAsyncRead<St>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
§impl AsyncWrite for Sink
impl AsyncWrite for Sink
fn poll_write( self: Pin<&mut Sink>, _: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Sink>, _: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut Sink>, _: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut Sink>, _: &mut Context<'_> ) -> Poll<Result<(), Error>>
§impl AsyncWrite for Cursor<Vec<u8, Global>>
impl AsyncWrite for Cursor<Vec<u8, Global>>
fn poll_write( self: Pin<&mut Cursor<Vec<u8, Global>>>, _: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Cursor<Vec<u8, Global>>>, _: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut Cursor<Vec<u8, Global>>>, _: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut Cursor<Vec<u8, Global>>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
§impl AsyncWrite for Cursor<&mut [u8]>
impl AsyncWrite for Cursor<&mut [u8]>
fn poll_write( self: Pin<&mut Cursor<&mut [u8]>>, _: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Cursor<&mut [u8]>>, _: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut Cursor<&mut [u8]>>, _: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut Cursor<&mut [u8]>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
§impl AsyncWrite for Cursor<Box<[u8], Global>>
impl AsyncWrite for Cursor<Box<[u8], Global>>
fn poll_write( self: Pin<&mut Cursor<Box<[u8], Global>>>, _: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Cursor<Box<[u8], Global>>>, _: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut Cursor<Box<[u8], Global>>>, _: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut Cursor<Box<[u8], Global>>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
§impl<R> AsyncWrite for BufReader<R>where
R: AsyncWrite,
impl<R> AsyncWrite for BufReader<R>where R: AsyncWrite,
fn poll_write( self: Pin<&mut BufReader<R>>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut BufReader<R>>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut BufReader<R>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut BufReader<R>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
§impl<P> AsyncWrite for Pin<P>where
P: DerefMut + Unpin,
<P as Deref>::Target: AsyncWrite,
impl<P> AsyncWrite for Pin<P>where P: DerefMut + Unpin, <P as Deref>::Target: AsyncWrite,
fn poll_write( self: Pin<&mut Pin<P>>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Pin<P>>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut Pin<P>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut Pin<P>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
§impl<T> AsyncWrite for Box<T, Global>where
T: AsyncWrite + Unpin + ?Sized,
impl<T> AsyncWrite for Box<T, Global>where T: AsyncWrite + Unpin + ?Sized,
fn poll_write( self: Pin<&mut Box<T, Global>>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Box<T, Global>>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut Box<T, Global>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut Box<T, Global>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
§impl AsyncWrite for Vec<u8, Global>
impl AsyncWrite for Vec<u8, Global>
fn poll_write( self: Pin<&mut Vec<u8, Global>>, _: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Vec<u8, Global>>, _: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut Vec<u8, Global>>, _: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut Vec<u8, Global>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
§impl<T> AsyncWrite for &mut Twhere
T: AsyncWrite + Unpin + ?Sized,
impl<T> AsyncWrite for &mut Twhere T: AsyncWrite + Unpin + ?Sized,
fn poll_write( self: Pin<&mut &mut T>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut &mut T>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut &mut T>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut &mut T>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
source§impl AsyncWrite for UdStream
impl AsyncWrite for UdStream
source§fn poll_close(
self: Pin<&mut UdStream>,
_: &mut Context<'_>
) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut UdStream>, _: &mut Context<'_> ) -> Poll<Result<(), Error>>
Finishes immediately. See the .shutdown() method.
fn poll_write( self: Pin<&mut UdStream>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut UdStream>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
source§impl AsyncWrite for OwnedWriteHalf
impl AsyncWrite for OwnedWriteHalf
source§fn poll_close(
self: Pin<&mut OwnedWriteHalf>,
_: &mut Context<'_>
) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut OwnedWriteHalf>, _: &mut Context<'_> ) -> Poll<Result<(), Error>>
Finishes immediately. See the .shutdown() method.
fn poll_write( self: Pin<&mut OwnedWriteHalf>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut OwnedWriteHalf>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
source§impl AsyncWrite for LocalSocketStream
impl AsyncWrite for LocalSocketStream
fn poll_write( self: Pin<&mut LocalSocketStream>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut LocalSocketStream>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut LocalSocketStream>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut LocalSocketStream>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
source§impl AsyncWrite for LocalSocketStream
impl AsyncWrite for LocalSocketStream
fn poll_write( self: Pin<&mut LocalSocketStream>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut LocalSocketStream>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut LocalSocketStream>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
source§impl AsyncWrite for OwnedWriteHalf
impl AsyncWrite for OwnedWriteHalf
fn poll_write( self: Pin<&mut OwnedWriteHalf>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut OwnedWriteHalf>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
fn poll_flush( self: Pin<&mut OwnedWriteHalf>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut OwnedWriteHalf>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>
source§impl AsyncWrite for BorrowedWriteHalf<'_>
impl AsyncWrite for BorrowedWriteHalf<'_>
source§fn poll_close(
self: Pin<&mut BorrowedWriteHalf<'_>>,
_: &mut Context<'_>
) -> Poll<Result<(), Error>>
fn poll_close( self: Pin<&mut BorrowedWriteHalf<'_>>, _: &mut Context<'_> ) -> Poll<Result<(), Error>>
Finishes immediately. See the .shutdown() method.