Skip to main content

Crate veilid_tools

Crate veilid_tools 

Source
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 - Uses tokio as the async runtime

If you use --no-default-features, you can switch to other runtimes:

  • rt-async-std - Uses async-std as the async runtime
  • rt-wasm-bindgen - When building for the wasm32 architecture, use this to enable wasm-bindgen-futures as 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::Write adapter that appends into a BytesMut buffer.
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 Eventual family.
eventual_value
Eventual carrying a single by-value payload to one waiter.
eventual_value_clone
Eventual carrying 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/expect variants that log through tracing or log on failure. Fork of tracing-unwrap crate, 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::Mutex wrapper that records the holder for debugging. TrackedMutex<T>: a drop-in parking_lot::Mutex<T> wrapper that, under the debug-locks feature, records the owning thread plus an acquisition backtrace and reports the holder when an acquisition cannot complete — covering the case the async parking_lot deadlock 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 the Ok value otherwise.
bail_io_error_other
Return early with an io::Error of kind Other built from anything ToString.
debug_target_enabled
True if DEBUG-level logging is enabled for the given target.
io_error_other
Build an io::Error of kind Other from anything ToString.
network_result_raise
Returns early from the enclosing Result<NetworkResult<_>, _>-returning function, re-raising a non-value NetworkResult under a new value type. Panics on Value.
network_result_try
Unwraps the Value of a NetworkResult, or returns the non-value variant early from the enclosing Result<NetworkResult<_>, _>-returning function. The => $f form runs $f before returning, for cleanup on the early-exit path.
pin_dyn_future
Pin a future to the heap, returning a PinBoxFuture trait object.
pin_dyn_future_closure
Pin a future to the heap inside a closure, returning a PinBoxFuture trait 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 TimeoutOr value or short-circuit a timeout out of the enclosing function.

Structs§

AddressFlags
Some of the flags associated with an address
AlternateDisplayFormat
Formats values with fmt::Display using {:#} (alternate form always on).
AssemblyBuffer
Packet reassembly and fragmentation handler
AsyncKeyedCache
A bounded keyed cache where each key has its own async lock.
AsyncKeyedCacheEntry
A locked handle to one key’s slot in an AsyncKeyedCache.
AsyncMutex
An async mutex giving one holder at a time exclusive access to T.
AsyncMutexGuard
Borrowed guard holding the mutex; derefs to T (mutably) and unlocks on drop.
AsyncMutexGuardArc
Owned guard holding the mutex; derefs to T (mutably) and unlocks on drop.
AsyncPeekStream
An AsyncRead + AsyncWrite stream wrapper that allows peeking at incoming bytes without consuming them.
AsyncRwLock
An async reader-writer lock allowing many concurrent readers or one writer.
AsyncRwLockReadGuard
Borrowed guard for shared read access; derefs to T and releases on drop.
AsyncRwLockReadGuardArc
Owned guard for shared read access; derefs to T and releases on drop.
AsyncRwLockWriteGuard
Borrowed guard for exclusive write access; derefs to T (mutably) and releases on drop.
AsyncRwLockWriteGuardArc
Owned guard for exclusive write access; derefs to T (mutably) and releases on drop.
AsyncSemaphore
An async counting semaphore bounding the number of concurrent permit holders.
AsyncSemaphoreGuard
A borrowed guard that releases its permit on drop.
AsyncSemaphoreGuardArc
An owned guard that releases the acquired permit.
AsyncTagLockGuard
A guard holding the lock for one tag; releases it on drop.
AsyncTagLockTable
A table of per-tag async locks, sharable across tasks.
AsyncWeightedSemaphore
A semaphore admitting weighted permits under a runtime-adjustable capacity limit.
AsyncWeightedSemaphoreGuard
A guard holding weight units; releases them back to the semaphore on drop.
BytesWriter
A std::io::Write adapter over a BytesMut buffer.
CloneStream
A cloneable wrapper that shares one stream behind an Arc<Mutex<_>>.
Compat
A compatibility layer that allows conversion between the tokio::io and futures-io AsyncRead and AsyncWrite traits.
DebugGuard
Scope guard that prints to stderr and bumps a shared counter on entry, then decrements and prints on drop.
DefaultDisplayFormat
Formats values with fmt::Display using {} only (ignores alternate form).
DeferredStreamProcessor
Background processor for streams Handles streams to completion, passing each item from the stream to a callback
EventBus
Event bus
EventBusSubscription
Handle to a registered event handler, passed to unsubscribe to remove it.
Eventual
A valueless one-shot signal. Many instance futures attach and all complete when resolve is called once. Each instance future may carry its own output value, supplied at attach time rather than at resolution.
EventualFutureClone
Instance future from Eventual::instance_clone; resolves to a clone of its attached value.
EventualFutureEmpty
Instance future from Eventual::instance_empty; resolves to ().
EventualFutureNone
Instance future from Eventual::instance_none; resolves to None.
EventualResolvedFuture
Future returned by resolve; completes once every instance future of the resolved Eventual has been polled and dropped.
EventualValue
A one-shot signal carrying a single owned value. Instance futures complete when resolve is called; exactly one consumer may take_value the resolved value out.
EventualValueClone
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.
EventualValueCloneFuture
Instance future from EventualValueClone::instance; resolves to a clone of the resolved value.
EventualValueFuture
Instance future from EventualValue::instance; resolves to a clone of the owning EventualValue so the value can be taken from it.
FlapDetector
Flapping detector: decaying-penalty counter (BGP-damping style) over an observed value. record counts a transition whenever the value differs from the last observed one; the penalty decays with half_life_us and crossing threshold means flapping. Timestamps are raw microseconds (veilid-tools has no Timestamp type).
FutureRaceCompletionPool
Pool that runs handed-off futures to completion. Cheap to clone.
Ifv4Addr
Details about the ipv4 address of an interface on this host.
Ifv6Addr
Details about the ipv6 address of an interface on this host.
InterfaceAddress
An address bound to an interface, with its flags. Ordered by reachability preference.
InterfaceFlags
Some of the flags associated with an interface
IpAddrPort
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.
MustJoinHandle
Wrapper around a task join handle that panics if dropped before the task is joined, detached, or aborted.
MustJoinSingleFuture
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
NetworkInterface
A single network interface on this host, with its flags, gateways, and addresses.
NetworkInterfaceAddressState
The best routable gateway and interface addresses distilled from all interfaces.
NetworkInterfaces
Cross-platform enumeration of this host’s network interfaces and their addresses.
NetworkInterfacesInner
Mutex-guarded interior state of NetworkInterfaces.
Peek
Future returned by AsyncPeekStream::peek.
PeekExact
Future returned by AsyncPeekStream::peek_exact.
RawAddressSummary
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.
SingleShotEventual
An EventualValue that resolves exactly once. resolve consumes it; if it is dropped without resolving, it resolves to the drop_value given at construction (if any), so awaiters never hang.
SplitUrl
A URL split into its components, parsed from scheme://[userinfo@]host[:port][/path].
SplitUrlError
Error returned when parsing a URL component fails.
SplitUrlPath
The portion of a URL after the host and port: path, optional fragment, optional query.
StartupLock
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.
StartupLockAlreadyShutDownError
Returned by shutdown when the lock is already in the shut down state.
StartupLockAlreadyStartedError
Returned by startup when the lock is already in the started state.
StartupLockEnterGuard
RAII-style lock for entry operations on a started-up region of code.
StartupLockEnterGuardArc
RAII-style lock for entry operations on a started-up region of code.
StartupLockGuard
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
StartupLockNotStartedError
Returned by enter when the lock is not in the started state.
StopSource
Cancellation source; dropping it stops every associated StopToken.
StopToken
Future that resolves when its StopSource is dropped.
TagLockGuard
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.
TagLockTable
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.
TickTask
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.
TimedOutError
Error returned by future::FutureExt::timeout_at when the deadline fires first.
TimeoutError
An operation did not complete before its deadline.
UdpSocket
A UDP socket.
VeilidRng
Cryptographically secure RNG that draws from the thread-local random source.

Enums§

DebuggerState
Debugger attachment state of the current process.
DeferredStreamResult
Result of a per-item handler, controlling whether stream processing continues.
FutureRaceCompletion
Outcome of race_complete_on
IfAddr
An interface address that is either IPv4 or IPv6, with its netmask and broadcast address.
Ipv6MulticastScope
Scope of an IPv6 multicast address (RFC 4291 § 2.7), in increasing reach.
NetworkResult
Outcome of a network operation that separates a real Value from benign network conditions which should not be treated as hard errors.
ResolverError
Error returned by DNS resolution operations.
SplitUrlHost
The host field of a URL: either a DNS hostname or an IP address.
TimeoutOr
The outcome of an operation that may either time out or produce a value.

Constants§

DEBUG_LOCKS_DURATION_MS
Timeout under the debug-locks feature after which a pending acquisition is reported as a deadlock.
DEFAULT_INDENT_SPACES
Spaces prepended by indent_string and indent_all_string
FRAGMENT_LEN
The hard-coded maximum fragment size used by AssemblyBuffer

Traits§

CmpAssign
In-place min/max assignment for ordered types.
EventualCommon
Operations available on every Eventual variant. Blanket-implemented for all EventualBase types.
FoldedNetworkResultExt
Folds a timeout-or-io outcome into a single NetworkResult.
FormatterToString
Format fmt::Display values to String, respecting a formatter-style alternate flag.
FutureRaceCompletionPoolExt
Trait that adds race_complete_on to any future
FuturesAsyncReadCompatExt
Extension trait that allows converting a type implementing futures_io::AsyncRead to implement tokio::io::AsyncRead.
FuturesAsyncWriteCompatExt
Extension trait that allows converting a type implementing futures_io::AsyncWrite to implement tokio::io::AsyncWrite.
HasDuplicates
Check for duplicates but doesn’t require a sorted vec
IoNetworkResultExt
Folds an io::Result into a NetworkResult, routing benign socket errors to the matching network condition.
IoTimeoutOrExt
Split a timed-out io::Result off into a TimeoutOr.
NetworkResultExt
Folds a TimeoutError outcome into a NetworkResult.
NetworkResultResultExt
Swaps the nesting of a NetworkResult wrapping a Result.
OptionExt
Extension trait for Option types.
RemoveDuplicates
Dedup, but doesn’t require a sorted vec, and keeps the element order
ResultExt
Extension trait for Result types.
StaticStrTransform
Cache the result of transforming a &'static str, keyed by its pointer and length.
StringIfEmpty
Substitute a placeholder for an empty string.
StripTrailingNewline
Strip a trailing \n or \r\n from a string-like value.
TimeoutOrExt
Convert a Result<T, TimeoutError> into a TimeoutOr<T>.
TimeoutOrResultExt
Hoist the error out of a TimeoutOr<Result<T, E>>.
ToMultilineString
Generate multiline human-readable output
ToStaticStr
Intern a string into a process-global table, returning a &'static str for it.
ToTableString
Trait for printing values in a human-readable table format
TokioAsyncReadCompatExt
Extension trait that allows converting a type implementing tokio::io::AsyncRead to implement futures_io::AsyncRead.
TokioAsyncWriteCompatExt
Extension trait that allows converting a type implementing tokio::io::AsyncWrite to implement futures_io::AsyncWrite.

Functions§

aligned_8_u8_vec_uninit
Safety
async_tcp_listener_incoming
Wrap a TcpListener as a stream of accepted TcpStream connections.
async_try_at_most_n_things
Await closure on items in order until one returns Some, giving up after max failures.
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_address with SO_REUSEADDR/SO_REUSEPORT set.
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 to local_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) for address.
ensure_directory_private_owner
Ensure path, if it exists as a directory, is mode 0o700 (or 0o750 when group_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_len bytes with a trailing ... when set.
human_duration
Format a microsecond duration as a human-readable string, e.g. 1d2h3m4.005s or 1.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 callback every freq_ms milliseconds.
ip_to_ipblock
Collapses an address to its allocation block by masking the host bits.
ipaddr_apply_netmask
Applies netmask to addr, zeroing the host bits. Returns None if the address and netmask are different IP families.
ipaddr_in_network
True if addr falls within the network netaddr/netmask. False if addr and netaddr are 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/8 or ::1).
ipaddr_is_multicast
Address is in a multicast range (IPv4 224.0.0.0/4 or IPv6 ff00::/8).
ipaddr_is_unspecified
Address has the all-zeros bit pattern (IPv4 0.0.0.0 or 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; None otherwise.
is_ipc_socket_path
Whether path refers to an existing IPC endpoint: a named pipe on Windows, a unix domain socket elsewhere. Always false on 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 Socket for domain with zero linger and TCP_NODELAY set.
parse_duration
Parse a duration string with h/m/s suffixes into microseconds; returns None on 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_size at a time, discarding their results.
process_batched_future_stream_result
Drive a stream of futures batch_size at a time, passing each result to result_callback.
process_batched_future_stream_void
Drive a stream of futures batch_size at a time, discarding their results.
random_bytes
Fill dest with cryptographically secure random bytes.
retry_falloff_log
Decide whether a retry is due, with logarithmic falloff between interval_start_us and interval_max_us.
scaled_yielding
Yielding that chooses the best mechanism using a scaled approach
secs_to_timestamp_duration
Convert seconds as f64 to a microsecond duration.
set_tcp_stream_linger
Set the SO_LINGER option on a TCP stream.
sleep
Suspend the current task for millis milliseconds; 0 yields once without sleeping.
socket2_operation
Run callback against the socket2::Socket backing s without 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 !Send future on the current thread and let it run unattended, with no join handle.
spawn_local
Spawn a named !Send future on the current thread, returning a join handle that must be awaited or detached.
split_async_tcp_stream
Split a TcpStream into owned read and write halves.
split_port
Split a host:port string into host and optional port at the last :.
timeout
Await f, failing with TimeoutError if it does not complete within dur_ms milliseconds.
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::Error of kind Other.
total_memory_bytes
Total physical memory in bytes, or None if not determinable on this platform.
try_at_most_n_things
Apply closure to items in order until one returns Some, giving up after max failures.
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.
PinBoxFuture
A heap-pinned, Send, boxed trait-object future borrowing for 'a.
PinBoxFutureStatic
A PinBoxFuture with a 'static lifetime.
ReadHalf
Owned read half of a split TcpStream.
TrackedMutex
Without debug-locks, a plain parking_lot::Mutex<T>.
TrackedMutexGuard
Without debug-locks, a plain parking_lot::MutexGuard<T>.
WriteHalf
Owned write half of a split TcpStream.