shape_runtime/stdlib_io/mod.rs
1//! Native `io` module for file system, network, and process operations.
2//!
3//! Exports (post-cluster-#2 group 1 file_ops migration):
4//!
5//! ## Migrated (cluster #2 group 1 file_ops + path-mass file_ops)
6//! - File handle: io.open, io.read_to_string, io.read, io.read_bytes,
7//! io.write, io.close, io.flush
8//! - File path: io.exists, io.stat, io.is_file, io.is_dir, io.mkdir,
9//! io.remove, io.rename, io.read_dir, io.read_gzip, io.write_gzip
10//!
11//! ## Deferred (next session)
12//! - Path utilities (path_ops): io.join (varargs), io.dirname, io.basename,
13//! io.extension, io.resolve. Blocked on the varargs-marshal sub-cluster
14//! for io.join; the other 4 are mechanical and held with the cluster.
15//! - Async file ops (async_file_ops): io.read_file_async, io.write_file_async,
16//! io.append_file_async, io.read_bytes_async, io.exists_async. Path-only,
17//! mechanical migrations using `register_typed_async_fn_N`.
18//! - Network ops (network_ops): tcp_connect/listen/accept/read/write/close,
19//! udp_bind/send/recv. Cluster #2 IoHandle consumers — same option γ
20//! shape as file_ops; deferred to keep this commit's scope manageable.
21//! - Process ops (process_ops): spawn, exec, shell, process_*. Blocked on
22//! the `Array<string>`-marshal sub-cluster for `args` params plus
23//! cluster #2 for IoHandle returns.
24//!
25//! See `docs/defections.md` 2026-05-06 cluster #2 entry +
26//! `marshal-optional-args` entry for the architectural decisions
27//! underlying the migrated functions.
28
29pub mod async_file_ops;
30pub mod file_ops;
31pub mod network_ops;
32pub mod path_ops;
33pub mod process_ops;
34
35use crate::module_exports::ModuleExports;
36
37/// Create the `io` module with file system, network, and process operations.
38pub fn create_io_module() -> ModuleExports {
39 let mut module = ModuleExports::new("std::core::io");
40 module.description = "File system, network, and process operations".to_string();
41
42 // Migrated this session (cluster #2 group 1 file_ops + path-mass file_ops).
43 file_ops::register_file_io_handle_ops(&mut module);
44 file_ops::register_file_path_ops(&mut module);
45
46 // Deferred to next session (each subfile's register_X is a no-op stub).
47 path_ops::register_path_io(&mut module);
48 async_file_ops::register_async_file_io(&mut module);
49 network_ops::register_network_io(&mut module);
50 process_ops::register_process_io(&mut module);
51
52 module
53}