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.
-
A stream's start.
-
Where it is.
-
Its end.
Reader
interface
Public Interface Reader
What bytes come from: a file, a socket, memory, or another Reader they go through.
-
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. -
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.
-
Writes all of from's bytes, in order.
-
Sends on what it holds on to, to what it writes to. One that holds nothing does nothing.
-
Write's Async twin, which waits on the main thread instead of blocking it.
-
Flush's Async twin.
-
Writes the
bytes. -
Writes a String's UTF-8 bytes.
Seeker
interface
Public Interface Seeker
What moves around in its bytes, as a file or memory does.
-
Moves to
offsetbytes fromorigin, 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. -
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.
CopyAsync
function
Public Async Function CopyAsync(from: Reader, to: Writer): Int64 Throws IOError
Copy's Async twin, through ReadAsync and WriteAsync.
ReadAll
function
Public Function ReadAll(from: Reader): UInt8[] Throws IOError
What's left of from, to its end.
ReadAllAsync
function
Public Async Function ReadAllAsync(from: Reader): UInt8[] Throws IOError
ReadAll's Async twin, through ReadAsync.
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.
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.
ReadExactAsync
function
Public Async Function ReadExactAsync(from: Reader, into: Buffer<UInt8>) Throws IOError
ReadExact's Async twin, through ReadAsync.
Report an issue with this page or with FutureBlitz on GitHub.