file
stdlib/core/file.hk: methods on the File resource type.
File is the first runtime-managed native resource (HANKI.md §4): an open OS file descriptor. The per-actor heap closes it when its last handle goes, so a dropped File is never leaked; close! releases it eagerly. A File is single-owner and not sendable across actors; the checker rejects sending one or returning one from a handler.
Open a handle with fs.open_file!; the methods here read and close it. The primitive operations are @intrinsic in sys; this face delegates, so the [fs_read] effect bubbles up through the call.
There is no hermetic test block here: every method bottoms out in a real OS file descriptor via an @intrinsic, with no pure result to assert in the stdlib test pack. These paths are covered end-to-end by the CLI integration tests and example programs.
File
File, or fs.File, is a runtime-managed native resource handle (HANKI.md §4): live native state the per-actor memory manager owns, released when the last handle drops. It is single-owner - never copied, moved across a send - and has no fields of its own, so its methods are its whole surface. A handle is minted by an API that opens one; it is never constructed.
impl File
read_all!
def read_all!(self) -> Result<bytes, sys.FsFailure> [fs_read]
Read the rest of the file as raw bytes. Ok(bytes) on success; Err(FsFailure) on an I/O error or if the file is already closed. That failure's path is empty: a descriptor does not record what it was opened from, and this face has no path of its own to supply. @no-doctest: reads a real descriptor, needs a file, cannot assert in a doctest
close!
def close!(self) -> () [fs_read]
Release the descriptor now. Idempotent: dropping the last handle also closes a File, and an explicit close! is therefore an eager optimisation, not a correctness requirement, and closing twice is harmless. @no-doctest: side-effecting close, with no return value to assert