Expand description
§veilid-tools
A collection of baseline tools for Rust development use by Veilid and Veilid-enabled Rust applications
These are used by veilid-core, veilid-server, veilid-cli and may be used by any other applications
that link in veilid-core if a common baseline of functionality is desired. Extending this crate with new
utility functions is encouraged rather than adding ‘common’ functionality to veilid-core, allowing it to
remain free of boilerplate and utility classes that could be reused elsewhere.
Everything added to this crate must be extensively unit-tested (work in progress).
§Cargo features
The default veilid-tools configurations are:
default- Usestokioas the async runtime
If you use --no-default-features, you can switch to other runtimes:
rt-async-std- Usesasync-stdas the async runtimert-wasm-bindgen- When building for thewasm32architecture, use this to enablewasm-bindgen-futuresas the async runtime
Re-exports§
pub use std::borrow::Cow;pub use std::borrow::ToOwned;pub use std::boxed::Box;pub use std::cell::RefCell;pub use std::cmp;pub use std::collections::btree_map::BTreeMap;pub use std::collections::btree_set::BTreeSet;pub use std::collections::hash_map::HashMap;pub use std::collections::hash_set::HashSet;pub use std::collections::LinkedList;pub use std::collections::VecDeque;pub use std::convert::TryFrom;pub use std::convert::TryInto;pub use std::fmt;pub use std::future::Future;pub use std::mem;pub use std::net::IpAddr;pub use std::net::Ipv4Addr;pub use std::net::Ipv6Addr;pub use std::net::SocketAddr;pub use std::net::SocketAddrV4;pub use std::net::SocketAddrV6;pub use std::net::ToSocketAddrs;pub use std::ops::Fn;pub use std::ops::FnMut;pub use std::ops::FnOnce;pub use std::pin::Pin;pub use std::rc::Rc;pub use std::str::FromStr;pub use std::string::String;pub use std::string::ToString;pub use std::sync::atomic::AtomicBool;pub use std::sync::atomic::AtomicUsize;pub use std::sync::atomic::Ordering;pub use std::sync::Arc;pub use std::sync::LazyLock;pub use std::sync::Weak;pub use std::task;pub use std::time::Duration;pub use std::vec::Vec;pub use tokio::task::JoinHandle as LowLevelJoinHandle;pub use bytes;pub use fn_name;pub use hex;pub use parking_lot;pub use shell_words;
Modules§
- assembly_
buffer - Packet fragmentation and reassembly for the sender and receiver ends. Packet reassembly and fragmentation handler
- async_
locks - Debuggable async lock primitives (mutex, rwlock). Debuggable Async Locks
- async_
peek_ stream - Stream adapter that allows peeking buffered bytes without consuming them.
- bytes_
writer io::Writeadapter that appends into aBytesMutbuffer.- clone_
stream - Broadcast stream that hands each subscriber its own clone of every item.
- cpu_
pool - Dedicated FIFO thread pool for heavy CPU work.
- debugging
- Debugger attachment detection and wait-for-attach.
- deferred_
stream_ processor - Runs futures to completion in the background and routes their results to a stream.
- event_
bus - Subscribe/publish event bus for type-keyed events. Event Bus
- eventual
- One-shot resolvable signal with futures that wait on resolution.
- eventual_
base - Shared base machinery behind the
Eventualfamily. - eventual_
value Eventualcarrying a single by-value payload to one waiter.- eventual_
value_ clone Eventualcarrying a payload cloned to every waiter.- flap_
detector - Hysteresis detector that debounces a value flapping between states.
- formatting
- String indentation, human-readable byte counts, and formatter helpers.
- future_
queue - Batched, concurrency-limited processing of future queues and streams.
- future_
race_ completion - Pool that races spawned futures and optionally reports their completion. FutureRaceCompletionPool
- igd
- UPnP gateway discovery and port mapping.
- interval
- Periodic interval timer driving an async callback.
- ip_
addr_ port - IP address paired with a port.
- ip_
extra - IP address classification helpers (global, loopback, multicast scope).
- ipc
- Inter-process communication over named pipes (Windows) or unix sockets.
- log_
unwrap unwrap/expectvariants that log throughtracingorlogon failure. Fork oftracing-unwrapcrate, modified to also allow non-tracing loggers to function- must_
join_ handle - Join handle that aborts on drop if not already joined.
- must_
join_ single_ future - Single-slot future runner that joins the prior run before starting the next.
- network_
interfaces - Enumeration of host network interfaces and their addresses.
- network_
result - Result type distinguishing network-level outcomes from hard errors.
- pin
- Type aliases for pinned, boxed futures.
- random
- Cryptographically secure RNG and random number helpers.
- raw_
timestamp - Raw integer timestamps with duration parsing and human formatting.
- resolver
- DNS resolution via the system resolver or hickory-resolver.
- single_
shot_ eventual - Single-fire eventual whose resolution returns the prior pending value.
- sleep
- Async sleep for a number of milliseconds.
- socket_
tools - UDP/TCP socket binding and connection helpers with reuse and linger options.
- spawn
- Spawn blocking work and yield control on the async runtime.
- split_
url - URL parser splitting scheme, host, port, and path into typed parts.
- startup_
lock - Lock gating startup and shutdown against in-flight operations.
- static_
string_ table - Interning of borrowed strings into
&'static str. - stop_
token - Drop-triggered cancellation tokens and deadline-bounded future combinators.
- system_
info - Total system memory query.
- tag_
lock - Per-tag lock table serializing access by key.
- tick_
task - Self-rescheduling periodic task with single-instance run guarantees.
- timeout
- Run a future with a millisecond timeout.
- timeout_
or - Timeout combinator returning either the value, a timeout, or an error.
- tools
- Assorted small utilities (time conversion, retry, comparison helpers).
- tracked_
mutex parking_lot::Mutexwrapper that records the holder for debugging.TrackedMutex<T>: a drop-inparking_lot::Mutex<T>wrapper that, under thedebug-locksfeature, records the owning thread plus an acquisition backtrace and reports the holder when an acquisition cannot complete — covering the case the asyncparking_lotdeadlock detector cannot: a sync lock whose holder is a suspended task or a re-entrant acquire on a runtime so starved that the detector task itself can never be scheduled to run.
Macros§
- assert_
err - Assert that an expression evaluates to
Err(..), panicking with theOkvalue otherwise. - bail_
io_ error_ other - Return early with an
io::Errorof kindOtherbuilt from anythingToString. - debug_
target_ enabled - True if DEBUG-level logging is enabled for the given target.
- io_
error_ other - Build an
io::Errorof kindOtherfrom anythingToString. - network_
result_ raise - Returns early from the enclosing
Result<NetworkResult<_>, _>-returning function, re-raising a non-valueNetworkResultunder a new value type. Panics onValue. - network_
result_ try - Unwraps the
Valueof aNetworkResult, or returns the non-value variant early from the enclosingResult<NetworkResult<_>, _>-returning function. The=> $fform runs$fbefore returning, for cleanup on the early-exit path. - pin_
dyn_ future - Pin a future to the heap, returning a
PinBoxFuturetrait object. - pin_
dyn_ future_ closure - Pin a future to the heap inside a closure, returning a
PinBoxFuturetrait object. - pin_
future - Pin a future to the heap, returning a concrete boxed future.
- pin_
future_ closure - Pin a future to the heap inside a closure, returning a concrete boxed future.
- timeout_
or_ try - Unwrap a
TimeoutOrvalue or short-circuit a timeout out of the enclosing function.
Structs§
- Address
Flags - Some of the flags associated with an address
- Alternate
Display Format - Formats values with
fmt::Displayusing{:#}(alternate form always on). - Assembly
Buffer - Packet reassembly and fragmentation handler
- Async
Keyed Cache - A bounded keyed cache where each key has its own async lock.
- Async
Keyed Cache Entry - A locked handle to one key’s slot in an
AsyncKeyedCache. - Async
Mutex - An async mutex giving one holder at a time exclusive access to
T. - Async
Mutex Guard - Borrowed guard holding the mutex; derefs to
T(mutably) and unlocks on drop. - Async
Mutex Guard Arc - Owned guard holding the mutex; derefs to
T(mutably) and unlocks on drop. - Async
Peek Stream - An
AsyncRead+AsyncWritestream wrapper that allows peeking at incoming bytes without consuming them. - Async
RwLock - An async reader-writer lock allowing many concurrent readers or one writer.
- Async
RwLock Read Guard - Borrowed guard for shared read access; derefs to
Tand releases on drop. - Async
RwLock Read Guard Arc - Owned guard for shared read access; derefs to
Tand releases on drop. - Async
RwLock Write Guard - Borrowed guard for exclusive write access; derefs to
T(mutably) and releases on drop. - Async
RwLock Write Guard Arc - Owned guard for exclusive write access; derefs to
T(mutably) and releases on drop. - Async
Semaphore - An async counting semaphore bounding the number of concurrent permit holders.
- Async
Semaphore Guard - A borrowed guard that releases its permit on drop.
- Async
Semaphore Guard Arc - An owned guard that releases the acquired permit.
- Async
TagLock Guard - A guard holding the lock for one tag; releases it on drop.
- Async
TagLock Table - A table of per-tag async locks, sharable across tasks.
- Async
Weighted Semaphore - A semaphore admitting weighted permits under a runtime-adjustable capacity limit.
- Async
Weighted Semaphore Guard - A guard holding
weightunits; releases them back to the semaphore on drop. - Bytes
Writer - A
std::io::Writeadapter over aBytesMutbuffer. - Clone
Stream - A cloneable wrapper that shares one stream behind an
Arc<Mutex<_>>. - Compat
- A compatibility layer that allows conversion between the
tokio::ioandfutures-ioAsyncReadandAsyncWritetraits. - Debug
Guard - Scope guard that prints to stderr and bumps a shared counter on entry, then decrements and prints on drop.
- Default
Display Format - Formats values with
fmt::Displayusing{}only (ignores alternate form). - Deferred
Stream Processor - Background processor for streams Handles streams to completion, passing each item from the stream to a callback
- Event
Bus - Event bus
- Event
BusSubscription - Handle to a registered event handler, passed to
unsubscribeto remove it. - Eventual
- A valueless one-shot signal. Many instance futures attach and all complete
when
resolveis called once. Each instance future may carry its own output value, supplied at attach time rather than at resolution. - Eventual
Future Clone - Instance future from
Eventual::instance_clone; resolves to a clone of its attached value. - Eventual
Future Empty - Instance future from
Eventual::instance_empty; resolves to(). - Eventual
Future None - Instance future from
Eventual::instance_none; resolves toNone. - Eventual
Resolved Future - Future returned by
resolve; completes once every instance future of the resolvedEventualhas been polled and dropped. - Eventual
Value - A one-shot signal carrying a single owned value. Instance futures complete
when
resolveis called; exactly one consumer maytake_valuethe resolved value out. - Eventual
Value Clone - A one-shot signal carrying a cloneable value. Every instance future resolves
to its own clone of the resolved value; the value also stays readable via
value. - Eventual
Value Clone Future - Instance future from
EventualValueClone::instance; resolves to a clone of the resolved value. - Eventual
Value Future - Instance future from
EventualValue::instance; resolves to a clone of the owningEventualValueso the value can be taken from it. - Flap
Detector - Flapping detector: decaying-penalty counter (BGP-damping style) over an observed value.
recordcounts a transition whenever the value differs from the last observed one; the penalty decays withhalf_life_usand crossingthresholdmeans flapping. Timestamps are raw microseconds (veilid-tools has no Timestamp type). - Future
Race Completion Pool - Pool that runs handed-off futures to completion. Cheap to clone.
- Ifv4
Addr - Details about the ipv4 address of an interface on this host.
- Ifv6
Addr - Details about the ipv6 address of an interface on this host.
- Interface
Address - An address bound to an interface, with its flags. Ordered by reachability preference.
- Interface
Flags - Some of the flags associated with an interface
- IpAddr
Port - An IP address paired with a port, without the flowinfo and scope_id carried by
SocketAddrV6. - IpcIncoming
- Stream of incoming IPC connections, yielded by
IpcListener::incoming. - IpcListener
- Listener that accepts incoming IPC connections. Backed by a unix domain socket.
- IpcStream
- A bidirectional IPC connection. Backed by a unix domain socket.
- Must
Join Handle - Wrapper around a task join handle that panics if dropped before the task is joined, detached, or aborted.
- Must
Join Single Future - Spawns a single background processing task idempotently, possibly returning the return value of the previously executed background task This does not queue, just ensures that no more than a single copy of the task is running at a time, but allowing tasks to be retriggered
- Network
Interface - A single network interface on this host, with its flags, gateways, and addresses.
- Network
Interface Address State - The best routable gateway and interface addresses distilled from all interfaces.
- Network
Interfaces - Cross-platform enumeration of this host’s network interfaces and their addresses.
- Network
Interfaces Inner - Mutex-guarded interior state of
NetworkInterfaces. - Peek
- Future returned by
AsyncPeekStream::peek. - Peek
Exact - Future returned by
AsyncPeekStream::peek_exact. - RawAddress
Summary - Which address families are present across the running non-loopback interfaces.
- Resolver
- Cross-platform DNS resolver. This backend uses hickory-resolver, trying the system configuration first and falling back to a default resolver.
- Single
Shot Eventual - An
EventualValuethat resolves exactly once.resolveconsumes it; if it is dropped without resolving, it resolves to thedrop_valuegiven at construction (if any), so awaiters never hang. - Split
Url - A URL split into its components, parsed from
scheme://[userinfo@]host[:port][/path]. - Split
UrlError - Error returned when parsing a URL component fails.
- Split
UrlPath - The portion of a URL after the host and port: path, optional fragment, optional query.
- Startup
Lock - Synchronization mechanism that tracks the startup and shutdown of a region of code. Guarantees that some code can only be started up once and shut down only if it is already started. Also tracks if the code is in-use and will wait for all ‘entered’ code to finish before shutting down. Once a shutdown is requested, future calls to ‘enter’ will fail, ensuring that nothing is ‘entered’ at the time of shutdown. This allows an asynchronous shutdown to wait for operations to finish before proceeding.
- Startup
Lock Already Shut Down Error - Returned by
shutdownwhen the lock is already in the shut down state. - Startup
Lock Already Started Error - Returned by
startupwhen the lock is already in the started state. - Startup
Lock Enter Guard - RAII-style lock for entry operations on a started-up region of code.
- Startup
Lock Enter Guard Arc - RAII-style lock for entry operations on a started-up region of code.
- Startup
Lock Guard - RAII-style lock for startup and shutdown operations Must call ‘success()’ on this lock to report a successful startup or shutdown Dropping this lock without calling ‘success()’ first indicates a failed startup or shutdown operation
- Startup
Lock NotStarted Error - Returned by
enterwhen the lock is not in the started state. - Stop
Source - Cancellation source; dropping it stops every associated
StopToken. - Stop
Token - Future that resolves when its
StopSourceis dropped. - TagLock
Guard - Holds the lock for one tag in a
TagLockTable. The tag is released and its table entry reclaimed when the last clone of the guard drops. - TagLock
Table - A table of mutexes keyed by tag. Locking a tag blocks only other lockers of the same tag; distinct tags never contend. Entries are created on first lock and removed when their last guard drops.
- TcpListener
- A TCP socket server, listening for connections.
- TcpStream
- A TCP stream between a local and a remote socket.
- Tick
Task - Runs a single-future background processing task, attempting to run it once every ‘tick period’ microseconds. If the prior tick is still running, it will allow it to finish, and do another tick when the timer comes around again. One should attempt to make tasks short-lived things that run in less than the tick period if you want things to happen with regular periodicity.
- Timed
OutError - Error returned by
future::FutureExt::timeout_atwhen the deadline fires first. - Timeout
Error - An operation did not complete before its deadline.
- UdpSocket
- A UDP socket.
- Veilid
Rng - Cryptographically secure RNG that draws from the thread-local random source.
Enums§
- Debugger
State - Debugger attachment state of the current process.
- Deferred
Stream Result - Result of a per-item handler, controlling whether stream processing continues.
- Future
Race Completion - Outcome of
race_complete_on - IfAddr
- An interface address that is either IPv4 or IPv6, with its netmask and broadcast address.
- Ipv6
Multicast Scope - Scope of an IPv6 multicast address (RFC 4291 § 2.7), in increasing reach.
- Network
Result - Outcome of a network operation that separates a real
Valuefrom benign network conditions which should not be treated as hard errors. - Resolver
Error - Error returned by DNS resolution operations.
- Split
UrlHost - The host field of a URL: either a DNS hostname or an IP address.
- Timeout
Or - The outcome of an operation that may either time out or produce a value.
Constants§
- DEBUG_
LOCKS_ DURATION_ MS - Timeout under the
debug-locksfeature after which a pending acquisition is reported as a deadlock. - DEFAULT_
INDENT_ SPACES - Spaces prepended by
indent_stringandindent_all_string - FRAGMENT_
LEN - The hard-coded maximum fragment size used by AssemblyBuffer
Traits§
- CmpAssign
- In-place
min/maxassignment for ordered types. - Eventual
Common - Operations available on every
Eventualvariant. Blanket-implemented for allEventualBasetypes. - Folded
Network Result Ext - Folds a timeout-or-io outcome into a single
NetworkResult. - Formatter
ToString - Format
fmt::Displayvalues toString, respecting a formatter-style alternate flag. - Future
Race Completion Pool Ext - Trait that adds
race_complete_onto any future - Futures
Async Read Compat Ext - Extension trait that allows converting a type implementing
futures_io::AsyncReadto implementtokio::io::AsyncRead. - Futures
Async Write Compat Ext - Extension trait that allows converting a type implementing
futures_io::AsyncWriteto implementtokio::io::AsyncWrite. - HasDuplicates
- Check for duplicates but doesn’t require a sorted vec
- IoNetwork
Result Ext - Folds an
io::Resultinto aNetworkResult, routing benign socket errors to the matching network condition. - IoTimeout
OrExt - Split a timed-out
io::Resultoff into aTimeoutOr. - Network
Result Ext - Folds a
TimeoutErroroutcome into aNetworkResult. - Network
Result Result Ext - Swaps the nesting of a
NetworkResultwrapping aResult. - Option
Ext - Extension trait for Option types.
- Remove
Duplicates - Dedup, but doesn’t require a sorted vec, and keeps the element order
- Result
Ext - Extension trait for Result types.
- Static
StrTransform - Cache the result of transforming a
&'static str, keyed by its pointer and length. - String
IfEmpty - Substitute a placeholder for an empty string.
- Strip
Trailing Newline - Strip a trailing
\nor\r\nfrom a string-like value. - Timeout
OrExt - Convert a
Result<T, TimeoutError>into aTimeoutOr<T>. - Timeout
OrResult Ext - Hoist the error out of a
TimeoutOr<Result<T, E>>. - ToMultiline
String - Generate multiline human-readable output
- ToStatic
Str - Intern a string into a process-global table, returning a
&'static strfor it. - ToTable
String - Trait for printing values in a human-readable table format
- Tokio
Async Read Compat Ext - Extension trait that allows converting a type implementing
tokio::io::AsyncReadto implementfutures_io::AsyncRead. - Tokio
Async Write Compat Ext - Extension trait that allows converting a type implementing
tokio::io::AsyncWriteto implementfutures_io::AsyncWrite.
Functions§
- aligned_
8_ ⚠u8_ vec_ uninit - Safety
- async_
tcp_ listener_ incoming - Wrap a
TcpListeneras a stream of acceptedTcpStreamconnections. - async_
try_ at_ most_ n_ things - Await
closureon items in order until one returnsSome, giving up aftermaxfailures. - available_
unspecified_ addresses - Unspecified addresses for every locally supported IP family (IPv4 always, IPv6 if available).
- bind_
async_ tcp_ listener - Bind a TCP listener to
local_address. - bind_
async_ udp_ socket - Bind a UDP socket to
local_addresswithSO_REUSEADDR/SO_REUSEPORTset. - blocking_
wrapper - Run a blocking closure on the runtime’s dedicated blocking-thread pool and await its result.
- blocking_
yielding - For things that use locks or IO operations or cpu tasks that take between 10-100us
- compatible_
unspecified_ socket_ addr - Unspecified address and port zero matching the address family of
socket_addr. - connect_
async_ tcp_ stream - Connect a TCP stream to
remote_address, optionally bound tolocal_address. - cpu_
pool_ spawn_ fifo - Run a task on the dedicated CPU pool in FIFO order.
- cpu_
yielding - For heavy cpu-intensive tasks that do not use locks or IO operations > (100us)
- debugger_
state - Determine whether a debugger is attached to the current process.
- domain_
for_ address - The socket address family (
AF_INET/AF_INET6) foraddress. - ensure_
directory_ private_ owner - Ensure
path, if it exists as a directory, is mode 0o700 (or 0o750 whengroup_read) and owned by the current user and group. - ensure_
file_ private_ owner - Ensure
path, if it exists as a file, is mode 0o600 and owned by the current user and group. - get_
concurrency - Number of available hardware threads, falling back to 1 if it cannot be determined.
- get_
random_ u32 - Return a cryptographically secure random
u32. - get_
random_ u64 - Return a cryptographically secure random
u64. - get_
raw_ timestamp - Current wall-clock time as microseconds since the Unix epoch.
- human_
byte_ count - Format a byte count as a human-readable string with binary (1024-based) GB/MB/KB/B units.
- human_
byte_ data - Format a byte slice for display: ASCII-printable data is shown as text, otherwise as shell-quoted
text or hex (whichever is shorter). Truncated to
truncate_lenbytes with a trailing...when set. - human_
duration - Format a microsecond duration as a human-readable string, e.g.
1d2h3m4.005sor1.005ms. - human_
timestamp - Format a microsecond Unix timestamp as a UTC string, omitting date fields that match the current time.
- indent_
all_ string - Indent every line of
s - indent_
string - Indent all but the first line of
s - interval
- Spawn a named task that invokes
callbackeveryfreq_msmilliseconds. - ip_
to_ ipblock - Collapses an address to its allocation block by masking the host bits.
- ipaddr_
apply_ netmask - Applies
netmasktoaddr, zeroing the host bits. ReturnsNoneif the address and netmask are different IP families. - ipaddr_
in_ network - True if
addrfalls within the networknetaddr/netmask. False ifaddrandnetaddrare different IP families. - ipaddr_
is_ documentation - Address is reserved for documentation (RFC 5737 / RFC 3849).
- ipaddr_
is_ global - Address is globally routable on the public internet.
- ipaddr_
is_ loopback - Address points at the host itself (
127.0.0.0/8or::1). - ipaddr_
is_ multicast - Address is in a multicast range (IPv4
224.0.0.0/4or IPv6ff00::/8). - ipaddr_
is_ unspecified - Address has the all-zeros bit pattern (IPv4
0.0.0.0or IPv6::). - ipv4addr_
is_ benchmarking - IPv4 RFC 2544 benchmarking range
198.18.0.0/15. - ipv4addr_
is_ broadcast - IPv4 limited broadcast address
255.255.255.255. - ipv4addr_
is_ documentation - IPv4 documentation ranges (RFC 5737):
192.0.2.0/24,198.51.100.0/24,203.0.113.0/24. - ipv4addr_
is_ global - IPv4 address is globally routable on the public internet.
- ipv4addr_
is_ ietf_ protocol_ assignment - IPv4 IETF protocol assignment range
192.0.0.0/24(RFC 6890). - ipv4addr_
is_ link_ local - IPv4 link-local / APIPA range
169.254.0.0/16(RFC 3927) — DHCP-fallback addresses. - ipv4addr_
is_ loopback - IPv4 loopback range
127.0.0.0/8(RFC 1122). - ipv4addr_
is_ multicast - IPv4 multicast range
224.0.0.0/4(RFC 5771). - ipv4addr_
is_ private - IPv4 RFC 1918 private ranges:
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16. - ipv4addr_
is_ reserved - IPv4 reserved range
240.0.0.0/4(RFC 1112), excluding the broadcast address. - ipv4addr_
is_ shared - IPv4 RFC 6598 shared address space
100.64.0.0/10— used for carrier-grade NAT (CGNAT). - ipv4addr_
is_ unspecified - IPv4 unspecified address
0.0.0.0. - ipv6addr_
is_ 6to4 - IPv6 6to4 prefix
2002::/16(RFC 3056) — IPv6-in-IPv4 transitional encapsulation. - ipv6addr_
is_ documentation - IPv6 documentation range
2001:db8::/32(RFC 3849). - ipv6addr_
is_ global - IPv6 address is globally routable on the public internet.
- ipv6addr_
is_ loopback - IPv6 loopback
::1. - ipv6addr_
is_ multicast - IPv6 multicast range
ff00::/8(RFC 4291). - ipv6addr_
is_ nat64_ well_ known - IPv6 well-known NAT64 prefix
64:ff9b::/96(RFC 6052) — synthesised IPv6 wrapping public IPv4. - ipv6addr_
is_ teredo - IPv6 Teredo prefix
2001::/32(RFC 4380) — IPv6-in-UDP/IPv4 transitional encapsulation. - ipv6addr_
is_ unicast_ global - IPv6 unicast address that is globally routable.
- ipv6addr_
is_ unicast_ link_ local - IPv6 link-local range
fe80::/10(RFC 4291). - ipv6addr_
is_ unicast_ link_ local_ strict - IPv6 strict link-local
fe80::/64— the canonical link-local prefix with all-zero subnet ID. - ipv6addr_
is_ unicast_ site_ local - IPv6 deprecated site-local range
fec0::/10(RFC 3879, deprecated by RFC 4291). - ipv6addr_
is_ unique_ local - IPv6 unique-local range
fc00::/7(RFC 4193) — organisation-internal addresses. - ipv6addr_
is_ unspecified - IPv6 unspecified address
::. - ipv6addr_
multicast_ scope - IPv6 multicast scope (RFC 4291 § 2.7) when the address is multicast;
Noneotherwise. - is_
ipc_ socket_ path - Whether
pathrefers to an existing IPC endpoint: a named pipe on Windows, a unix domain socket elsewhere. Alwaysfalseon unsupported platforms. - is_
ipv4_ supported - Whether IPv4 is usable locally, tested once by binding a loopback UDP socket and cached.
- is_
ipv6_ supported - Whether IPv6 is usable locally, tested once by binding a loopback UDP socket and cached.
- listen_
address_ to_ socket_ addrs - Resolve a listen-address string to socket addresses.
- map_
to_ string - Call
ToString::to_string, for use as a.map()argument. - ms_
to_ us - Convert milliseconds to microseconds.
- new_
default_ socket2_ tcp - Create a non-shared TCP
Socketfordomainwith zero linger andTCP_NODELAYset. - parse_
duration - Parse a duration string with
h/m/ssuffixes into microseconds; returnsNoneon any unexpected character. - prepend_
slash - Prepend a
/unless the string already starts with one. - primary_
source_ ipv4 - Local IPv4 the kernel would pick as the source for outbound traffic.
- primary_
source_ ipv6 - Local IPv6 the kernel would pick as the source for outbound traffic.
- process_
batched_ future_ queue_ result - Returns true if the future queue was processed to completion, false if the stop token was triggered
- process_
batched_ future_ queue_ void - Drive an iterator of futures
batch_sizeat a time, discarding their results. - process_
batched_ future_ stream_ result - Drive a stream of futures
batch_sizeat a time, passing each result toresult_callback. - process_
batched_ future_ stream_ void - Drive a stream of futures
batch_sizeat a time, discarding their results. - random_
bytes - Fill
destwith cryptographically secure random bytes. - retry_
falloff_ log - Decide whether a retry is due, with logarithmic falloff between
interval_start_usandinterval_max_us. - scaled_
yielding - Yielding that chooses the best mechanism using a scaled approach
- secs_
to_ timestamp_ duration - Convert seconds as
f64to a microsecond duration. - set_
tcp_ stream_ linger - Set the
SO_LINGERoption on a TCP stream. - sleep
- Suspend the current task for
millismilliseconds;0yields once without sleeping. - socket2_
operation - Run
callbackagainst thesocket2::Socketbackingswithout taking ownership of it. - spawn
- Spawn a named future on the async runtime, returning a join handle that must be awaited or detached.
- spawn_
detached - Spawn a named future and let it run unattended, with no join handle.
- spawn_
detached_ local - Spawn a named
!Sendfuture on the current thread and let it run unattended, with no join handle. - spawn_
local - Spawn a named
!Sendfuture on the current thread, returning a join handle that must be awaited or detached. - split_
async_ tcp_ stream - Split a
TcpStreaminto owned read and write halves. - split_
port - Split a
host:portstring into host and optional port at the last:. - timeout
- Await
f, failing withTimeoutErrorif it does not complete withindur_msmilliseconds. - timestamp_
duration_ to_ secs - Convert a microsecond duration to seconds as
f64, shedding least-significant bits if the value is too large to represent exactly. - to_
io_ error_ other - Wrap any error in an
io::Errorof kindOther. - total_
memory_ bytes - Total physical memory in bytes, or None if not determinable on this platform.
- try_
at_ most_ n_ things - Apply
closureto items in order until one returnsSome, giving up aftermaxfailures. - type_
name_ of_ val - Type name of a value as a string, without needing to name the type.
- unaligned_
u8_ ⚠vec_ uninit - Safety
- us_
to_ ms - Convert microseconds to milliseconds, erroring if the result overflows
u32. - wait_
until_ debugger_ attached - Block until a debugger attaches, or until the optional timeout elapses.
- yielding
- Run
x, then yield once to the runtime before returning its result.
Type Aliases§
- PinBox
- A heap-pinned box.
- PinBox
Future - A heap-pinned,
Send, boxed trait-object future borrowing for'a. - PinBox
Future Static - A
PinBoxFuturewith a'staticlifetime. - Read
Half - Owned read half of a split
TcpStream. - Tracked
Mutex - Without
debug-locks, a plainparking_lot::Mutex<T>. - Tracked
Mutex Guard - Without
debug-locks, a plainparking_lot::MutexGuard<T>. - Write
Half - Owned write half of a split
TcpStream.