componentized/directory

wasi:cli

interface dependency

WASI CLI interfaces for command-line programs

interface stdin wasi:cli/stdin@0.3.0 since 0.3.0

Types

use enum error-code

from wasi:cli/types@0.3.0

  • io

    Input/output error

  • illegal-byte-sequence

    Invalid or incomplete multibyte or wide character

  • pipe

    Broken pipe

Functions

functionread-via-stream: func() -> tuple<stream<u8>, future<result<_, error-code>>>since 0.3.0

Return a stream for reading from stdin.

This function returns a stream which provides data read from stdin, and a future to signal read results.

If the stream's readable end is dropped the future will resolve to success.

If the stream's writable end is dropped the future will either resolve to success if stdin was closed by the writer or to an error-code if reading failed for some other reason.

Multiple streams may be active at the same time. The behavior of concurrent reads is implementation-specific.

WIT

@since(version = 0.3.0)
interface stdin {
  use types.{error-code};

  /// Return a stream for reading from stdin.
  ///
  /// This function returns a stream which provides data read from stdin,
  /// and a future to signal read results.
  ///
  /// If the stream's readable end is dropped the future will resolve to success.
  ///
  /// If the stream's writable end is dropped the future will either resolve to
  /// success if stdin was closed by the writer or to an error-code if reading
  /// failed for some other reason.
  ///
  /// Multiple streams may be active at the same time. The behavior of concurrent
  /// reads is implementation-specific.
  @since(version = 0.3.0)
  read-via-stream: func() -> tuple<stream<u8>, future<result<_, error-code>>>;
}