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.

§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::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§

AddressFlags
Some of the flags associated with an address.
AssemblyBuffer
Packet reassembly and fragmentation handler
AsyncPeekStream
AsyncTagLockGuard
AsyncTagLockTable
CloneStream
Compat
A compatibility layer that allows conversion between the tokio::io and futures-io AsyncRead and AsyncWrite traits.
DebugGuard
DeferredStreamProcessor
Background processor for streams Handles streams to completion, passing each item from the stream to a callback
EventBus
Event bus
EventBusSubscription
Eventual
EventualFutureClone
EventualFutureEmpty
EventualFutureNone
EventualResolvedFuture
EventualValue
EventualValueClone
EventualValueCloneFuture
EventualValueFuture
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
InterfaceFlags
Some of the flags associated with an interface.
IpAddrPort
IpcIncoming
IpcListener
IpcStream
MustJoinHandle
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
MutableFuture
NetworkInterface
NetworkInterfaces
NetworkInterfacesInner
Peek
PeekExact
SingleShotEventual
SplitUrl
SplitUrlError
SplitUrlPath
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
StartupLockAlreadyStartedError
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
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.
TimeoutError
UdpSocket
A UDP socket.
VeilidRng

Enums§

IfAddr
Ipv6MulticastScope
NetworkResult
SplitUrlHost
TimeoutOr

Constants§

FRAGMENT_LEN
The hard-coded maximum fragment size used by AssemblyBuffer

Traits§

CmpAssign
EventualCommon
FoldedNetworkResultExt
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.
IoNetworkResultExt
IoTimeoutOrExt
NetworkResultExt
NetworkResultResultExt
RemoveDuplicates
Dedup, but doesn’t require a sorted vec, and keeps the element order
StaticStrTransform
TimeoutOrExt
TimeoutOrResultExt
ToStaticStr
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
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

Type Aliases§

PinBox
PinBoxFuture
PinBoxFutureLifetime
ReadHalf
SendPinBoxFuture
SendPinBoxFutureLifetime
WriteHalf