Sign in

    #Stream

    This package provides abstraction for Streams, including readable streams and writable streams.

    The goal is to provide an abstraction for stream in Node.js, stream in wasi-io, and other IO-related library, such as libuv.

    With the foundation, there will be higher level operations, such as buffered streams, text streams, etc.

    Closable

    pub(open) trait Closable {
    close(Self) -> Unit
    }

    Flushable

    pub(open) trait Flushable {
    flush(Self) ->
    T
    [Unit]
    }

    InputStream

    pub(open) trait InputStream : Closable {
    read(Self, FixedArray[Byte], offset? : Int, max_len? : Int) ->
    T
    [Int?]
    }

    This trait represents an interface that provides the ability for low level async read operations.

    The Self here may represent a stream / file descriptor, or a stream / file descriptor + event loop.

    OutputStream

    pub(open) trait OutputStream : Closable + Flushable {
    write(Self, BytesView) ->
    T
    [Unit]
    }

    This trait represents an interface that provides the ability for low level async write operations.

    The Self here may represent a stream / file descriptor, or a stream / file descriptor + event loop.

    Reader

    pub(open) trait Reader : Closable {
    read(Self, StringBuilder, max_len? : Int) ->
    T
    [Unit?]
    }

    This trait represents an interface that provides the ability for async read operations based on Chars.

    The Self here may represent a stream / file descriptor, or a stream / file descriptor + event loop.

    Writer

    pub(open) trait Writer : Closable + Flushable {
    write(Self, StringView) ->
    T
    [Unit]
    }

    This trait represents an interface that provides the ability for async write operations based on Chars.

    The Self here may represent a stream / file descriptor, or a stream / file descriptor + event loop.

    AsyncIterable

    pub(all) type AsyncIterable[T] async () -> T

    AsyncIterable::inner

    #deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
    fn[T] AsyncIterable::inner(self : AsyncIterable[T]) -> (async () -> T)
    Convert newtype to its underlying type, automatically derived.

    BufferedReader

    type BufferedReader

    A reader that buffers the input stream and provides line reading capabilities.

    BufferedReader::next_line

    BufferedReader::read_line

    StringReader

    type StringReader

    A reader based on a string

    buffered_reader

    fn buffered_reader(stream : &Reader) -> BufferedReader

    Create a buffered reader from a reader

    input_stream_reader

    fn[T : InputStream + Closable] input_stream_reader(stream : T, encoding? :
    Encoding
    , buffer_size? : Int) -> &Reader

    Create a reader from an input stream through the given encoding.

    output_stream_writer

    fn[T : OutputStream + Closable + Flushable] output_stream_writer(stream : T, encoding? :
    Encoding
    ) -> &Writer

    Create a writer from an output stream through the given encoding.

    string_reader

    fn string_reader(string : String) -> StringReader

    Creates a new StringReader based on a string

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io