moonbitlang/async/stdio does not have a README file

    Input

    type Input

    impl Reader for Input

    Input::drop

    async fn Input::drop(self : Input, len : Int) -> Int

    reader.drop(len) drops len number of bytes from the reader. The number of bytes actually dropped is returned. drop will wait until enough number of bytes is available, so the return value would be smaller than len only when EOF is reached.

    Input::fd

    fn Input::fd(self : Input) -> Int raise

    Return the file descriptor of an input channel.

    If the initialization of the input channel failed, for example when stdin does not exist (Windows) or is not a valid fd (Unix-like), This method will fail with error. So .fd() can be used as a way to tell if stdin is valid.

    Input::read

    async fn Input::read(self : Input, dst : FixedArray[Byte], offset? : Int, max_len? : Int) -> Int

    reader.read(dst, offset~, max_len~) read at most max_len bytes from the reader, storing the result in dst[offset:]. The number of bytes actually read is returned. Note that the return value may be smaller than max_len if not enough data is immediately available. If EOF is reached and no more data is available, zero will be returned.

    Input::read_all

    async fn Input::read_all(self : Input) -> &
    Data

    Read all remaining content from the reader. The return value is a &io.Data object, which can be converted to different formats using .binary(), .text() or .json().

    Input::read_exactly

    async fn Input::read_exactly(self : Input, len : Int) -> Bytes

    reader.read_exactly(len) read exactly len number of bytes from the reader. It will wait until enough number of bytes is available. If EOF is reached before enough data is read, ReaderClosed is raised.

    Input::read_some

    async fn Input::read_some(self : Input, max_len? : Int) -> Bytes?

    reader.read_some(max_len?) fetch and return a chunk of data from the reader. It will return as fast as possible when new data become available. If EOF is reached, None is returned.

    If max_len is specified, the returned chunk will not be larger than max_len. Since read_some will return immediately when new data become available, the returned chunk may be smaller than max_len, even if there are still data available in the reader.

    Input::read_until

    async fn Input::read_until(self : Input, sep : StringView) -> String?

    reader.read_until(sep) read UTF-8 encoded text from the input stream until sep or EOF is reached. The segment of input from start of reader to start of sep or EOF is returned. sep will be conusmed from the input, but is not included in the return value.

    Output

    type Output

    impl Writer for Output

    Output::fd

    fn Output::fd(self : Output) -> Int raise

    Return the file descriptor of an output channel.

    If the initialization of the output channel failed, for example when stdout does not exist (Windows) or is not a valid fd (Unix-like), This method will fail with error. So .fd() can be used as a way to tell if stdout/stderr is valid.

    Output::write

    async fn Output::write(self : Output, data : &
    Data
    ) -> Unit

    Unlike most ordinary streams, concurrent write over stdout or stderr is allowed. Individual writes are automatically serialized internally. Large writes may get split to multiple writes and may still be interleaved, though.

    Output::write_once

    async fn Output::write_once(self : Output, buf : Bytes, offset~ : Int, len~ : Int) -> Int

    Unlike most ordinary streams, concurrent write over stdout or stderr is allowed. Individual writes are automatically serialized internally. Large writes may get split to multiple writes and may still be interleaved, though.

    Output::write_reader

    async fn Output::write_reader(self : Output, reader : &
    Reader
    ) -> Unit

    Unlike most ordinary streams, concurrent write over stdout or stderr is allowed. Individual writes are automatically serialized internally. Large writes may get split to multiple writes and may still be interleaved, though.

    stderr

    let stderr : Output

    The standard error channel.

    If stderr does not exist or is invalid, all operations on stderr will immediately fail with error.

    Windows note: console handles are text based on Windows. If stderr is a Windows console output, binary IO over stderr will be interpreted as UTF-8 sequence, and submitted to the actual console screen buffer via unicode-safe API. If the input is not valid UTF-8, the correct parts will be preserved, but the final output for incorrect parts is undefined

    stdin

    let stdin : Input

    The standard input channel.

    If stdin does not exist or is invalid, all operations on stdin will immediately fail with error.

    Windows note: console handles are text based on Windows. If stdin is a Windows console input, unicode text read from the console will be decoded to UTF-8.

    stdout

    let stdout : Output

    The standard output channel.

    If stdout does not exist or is invalid, all operations on stdout will immediately fail with error.

    Windows note: console handles are text based on Windows. If stdout is a Windows console output, binary IO over stdout will be interpreted as UTF-8 sequence, and submitted to the actual console screen buffer via unicode-safe API. If the input is not valid UTF-8, the correct parts will be preserved, but the final output for incorrect parts is undefined