Safe Rust bindings to POSIX-ish APIs
翻訳待ち
開発ツールRustGitHub @bytecodealliance自分でインストール所有者未確認
Paste into Claude or ChatGPT for installation instructions suited to your environment.
Have you tried it? One tap is enough. No sign-in needed.
The maker's introduction consists of the line above. Read the repository README for more details. Repository README ↗
Loading the full README.
Read the full README ↗A Bytecode Alliance project
rustix provides efficient memory-safe and I/O-safe wrappers to POSIX-like,
Unix-like, Linux, and Winsock syscall-like APIs, with configurable backends. It
uses Rust references, slices, and return values instead of raw pointers, and
I/O safety types instead of raw file descriptors, providing memory safety,
I/O safety, and provenance. It uses Results for reporting errors,
bitflags instead of bare integer flags, an Arg trait with optimizations
to efficiently accept any Rust string type, and several other efficient
conveniences.
rustix is low-level and, and while the net API supports Windows Sockets 2
(Winsock), the rest of the APIs do not support Windows; for higher-level and
more portable APIs built on this functionality, see the cap-std, memfd,
timerfd, and io-streams crates, for example.
rustix currently has two backends available:
linux_raw, which uses raw Linux system calls and vDSO calls, and is supported on Linux on x86-64, x86, aarch64, riscv64gc, powerpc64le, arm (v5 onwards), mipsel, and mips64el, with stable, nightly, and 1.65 Rust.
libc, errno, and pthread
cancellation, and employing some specialized optimizations, most functions
compile down to very efficient code, which can often be fully inlined into
user code.linux_raw preserve memory, I/O safety, and pointer
provenance all the way down to the syscalls.libc, which uses the libc crate which provides bindings to native libc
libraries on Unix-family platforms, and windows-sys for Winsock on
Windows, and is portable to many OS's.
The linux_raw backend is enabled by default on platforms which support it. To
enable the libc backend instead, either enable the "use-libc" cargo feature, or
set the RUSTFLAGS environment variable to --cfg=rustix_use_libc when
building.
The modules rustix::io, rustix::buffer, rustix::fd,
rustix::ffi, and rustix::ioctl are enabled by default. The rest of the
API modules are conditional with cargo feature flags.
| Name | Description |
|---|---|
event | rustix::event—Polling and event operations. |
fs | rustix::fs—Filesystem operations. |
io_uring | rustix::io_uring—Linux io_uring. |
mm | rustix::mm—Memory map operations. |
mount | rustix::mount—Linux mount API. |
net | rustix::net—Network-related operations. |
param | rustix::param—Process parameters. |
pipe | rustix::pipe—Pipe operations. |
process | rustix::process—Process-associated operations. |
pty | rustix::pty—Pseudoterminal operations. |
rand | rustix::rand—Random-related operations. |
shm | rustix::shm—POSIX shared memory. |
stdio | —Stdio-related operations. |
This is the beginning of the README. Read the rest at the original. Read the full README ↗
rustix::stdiosystem | rustix::system—System-related operations. |
termios | rustix::termios—Terminal I/O stream operations. |
thread | rustix::thread—Thread-associated operations. |
time | rustix::time—Time-related operations. |
use-libc | Enable the libc backend. |
linux_4_11 | Enable optimizations that assume Linux ≥ 4.11 |
linux_5_1 | Enable optimizations that assume Linux ≥ 5.1 |
linux_5_11 | Enable optimizations that assume Linux ≥ 5.11 |
linux_latest | Enable optimizations that assume the latest Linux release |
use-libc-auxv | Use getauxval instead of PR_GET_AUXV or "/proc/self/auxv". |
std | On by default; disable to activate #![no_std]. |
alloc | On by default; enables features that depend on alloc. |