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.
§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::Weak;pub use std::task;pub use std::time::Duration;pub use std::vec::Vec;pub use async_lock::RwLock as AsyncRwLock;pub use async_lock::RwLockReadGuard as AsyncRwLockReadGuard;pub use async_lock::RwLockReadGuardArc as AsyncRwLockReadGuardArc;pub use async_lock::RwLockWriteGuard as AsyncRwLockWriteGuard;pub use async_lock::RwLockWriteGuardArc as AsyncRwLockWriteGuardArc;pub use tokio::sync::Mutex as AsyncMutex;pub use tokio::sync::MutexGuard as AsyncMutexGuard;pub use tokio::sync::OwnedMutexGuard as AsyncMutexGuardArc;pub use tokio::task::JoinHandle as LowLevelJoinHandle;pub use fn_name;
Modules§
- assembly_
buffer - Packet reassembly and fragmentation handler
- async_
peek_ stream - async_
tag_ lock - clone_
stream - deferred_
stream_ processor - event_
bus - Event Bus
- eventual
- eventual_
base - eventual_
value - eventual_
value_ clone - future_
queue - interval
- ip_
addr_ port - ip_
extra - ipc
- must_
join_ handle - must_
join_ single_ future - mutable_
future - network_
interfaces - network_
result - random
- single_
shot_ eventual - sleep
- socket_
tools - spawn
- split_
url - startup_
lock - static_
string_ table - tests
- tick_
task - timeout
- timeout_
or - timestamp
- tools
Macros§
- assert_
err - asyncmutex_
lock_ arc - asyncmutex_
try_ lock - asyncmutex_
try_ lock_ arc - asyncrwlock_
try_ read - asyncrwlock_
try_ read_ arc - asyncrwlock_
try_ write - asyncrwlock_
try_ write_ arc - bail_
io_ error_ other - debug_
target_ enabled - io_
error_ other - network_
result_ raise - network_
result_ try - network_
result_ value_ or_ log - timeout_
or_ try
Structs§
- Address
Flags - Some of the flags associated with an address.
- Assembly
Buffer - Packet reassembly and fragmentation handler
- Async
Peek Stream - Async
TagLock Guard - Async
TagLock Table - Clone
Stream - Compat
- A compatibility layer that allows conversion between the
tokio::ioandfutures-ioAsyncReadandAsyncWritetraits. - Debug
Guard - 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 - Eventual
- Eventual
Future Clone - Eventual
Future Empty - Eventual
Future None - Eventual
Resolved Future - Eventual
Value - Eventual
Value Clone - Eventual
Value Clone Future - Eventual
Value Future - 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 - Interface
Flags - Some of the flags associated with an interface.
- IpAddr
Port - IpcIncoming
- IpcListener
- IpcStream
- Must
Join Handle - 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
- Mutable
Future - Network
Interface - Network
Interfaces - Network
Interfaces Inner - Peek
- Peek
Exact - Single
Shot Eventual - Split
Url - Split
UrlError - Split
UrlPath - 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 - Startup
Lock Already Started Error - 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 - 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.
- Timeout
Error - UdpSocket
- A UDP socket.
- Veilid
Rng
Enums§
Constants§
- FRAGMENT_
LEN - The hard-coded maximum fragment size used by AssemblyBuffer
Traits§
- CmpAssign
- Eventual
Common - Folded
Network Result Ext - 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. - IoNetwork
Result Ext - IoTimeout
OrExt - Network
Result Ext - Network
Result Result Ext - Remove
Duplicates - Dedup, but doesn’t require a sorted vec, and keeps the element order
- Static
StrTransform - Timeout
OrExt - Timeout
OrResult Ext - ToStatic
Str - 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 - async_
try_ at_ most_ n_ things - available_
unspecified_ addresses - bind_
async_ tcp_ listener - bind_
async_ udp_ socket - blocking_
wrapper - compatible_
unspecified_ socket_ addr - connect_
async_ tcp_ stream - debug_
backtrace - debug_
duration - debug_
print_ backtrace - display_
duration - display_
ts - domain_
for_ address - ensure_
directory_ private_ owner - ensure_
file_ private_ owner - get_
concurrency - get_
random_ u32 - get_
random_ u64 - get_
timestamp - interval
- ip_
to_ ipblock - ipaddr_
apply_ netmask - ipaddr_
in_ network - ipaddr_
is_ documentation - ipaddr_
is_ global - ipaddr_
is_ loopback - ipaddr_
is_ multicast - ipaddr_
is_ unspecified - ipv4addr_
is_ benchmarking - ipv4addr_
is_ broadcast - ipv4addr_
is_ documentation - ipv4addr_
is_ global - ipv4addr_
is_ ietf_ protocol_ assignment - ipv4addr_
is_ link_ local - ipv4addr_
is_ loopback - ipv4addr_
is_ multicast - ipv4addr_
is_ private - ipv4addr_
is_ reserved - ipv4addr_
is_ shared - ipv4addr_
is_ unspecified - ipv6addr_
is_ documentation - ipv6addr_
is_ global - ipv6addr_
is_ loopback - ipv6addr_
is_ multicast - ipv6addr_
is_ unicast_ global - ipv6addr_
is_ unicast_ link_ local - ipv6addr_
is_ unicast_ link_ local_ strict - ipv6addr_
is_ unicast_ site_ local - ipv6addr_
is_ unique_ local - ipv6addr_
is_ unspecified - ipv6addr_
multicast_ scope - is_
debug_ backtrace_ enabled - is_
ipc_ socket_ path - is_
ipv6_ supported - listen_
address_ to_ socket_ addrs - main_rs
- map_
to_ string - ms_
to_ us - new_
default_ socket2_ tcp - parse_
duration - prepend_
slash - process_
batched_ future_ queue - random_
bytes - retry_
falloff_ log - secs_
to_ timestamp - set_
tcp_ stream_ linger - sleep
- socket2_
operation - spawn
- spawn_
detached - spawn_
detached_ local - spawn_
local - split_
async_ tcp_ stream - split_
port - system_
boxed - timeout
- timestamp_
to_ secs - to_
io_ error_ other - try_
at_ most_ n_ things - type_
name_ of_ val - unaligned_
u8_ ⚠vec_ uninit - Safety
- us_
to_ ms