stream
local stream = require("@rodeo/stream")Summary
Section titled “Summary”| Entry | Description |
|---|---|
| StreamHandle | Opaque stream identifier. Pass these to stream.read/stream.write/ |
| close | Closes handle. Subsequent reads/writes error. |
| read | Reads from handle. Returns the next chunk as a string, or nil on EOF. |
| readBytes | Reads all remaining bytes from handle as a buffer. Use for binary |
| write | Writes data to handle. data is converted to a string via tostring. |
| writeBytes | Writes the bytes in data to handle. Use for binary data; for text |
StreamHandle
Section titled “StreamHandle”Opaque stream identifier. Pass these to stream.read/stream.write/
stream.close; you don’t access __handle directly.
type StreamHandle = { __handle: string,}Functions and Properties
Section titled “Functions and Properties”stream.close
Section titled “stream.close”Closes handle. Subsequent reads/writes error.
(handle: StreamHandle) -> ()stream.read
Section titled “stream.read”Reads from handle. Returns the next chunk as a string, or nil on EOF.
(handle: StreamHandle) -> string?stream.readBytes
Section titled “stream.readBytes”Reads all remaining bytes from handle as a buffer. Use for binary
data; for text use read.
(handle: StreamHandle) -> bufferstream.write
Section titled “stream.write”Writes data to handle. data is converted to a string via tostring.
(handle: StreamHandle, data: any) -> ()stream.writeBytes
Section titled “stream.writeBytes”Writes the bytes in data to handle. Use for binary data; for text
use write.
(handle: StreamHandle, data: buffer) -> ()