Trait salvo_core::rt::Write

source ·
pub trait Write {
    // 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_shutdown(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>
    ) -> Poll<Result<(), Error>>;

    // Provided methods
    fn is_write_vectored(&self) -> bool { ... }
    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 similar to std::io::Write, but for asynchronous writes.

Required Methods§

source

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>

Attempt to write bytes from buf into the destination.

On success, returns Poll::Ready(Ok(num_bytes_written))). If successful, it must be guaranteed that n <= buf.len(). A return value of 0 means that the underlying object is no longer able to accept bytes, or that the provided buffer is empty.

If the object is not ready for writing, the method returns Poll::Pending and arranges for the current task (via cx.waker()) to receive a notification when the object becomes writable or is closed.

source

fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>

Attempts to flush the object.

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()) to receive a notification when the object can make progress.

source

fn poll_shutdown( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>

Attempts to shut down this writer.

Provided Methods§

source

fn is_write_vectored(&self) -> bool

Returns whether this writer has an efficient poll_write_vectored implementation.

The default implementation returns false.

source

fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>

Like poll_write, except that it writes from a slice of buffers.

Implementations on Foreign Types§

source§

impl<P> Write for Pin<P>
where P: DerefMut, <P as Deref>::Target: Write,

source§

fn poll_write( self: Pin<&mut Pin<P>>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>

source§

fn poll_write_vectored( self: Pin<&mut Pin<P>>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>

source§

fn is_write_vectored(&self) -> bool

source§

fn poll_flush( self: Pin<&mut Pin<P>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>

source§

fn poll_shutdown( self: Pin<&mut Pin<P>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>

source§

impl<T> Write for MaybeHttpsStream<T>
where T: Write + Read + Unpin,

source§

fn poll_write( self: Pin<&mut MaybeHttpsStream<T>>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>

source§

fn poll_flush( self: Pin<&mut MaybeHttpsStream<T>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>

source§

fn poll_shutdown( self: Pin<&mut MaybeHttpsStream<T>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>

source§

impl<T> Write for &mut T
where T: Write + Unpin + ?Sized,

source§

fn poll_write( self: Pin<&mut &mut T>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>

source§

fn poll_write_vectored( self: Pin<&mut &mut T>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>

source§

fn is_write_vectored(&self) -> bool

source§

fn poll_flush( self: Pin<&mut &mut T>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>

source§

fn poll_shutdown( self: Pin<&mut &mut T>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>

source§

impl<T> Write for Box<T>
where T: Write + Unpin + ?Sized,

source§

fn poll_write( self: Pin<&mut Box<T>>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>

source§

fn poll_write_vectored( self: Pin<&mut Box<T>>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>

source§

fn is_write_vectored(&self) -> bool

source§

fn poll_flush( self: Pin<&mut Box<T>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>

source§

fn poll_shutdown( self: Pin<&mut Box<T>>, cx: &mut Context<'_> ) -> Poll<Result<(), Error>>

Implementors§

source§

impl Write for Upgraded

source§

impl<T> Write for TokioIo<T>
where T: AsyncWrite,