Skip to content
FutureBlitz

    Install

    Import std.io.streams

    std.io.streams

    std.io's streams: Reader, what bytes come from, and Writer, where they go, each with Async twins that wait on the main thread instead of blocking it, as a file or a socket does; Seeker, what moves around in them, which only blocks; and Copy, ReadAll, and ReadExact over them. Bytes go through Buffers, whose memory C code reads and fills too.

    std/io/streams.fb

    Types

    SeekOrigin enum

    Public Enum SeekOrigin

    Where Seek counts from.

    std/io/streams.fb, line 14

    • START enum member #

      A stream's start.

    • CURRENT enum member #

      Where it is.

    • END enum member #

      Its end.

    Reader interface

    Public Interface Reader

    What bytes come from: a file, a socket, memory, or another Reader they go through.

    std/io/streams.fb, line 24

    • Method Read(into: Buffer<UInt8>): Int64 Throws IOError method #

      Reads up to into.Count bytes into the start of into, and gives how many it read: one at least, or 0 once the stream has ended, or for an empty Buffer.

    • Async Method ReadAsync(into: Buffer<UInt8>): Int64 Throws IOError method #

      Read's Async twin, which waits on the main thread instead of blocking it. One that can only block reads with Read.

    Writer interface

    Public Interface Writer

    Where bytes go: a file, a socket, memory, or another Writer they go through.

    std/io/streams.fb, line 35

    • Method Write(from: Buffer<UInt8>) Throws IOError method #

      Writes all of from's bytes, in order.

    • Method Flush() Throws IOError method #

      Sends on what it holds on to, to what it writes to. One that holds nothing does nothing.

    • Async Method WriteAsync(from: Buffer<UInt8>) Throws IOError method #

      Write's Async twin, which waits on the main thread instead of blocking it.

    • Async Method FlushAsync() Throws IOError method #

      Flush's Async twin.

    • Final Method WriteBytes(bytes: UInt8[]) Throws IOError method #

      Writes the bytes.

    • Final Method WriteText(text: String) Throws IOError method #

      Writes a String's UTF-8 bytes.

    Seeker interface

    Public Interface Seeker

    What moves around in its bytes, as a file or memory does.

    std/io/streams.fb, line 65

    • Method Seek(offset: Int64, origin: SeekOrigin): Int64 Throws IOError method #

      Moves to offset bytes from origin, and gives where that is from the start. A place before the start, or past what an Int64 counts, throws an IOError, and one past the end is the end for a Reader, and where a Writer writes next.

    • Final Method Position(): Int64 Throws IOError method #

      Where it is, in bytes from the start.

    Functions

    Copy function

    Public Function Copy(from: Reader, to: Writer): Int64 Throws IOError

    Copies what's left of from to to, and gives how many bytes that was.

    std/io/streams.fb, line 79

    CopyAsync function

    Public Async Function CopyAsync(from: Reader, to: Writer): Int64 Throws IOError

    Copy's Async twin, through ReadAsync and WriteAsync.

    std/io/streams.fb, line 91

    ReadAll function

    Public Function ReadAll(from: Reader): UInt8[] Throws IOError

    What's left of from, to its end.

    std/io/streams.fb, line 103

    ReadAllAsync function

    Public Async Function ReadAllAsync(from: Reader): UInt8[] Throws IOError

    ReadAll's Async twin, through ReadAsync.

    std/io/streams.fb, line 114

    ReadAllText function

    Public Function ReadAllText(from: Reader): String Throws IOError

    What's left of from as text, its UTF-8 bytes, with U+FFFD for each byte that doesn't start well-formed UTF-8.

    std/io/streams.fb, line 126

    ReadExact function

    Public Function ReadExact(from: Reader, into: Buffer<UInt8>) Throws IOError

    Fills all of into from from, reading as many times as that takes. Throws an IOError of UNEXPECTED_END when the stream ends first, after what it had.

    std/io/streams.fb, line 132

    ReadExactAsync function

    Public Async Function ReadExactAsync(from: Reader, into: Buffer<UInt8>) Throws IOError

    ReadExact's Async twin, through ReadAsync.

    std/io/streams.fb, line 142

    Report an issue with this page or with FutureBlitz on GitHub.