Safe Rust bindings to Unix and Linux system APIs
open sourceMITfree
nix is a Rust crate of friendly, safe bindings to Unix-like system APIs on Linux, macOS, the BSDs and others. Where the libc crate exposes raw unsafe calls that return error codes, nix wraps them in types that enforce correct use and return Results: gethostname returns an OsString, for example, instead of filling a buffer. It unifies what it can across platforms and keeps platform-specific APIs where they differ, with targets supported in three tiers by how thoroughly CI tests them.
Problems it solves
- call Unix system APIs from Rust without writing unsafe libc code
- fork a process, handle signals or use ptrace safely in a Rust program on Linux
- get proper Result errors instead of errno from system calls in Rust
Features
- Safe wrappers over Unix system calls that return Result types
- Covers Linux, macOS (Darwin), FreeBSD and other Unix-like targets
- Shared interface where platforms agree, platform-specific APIs where they don't
- Tiered platform support, with tier 1 targets built and tested in CI
Alternatives
The same job
These do what nix (Rust) does.
- libc Raw bindings to platform APIs for Rust
- windows-rs Microsoft's Rust crates for calling Windows APIs, from COM and WinRT to system services and raw bindings