expression

Write all bytes to an async writer

A single write may accept only part of the supplied slice. Use write_all when the operation should finish the entire buffer, or maintain an explicit offset for cancellation-sensitive protocols. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): report Common mistake: Assuming one write always sends the whole message.

Formal Syntax & Structure

rust syntaxrust
writer.write_all(bytes).await

Working Example

Example Snippetrust
#[tokio::main(flavor = "current_thread")]async fn main() {    use tokio::io::AsyncWriteExt;    let mut out = Vec::new();    out.write_all(b"report").await.unwrap();    println!("{}", String::from_utf8(out).unwrap());}
Rust Reference