Crate base

Source
Expand description

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

Re-exportsยง

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 sys::linux;
pub use linux::clone_descriptor;
pub use linux::safe_descriptor_from_path;
pub use linux::validate_raw_descriptor;
pub use linux::clear_descriptor_cloexec;
pub use linux::safe_descriptor_from_cmdline_fd;
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::register_rt_signal_handler;
pub use linux::signal;
pub use linux::unblock_signal;
pub use linux::Killable;
pub use linux::SIGRTMIN;
pub use linux::AcpiNotifyEvent;
pub use linux::NetlinkGenericSocket;
pub use linux::SignalFd;
pub use linux::Terminal;
pub use linux::drop_capabilities;
pub use linux::pipe;
pub use linux::read_raw_stdin;
pub use linux::enable_core_scheduling;
pub use linux::set_rt_prio_limit;
pub use linux::set_rt_round_robin;
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::logical_core_capacity;
pub use linux::logical_core_cluster_id;
pub use linux::logical_core_frequencies_khz;
pub use linux::logical_core_max_freq_khz;
pub use linux::sched_attr;
pub use linux::sched_setattr;
pub use linux::UnlinkUnixListener;
pub use linux::EventExt;
pub use linux::Gid;
pub use sys::unix;
pub use unix::IoBuf;
pub use unix::net::UnixSeqpacket;
pub use unix::net::UnixSeqpacketListener;
pub use unix::net::UnlinkUnixSeqpacketListener;
pub use unix::ScmSocket;
pub use unix::SCM_SOCKET_MAX_FD_COUNT;
pub use unix::add_fd_flags;
pub use unix::clear_fd_flags;
pub use unix::number_of_logical_cores;
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::get_cpu_affinity;
pub use platform::getpid;
pub use platform::open_file_or_duplicate;
pub use platform::platform_timer_resolution::enable_high_res_timers;
pub use platform::set_cpu_affinity;
pub use platform::set_thread_name;
pub use platform::BlockingMode;
pub use platform::EventContext;
pub use platform::FramingMode;
pub use platform::MemoryMappingArena;
pub use platform::RawDescriptor;
pub use platform::StreamChannel;
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;

Modulesยง

alloc ๐Ÿ”’
clock ๐Ÿ”’
custom_serde
Library for custom implementations of serialize/deserialize.
descriptor
descriptor_reflection
Provides infrastructure for de/serializing descriptors embedded in Rust data structures.
errno ๐Ÿ”’
event ๐Ÿ”’
file_traits ๐Ÿ”’
iobuf ๐Ÿ”’
Cross platform IoBuf and IoBufMut types wrapping iovec/WSABUF.
mmap ๐Ÿ”’
notifiers ๐Ÿ”’
periodic_logger ๐Ÿ”’
shm ๐Ÿ”’
sys
syslog
Facilities for sending log message to syslog.
test_utils
timer ๐Ÿ”’
tube ๐Ÿ”’
volatile_memory ๐Ÿ”’
Types for volatile access to memory.
wait_context ๐Ÿ”’
worker_thread ๐Ÿ”’
Worker thread abstraction
write_zeroes ๐Ÿ”’

Macrosยง

debug
Logs a message at the debug level.
error
Logs a message at the error level.
handle_eintr
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.
handle_eintr_errno
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.
handle_eintr_rc
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.
info
Logs a message at the info level.
ioctl_expr
Raw macro to declare the expression that calculates an ioctl number
ioctl_io_nr
Declare an ioctl that transfers no data.
ioctl_ioc_nr
Raw macro to declare a constant or a function that returns an ioctl number.
ioctl_ior_nr
Declare an ioctl that reads data.
ioctl_iow_nr
Declare an ioctl that writes data.
ioctl_iowr_nr
Declare an ioctl that reads and writes data.
poll_assert
Assert repeatedly until itโ€™s true
syscall
trace
Logs a message at the trace level.
volatile_at_impl
volatile_impl
warn
Logs a message at the warn level.

Structsยง

Clock
Error
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
Event
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.
ExternalMapping
FakeClock
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/timer.rs.
FakeTimer
FakeTimer: For use in tests.
IoBufMut
Cross-platform mutable buffer.
LayoutAllocation
A contiguous memory allocation with a specified size and alignment, with a Drop impl to perform the deallocation.
MemoryMapping
See MemoryMapping for struct- and method-level documentation.
MemoryMappingBuilder
Protection
Memory access type for anonymous shared memory mapping.
RecvTube
A Tube end which can only recv messages.
SendTube
A Tube end which can only send messages. Cloneable.
SharedMemory
A shared memory file descriptor and its size.
Timer
TriggeredEvent
Represents an event that has been signaled and waited for via a wait function.
VolatileSlice
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].
WaitContext
Used to wait for multiple objects which are eligible for waiting.
WorkerThread
Wrapper object for creating a worker thread that can be stopped by signaling an event.

Enumsยง

EventType
Represents types of events to watch for.
EventWaitResult
MmapError
TubeError
VmEventType
VolatileMemoryError

Traitsยง

CloseNotifier
EnabledHighResTimer
An empty trait that helps reset timer resolution to its previous state.
EventToken
Trait that can be used to associate events with arbitrary enums when using WaitContext.
FileAllocate
A trait for allocating disk space in a sparse file. This is equivalent to fallocate() with no special flags.
FileGetLen
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.
FileReadWriteAtVolatile
A trait similar to the unix ReadExt and WriteExt traits, but for volatile memory.
FileReadWriteVolatile
A trait similar to Read and Write, but uses volatile memory as buffers.
FileSetLen
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.
FileSync
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.
MappedRegion
A range of memory that can be msynced, for abstracting over different types of memory mappings.
PunchHole
A trait for deallocating space in a file.
ReadNotifier
TimerTrait
A trait for timer objects that delivers timer expiration notifications to an underlying descriptor.
VolatileMemory
Trait for types that support raw volatile access to their data.
WriteZeroesAt
A trait for writing zeroes to an arbitrary position in a file.

Functionsยง

errno_result
Returns the last errno as a Result that is always an error.
generate_uuid
Creates a UUID.
round_up_to_page_size
Uses the systemโ€™s page size in bytes to round the given value up to the nearest page boundary.

Type Aliasesยง

MmapResult
Result
TubeResult
VolatileMemoryResult

Derive Macrosยง

EventToken
Implements the EventToken trait for a given enum.