Platform I/O (id_effect_platform)
Workspace crate id_effect_platform mirrors Effect.ts @effect/platform: HTTP, filesystem, and process capabilities as typed services in R, not as ad hoc reqwest / std::fs / tokio::process calls scattered through domain code.
The crate is a single build: HTTP (reqwest + http + bytes), Tokio fs/process, and URI helpers ship together—no Cargo feature matrix to toggle when learning or publishing docs.
Why separate from id_effect?
- Ports, not drivers — traits like
HttpClient,FileSystem, andProcessRuntimedescribe what your program needs; production stacks install concrete implementations via layers (same pattern as Layers). - Test doubles —
TestFileSystemis an in-memoryFileSystemfor fast, deterministic tests; production usesLiveFileSystembacked by Tokio. - Stable HTTP boundary — domain code depends on
HttpClientKey+execute, not onreqwest::RequestBuilder. The default implementation isReqwestHttpClient, swappable in tests.
Modules at a glance
| Module | Responsibility |
|---|---|
error | HttpError, FsError, ProcessError, unified PlatformError |
http | HttpRequest / HttpResponse, HttpClient, ReqwestHttpClient, layer_http_client, execute |
fs | FileSystem, live + test impls, FileSystemKey, read helper |
process | CommandSpec, ProcessRuntime, TokioProcessRuntime, spawn_wait |
uri | Small helpers around http::Uri |
Wiring pattern
- Declare
Rthat includesService<HttpClientKey, …>(or fs/process keys) viaContext/Consas in A Complete DI Example. - Build a
Layerfromlayer_http_client,layer_file_system, orlayer_process_runtime. - Call
execute,read, orspawn_waitfrom handlers; drive withid_effect_tokio::run_async(see Tokio bridge).
Security note (filesystem)
TestFileSystem rejects path keys containing ... Live I/O follows OS semantics—sandbox or canonicalize untrusted paths at a higher layer when exposing file access.
Runnable example
cargo run -p id_effect_platform --example 010_platform_http_get
Spec and parity
- RFC:
docs/effect-ts-parity/rfcs/0001-id-effect-platform.md - Crate README:
crates/id_effect_platform/README.md
Next
For reqwest-shaped APIs (pools, RequestBuilder, schema-decoded JSON helpers), see HTTP via reqwest and decide when to prefer platform ports vs reqwest adapters.