Import std.io.streams
Reader
interface
Public Interface Reader
What bytes come from: a file, a socket, memory, or another Reader they go through.
Examples
// A Reader of the same byte, forever.
Class Zeros Implements Reader
Public Method Read(into: Buffer<UInt8>): Int64 Throws IOError
For i = 0 Until into.Count
into[i] = 0
End For
Return into.Count
End Method
End Class
Local four = Buffer<UInt8>(4)
Try ReadExact(Zeros(), four)
Expect(four.ToArray() == [0, 0, 0, 0] As UInt8[])-
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.
Report an issue with this page or with FutureBlitz on GitHub.