readFileStream
readFileStream opens a file and returns a bounded Result<ReadableStream<u8[]>, FsError>. The runtime reads chunks progressively, so memory use does not grow with the complete file size.
Signature
tyrus
function readFileStream(path: string): Result<ReadableStream<u8[]>, FsError>The default chunk size is 64 KiB and the bounded queue holds at most 256 KiB. Each chunk preserves the original bytes, including zero bytes and data that is not valid text.
Example
tyrus
import { FsError, readFileStream } from "tyrus:fs";
import { ReadableStream } from "tyrus:stream";
match (readFileStream("video.mp4")) {
Ok(stream) => { print("input stream opened"); } // input stream opened
Err(error) => { printError(error.code); } // ERR_FS_READ_FAILED
}Opening failures return Err(FsError). Failures after the file is open reject stream operations with StreamError.
