Crate base

source ·
Expand description

Safe, cross-platform-compatible wrappers for system interfaces.


pub use platform::ioctl::ioctl;
pub use platform::ioctl::ioctl_with_mut_ptr;
pub use platform::ioctl::ioctl_with_mut_ref;
pub use platform::ioctl::ioctl_with_ptr;
pub use platform::ioctl::ioctl_with_ref;
pub use platform::ioctl::ioctl_with_val;
pub use platform::ioctl::IoctlNr;
pub use tube::ProtoTube;
pub use tube::Tube;
pub use wait_context::EventToken;
pub use sys::linux;
pub use linux::add_fd_flags;
pub use linux::clear_fd_flags;
pub use linux::clone_descriptor;
pub use linux::validate_raw_descriptor;
pub use linux::clear_descriptor_cloexec;
pub use linux::block_signal;
pub use linux::clear_signal;
pub use linux::get_blocked_signals;
pub use linux::new_pipe_full;
pub use linux::signal;
pub use linux::unblock_signal;
pub use linux::Killable;
pub use linux::SIGRTMIN;
pub use linux::pipe;
pub use linux::flock;
pub use linux::FlockOperation;
pub use linux::getegid;
pub use linux::geteuid;
pub use linux::gettid;
pub use linux::kill_process_group;
pub use linux::reap_child;
pub use linux::sched_attr;
pub use linux::sched_setattr;
pub use linux::UnlinkUnixListener;
pub use linux::Gid;
pub use sys::unix;
pub use unix::net::UnixSeqpacket;
pub use unix::net::UnixSeqpacketListener;
pub use unix::net::UnlinkUnixSeqpacketListener;
pub use unix::pagesize;
pub use unix::Pid;
pub use descriptor_reflection::deserialize_with_descriptors;
pub use descriptor_reflection::with_as_descriptor;
pub use descriptor_reflection::with_raw_descriptor;
pub use descriptor_reflection::FileSerdeWrapper;
pub use descriptor_reflection::SerializeDescriptors;
pub use platform::getpid;
pub use platform::open_file_or_duplicate;
pub use platform::platform_timer_resolution::enable_high_res_timers;
pub use platform::RawDescriptor;
pub use platform::INVALID_DESCRIPTOR;
pub use crate::descriptor::AsRawDescriptor;
pub use crate::descriptor::AsRawDescriptors;
pub use crate::descriptor::Descriptor;
pub use crate::descriptor::FromRawDescriptor;
pub use crate::descriptor::IntoRawDescriptor;
pub use crate::descriptor::SafeDescriptor;


alloc 🔒
clock 🔒
Library for custom implementations of serialize/deserialize.
Provides infrastructure for de/serializing descriptors embedded in Rust data structures.
errno 🔒
event 🔒
iobuf 🔒
Cross platform IoBuf and IoBufMut types wrapping iovec/WSABUF.
mmap 🔒
notifiers 🔒
shm 🔒
Facilities for sending log message to syslog.
timer 🔒
tube 🔒
Types for volatile access to memory.
Worker thread abstraction


Logs a message at the debug level.
Logs a message at the error level.
Macro that retries the given expression every time its result indicates it was interrupted (i.e. returned EINTR). This is useful for operations that are prone to being interrupted by signals, such as blocking syscalls.
Macro that retries the given expression every time its result indicates it was interrupted. It is intended to use with system functions that signal error by returning -1 and setting errno to appropriate error code (EINTR, EINVAL, etc.) Most of standard non-reentrant libc functions use this way of signalling errors.
Macro that retries the given expression every time its result indicates it was interrupted. It is intended to use with system functions that return EINTR and other error codes directly as their result. Most of reentrant functions use this way of signalling errors.
Logs a message at the info level.
Raw macro to declare the expression that calculates an ioctl number
Declare an ioctl that transfers no data.
Raw macro to declare a function that returns an ioctl number.
Declare an ioctl that reads data.
Declare an ioctl that writes data.
Declare an ioctl that reads and writes data.
Logs a message at the trace level.
Logs a message at the warn level.


A system error In Unix systems, retrieved from errno (man 3 errno), set by a libc function that returned an error. On Windows, retrieved from GetLastError, set by a Windows function that returned an error
An inter-process event wait/notify mechanism. Loosely speaking: Writes signal the event. Reads block until the event is signaled and then clear the signal.
Used to poll multiple objects that have file descriptors.
A fake clock that can be used in tests to give exact control over the time. For a code example, see the tests in base/src/
FakeTimer: For use in tests.
Cross-platform mutable buffer.
A contiguous memory allocation with a specified size and alignment, with a Drop impl to perform the deallocation.
See MemoryMapping for struct- and method-level documentation.
Tracks Fixed Memory Maps within an anonymous memory-mapped fixed-sized arena in the current process.
Safe wrapper for NETLINK_GENERIC netlink sockets.
Memory access type for anonymous shared memory mapping.
A Tube end which can only recv messages.
Trait for file descriptors can send and receive socket control messages via sendmsg and recvmsg.
A Tube end which can only send messages. Cloneable.
A shared memory file descriptor and its size.
A safe wrapper around a Linux signalfd (man 2 signalfd).
An abstraction over named pipes and unix socketpairs. This abstraction can be used in a blocking and non blocking mode.
Represents an event that has been signaled and waited for via a wait function.
A slice of raw memory that supports volatile access. Like std::io::IoSliceMut, this type is guaranteed to be ABI-compatible with libc::iovec but unlike IoSliceMut, it doesn’t automatically deref to &mut [u8].
Used to wait for multiple objects which are eligible for waiting.
Wrapper object for creating a worker thread that can be stopped by signaling an event.



The maximum number of FDs that can be sent in a single send.


An empty trait that helps reset timer resolution to its previous state.
Linux specific extensions to Event.
Trait that can be used to associate events with arbitrary enums when using WaitContext.
A trait for allocating disk space in a sparse file. This is equivalent to fallocate() with no special flags.
A trait for getting the size of a file. This is equivalent to File’s metadata().len() method, but wrapped in a trait so that it can be implemented for other types.
A trait similar to the unix ReadExt and WriteExt traits, but for volatile memory.
A trait similar to Read and Write, but uses volatile memory as buffers.
A trait for setting the size of a file. This is equivalent to File’s set_len method, but wrapped in a trait so that it can be implemented for other types.
A trait for flushing the contents of a file to disk. This is equivalent to File’s sync_all and sync_data methods, but wrapped in a trait so that it can be implemented for other types.
A range of memory that can be msynced, for abstracting over different types of memory mappings.
A trait for deallocating space in a file.
A trait for deallocating space in a file of a mutable reference
Trait for file descriptors that are TTYs, according to isatty(3).
A trait for timer objects that delivers timer expiration notifications to an underlying descriptor.
Trait for types that support raw volatile access to their data.
A trait for writing zeroes to an arbitrary position in a file.


Drops all capabilities (permitted, inheritable, and effective) from the current process.
Enable experimental core scheduling for the current thread.
Returns the last errno as a Result that is always an error.
Creates a UUID.
Obtain file system type of the file system that the file is served from.
Read raw bytes from stdin.
Uses the system’s page size in bytes to round the given value up to the nearest page boundary.
Set the CPU affinity of the current thread to a given set of CPUs.
Enables real time thread priorities in the current thread up to limit.
Sets the current thread to be scheduled using the round robin real time class with priority.

Type Definitions

Cross platform binary compatible iovec. See crate::IoBufMut for documentation.

Derive Macros

Implements the EventToken trait for a given enum.