Skip to content

stream

local stream = require("@rodeo/stream")
EntryDescription
StreamHandleOpaque stream identifier. Pass these to stream.read/stream.write/
closeCloses handle. Subsequent reads/writes error.
readReads from handle. Returns the next chunk as a string, or nil on EOF.
readBytesReads all remaining bytes from handle as a buffer. Use for binary
writeWrites data to handle. data is converted to a string via tostring.
writeBytesWrites the bytes in data to handle. Use for binary data; for text

Opaque stream identifier. Pass these to stream.read/stream.write/

stream.close; you don’t access __handle directly.

type StreamHandle = {
__handle: string,
}

Closes handle. Subsequent reads/writes error.

(handle: StreamHandle) -> ()

Reads from handle. Returns the next chunk as a string, or nil on EOF.

(handle: StreamHandle) -> string?

Reads all remaining bytes from handle as a buffer. Use for binary

data; for text use read.

(handle: StreamHandle) -> buffer

Writes data to handle. data is converted to a string via tostring.

(handle: StreamHandle, data: any) -> ()

Writes the bytes in data to handle. Use for binary data; for text

use write.

(handle: StreamHandle, data: buffer) -> ()