NIAOJoin Beta
Ecosystem

io

available

File & Path I/O

Core Standard Library

Overview

io covers filesystem work: slurp a small config, stream a big log file line by line, join path segments without worrying about slashes on Windows vs Linux.

Whole-file helpers are fine for kilobyte-scale files. For anything large, open a handle and read chunks. If disk I/O would stall the VM, dispatch it to a background thread and poll when it's done. Errors come back as structured objects with a code and message, not opaque strings.

  • Whole-file read/write
  • Streaming handles
  • Background I/O
  • Path helpers

Import

import
import "io"

Quick start

quick start
import "io"
let content = io.read_file("config.toml")
io.write_file("out/result.txt", content)
let path = io.join("data", "logs", "app.log")

Capabilities

High-level overview of what io is for.

Whole-file I/O

read_file and write_file when the whole thing fits in memory, configs, small exports, generated reports.

Streaming handles

Open once, read or write incrementally. Use this for log tailing and datasets that won't fit in RAM.

Async background I/O

Move blocking reads/writes off the main thread and check back when they finish.

Path utilities

join, dirname, basename, extension, is_absolute, exists, the usual path helpers, cross-platform.

Structured errors

Failed opens and permission denials return typed errors you can match on instead of parsing strings.

API reference

54 functions and methods in io. Grouped by category from the standard library docs.

Path utilities

SignatureDescription
io_join(a, b, …)Join path segments (`PathBuf::push`)
io_join_many(parts)Join an array of segments; empty array → `""`
io_dirname(path)Parent directory; root → `"."`
io_basename(path)Final path component
io_stem(path)File name without extension
io_extension(path)Extension without dot, or `""`
io_is_absolute(path)Whether path is absolute
io_canonical(path)Resolve to absolute canonical path

Metadata

SignatureDescription
io_exists(path)Path exists (any type)
io_is_file(path)Regular file
io_is_dir(path)Directory
io_is_symlink(path)Symbolic link
io_file_size(path)Size in bytes
io_modified_ms(path)Last modified time (Unix ms)
io_created_ms(path)Creation time (Unix ms); may fail on some platforms

Sync whole-file I/O

SignatureDescription
io_read_file(path)Read entire file as UTF-8 text
io_read_bytes(path)Read raw bytes as `int_array` (0–255 per element)
io_write_file(path, text)Create/truncate and write text
io_write_bytes(path, bytes)Write raw bytes
io_append_file(path, text)Append text (creates file if needed)
io_read_lines(path)Split into lines; newlines stripped
io_write_lines(path, lines)Write lines joined with `\n` (no trailing newline after last line)

Directory operations

SignatureDescription
io_list_dir(path)Immediate children (sorted names)
io_list_dir_recursive(path)All files/dirs under `path` (relative paths; dirs end with `/`)
io_create_dir(path)Create single directory
io_create_dir_all(path)Create directory tree
io_remove_file(path)Delete a file
io_remove_dir(path)Remove empty directory
io_remove_dir_all(path)Remove directory tree
io_copy(src, dst)Copy file
io_rename(src, dst)Rename or move

Working directory and standard paths

SignatureDescription
io_cwd()Current working directory
io_chdir(path)Change working directory
io_temp_dir()OS temp directory
io_home_dir()User home (`HOME` / `USERPROFILE`)

Handle API

SignatureDescription
io_open(path, mode)Open file; returns handle id
io_close(handle)Flush and close
io_read(handle, n)Read up to `n` bytes
io_read_all(handle)Read remainder
io_read_line(handle)One line (text only); `nil` at EOF
io_write(handle, data)Bytes/chars written
io_flush(handle)Flush buffers
io_seek(handle, offset, whence)Seek; returns new position
io_tell(handle)Current position
io_eof(handle)Whether EOF was reached on last read

Async background I/O

SignatureDescription
io_async_read(path)Background read text
io_async_read_bytes(path)Background read bytes
io_async_write(path, text)Background write text
io_async_write_bytes(path, bytes)Background write bytes
io_async_copy(src, dst)Background file copy
io_task_done(task)`true` when finished or cancelled
io_task_poll(task)Result if done; `nil` if pending
io_task_wait(task)Block until done, then return result
io_task_cancel(task)Cancel pending task; `true` if cancelled

Related libraries

More from Core Standard Library.

available

json

JSON Parse & Manipulate

Parse, build, and edit JSON. Backed by serde_json in Rust, nested get/set, merge, and pretty-print included.

  • parse & stringify
  • Dot-path access
  • Deep merge
  • Pretty-print
Read more
available

time

Wall-Clock & Time Zones

Timestamps, formatting, parsing, and time zones. Built on chrono and chrono-tz, DST handled correctly.

  • IANA time zones
  • strftime formats
  • Datetime values
  • Date math
Read more
available

re

Regular Expressions

Regular expressions via Rust's regex crate. Match, split, replace, and compile patterns once for hot loops.

  • Capture groups
  • Search & replace
  • Compiled patterns
  • Unicode-aware
Read more