MCPcopy Index your code
hub / github.com/bytecodealliance/wstd / AsyncWrite

Interface AsyncWrite

src/io/write.rs:4–26  ·  view source on GitHub ↗

Write bytes to a sink.

Source from the content-addressed store, hash-verified

2
3/// Write bytes to a sink.
4pub trait AsyncWrite {
5 // Required methods
6 async fn write(&mut self, buf: &[u8]) -> io::Result<usize>;
7 async fn flush(&mut self) -> io::Result<()>;
8
9 async fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
10 let mut to_write = &buf[0..];
11 loop {
12 let bytes_written = self.write(to_write).await?;
13 to_write = &to_write[bytes_written..];
14 if to_write.is_empty() {
15 return Ok(());
16 }
17 }
18 }
19
20 // If the `AsyncWrite` implementation is an unbuffered wrapper around an
21 // `AsyncOutputStream`, some I/O operations can be more efficient.
22 #[inline]
23 fn as_async_output_stream(&self) -> Option<&io::AsyncOutputStream> {
24 None
25 }
26}
27
28impl<W: AsyncWrite + ?Sized> AsyncWrite for &mut W {
29 #[inline]

Callers

nothing calls this directly

Implementers 6

streams.rssrc/io/streams.rs
stdio.rssrc/io/stdio.rs
write.rssrc/io/write.rs
empty.rssrc/io/empty.rs
cursor.rssrc/io/cursor.rs
tcp_stream.rssrc/net/tcp_stream.rs

Calls

no outgoing calls

Tested by

no test coverage detected