Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 64 additions & 2 deletions wit-0.3.0-draft/stdio.wit
Original file line number Diff line number Diff line change
@@ -1,17 +1,79 @@
@since(version = 0.3.0-rc-2025-08-15)
interface stdin {
/// Gets the "stdin" of this component as a stream.
///
/// This function returns a `stream<u8>` which is a byte-based async view
/// of the stdin to this component. What exactly stdin is depends on the
/// implementor but it could possibly be backed by any of the following:
///
/// * A console terminal input
/// * A file via shell redirection
/// * Another stream from another component in virtualization scenarios
///
/// This function can be called any number of times and all returned streams
/// will refer to the same I/O object that represents the stdin of this
/// component itself. Concurrent reads from separate streams are allowed
/// but it's unspecified which resolves first.
///
/// If a read is started and then cancelled implementors need to guarantee
/// that no bytes are consumed from stdin. In other words if a read from the
/// stream returned here initiates a read somewhere else then cancelling
/// the original read should cancel this other read appropriately or buffer
/// the results.
@since(version = 0.3.0-rc-2025-08-15)
get-stdin: func() -> stream<u8>;
}

@since(version = 0.3.0-rc-2025-08-15)
interface stdout {
/// Appends the provided stream of data to the "stdout" of this component.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "append" mean in this context? If an application calls append-stdout multiple times, how do the different output streams relate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure yeah, I've expanded the docs a bit

///
/// This function will cause the host/embedder to read from the `data` byte
/// stream provided and write the output to a component's stdout. What
/// exactly stdout is depends on the implementor but it could possibly be
/// backed by any of the following:
///
/// * A console terminal screen
/// * A file via shell redirection
/// * Another stream from another component in virtualization scenarios
///
/// Writes to stdout may be blocked if the system is unable to accept and/or
/// buffer any more bytes from stdout. Implementors are encouraged to only
/// complete a write once the bytes have been fully flushed out to the
/// destination in interactive situations as this API is frequently used
/// for debugging.
///
/// If this function is called multiple times then the true output of this
/// component will be an interleaving of all the various streams together
/// as data from them becomes ready. If two streams appended here are ready
/// at the same time with data then it's not specified which one comes first.
@since(version = 0.3.0-rc-2025-08-15)
set-stdout: func(data: stream<u8>);
append-stdout: func(data: stream<u8>);
}

@since(version = 0.3.0-rc-2025-08-15)
interface stderr {
/// Appends the provided stream of data to the "stderr" of this component.
///
/// This function will cause the host/embedder to read from the `data` byte
/// stream provided and write the output to a component's stderr. What
/// exactly stderr is depends on the implementor but it could possibly be
/// backed by any of the following:
///
/// * A console terminal screen
/// * A file via shell redirection
/// * Another stream from another component in virtualization scenarios
///
/// Writes to stderr may be blocked if the system is unable to accept and/or
/// buffer any more bytes from stderr. Implementors are encouraged to only
/// complete a write once the bytes have been fully flushed out to the
/// destination in interactive situations as this API is frequently used
/// for debugging.
///
/// If this function is called multiple times then the true output of this
/// component will be an interleaving of all the various streams together
/// as data from them becomes ready. If two streams appended here are ready
/// at the same time with data then it's not specified which one comes first.
@since(version = 0.3.0-rc-2025-08-15)
set-stderr: func(data: stream<u8>);
append-stderr: func(data: stream<u8>);
}