MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / async_stdout_stream_unblocks

Function async_stdout_stream_unblocks

crates/wasi/src/cli.rs:339–355  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

337
338 #[tokio::test]
339 async fn async_stdout_stream_unblocks() {
340 let (mut read, write) = tokio::io::duplex(32);
341 let stdout = AsyncStdoutStream::new(32, write);
342
343 let task = tokio::task::spawn(async move {
344 let mut stream = stdout.p2_stream();
345 blocking_write_and_flush(&mut *stream, "x".into())
346 .await
347 .unwrap();
348 });
349
350 let mut buf = [0; 100];
351 let n = read.read(&mut buf).await.unwrap();
352 assert_eq!(&buf[..n], b"x");
353
354 task.await.unwrap();
355 }
356
357 async fn blocking_write_and_flush(s: &mut dyn OutputStream, mut bytes: Bytes) -> Result<()> {
358 while !bytes.is_empty() {

Callers

nothing calls this directly

Calls 6

spawnFunction · 0.85
blocking_write_and_flushFunction · 0.85
newFunction · 0.50
p2_streamMethod · 0.45
unwrapMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected