🕳 Add virtual pipes to wasi-common

This introduces `Handle` implementations for readable and writable pipes, backed by arbitrary `Read`
and `Write` types, respectively. In particular, this allows for easily providing, capturing, or
redirecting WASI stdio without having to resort to OS-provided file descriptors.

The implementation is based heavily on `wasi_common::virtfs::InMemoryFile`, but without inapplicable
operations like `seek` or `allocate`.

Note that these types are not 1:1 replacements for real pipes, because they do not support `poll_oneoff`.
This commit is contained in:
Adam C. Foltzer
2020-06-29 19:20:54 -07:00
parent c91a9313b5
commit 5a96b0deaa
3 changed files with 415 additions and 1 deletions

View File

@@ -32,7 +32,7 @@ mod poll;
mod sandboxed_tty_writer;
pub mod snapshots;
mod sys;
mod virtfs;
pub mod virtfs;
pub mod wasi;
pub use ctx::{WasiCtx, WasiCtxBuilder, WasiCtxBuilderError};