Hello! I am working with wasmtime 13.0.0. I have used the wasi command adapter to migrate a core module to a component, and I'm able to load it using the component loader. However, I'm not able to, using the Rust API, retrieve the stdout from the component. Do you know if there's an example of the sorts? I am able to inherit stdout from the host and let the component print to it, but I'd like to retrieve the result on the rust side. Thanks!
wasmtime_wasi::preview2::pipe::MemoryOutputPipe
is a trivial implementation for capturing all writes to an output stream to a buffer
if you need to consume the stream as the program runs, you can use AsyncWriteStream to wrap your own type that impls AsyncWrite.
and you can use things like tokio::io::duplex
if you need to redirect that into a buffered channel you can AsyncRead from
Thanks for the answer! I just figured out that I was using the wrong WasiCtxBuilder when trying this, so it was expecting a dyn WasiFile, instead of the snapshot2 one that expects a impl HostOutputStream :)
Rafael Fernández López has marked this topic as resolved.
Last updated: Dec 23 2024 at 12:05 UTC