pub trait AsyncWrite {
type Error;
// Required methods
fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Self::Error>>;
fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>>;
// Provided method
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self> ⓘ
where Self: Unpin { ... }
}
io
only.Required Associated Types§
Required Methods§
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Self::Error>>
fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>
Provided Methods§
Sourcefn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self> ⓘwhere
Self: Unpin,
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self> ⓘwhere
Self: Unpin,
Attempts to write an entire buffer into this writer.
Equivalent to:
async fn write_all(&mut self, buf: &[u8]) -> io::Result<()>;
This method will continuously call write
until there is no more data
to be written. This method will not return until the entire buffer
has been successfully written or such an error occurs. The first
error generated from this method will be returned.
§Cancel safety
This method is not cancellation safe. If it is used as the event
in a tokio::select!
statement and some other
branch completes first, then the provided buffer may have been
partially written, but future calls to write_all
will start over
from the beginning of the buffer.
§Errors
This function will return the first error that write
returns.
write
: AsyncWrite::write
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.