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 fn_name;

Modules§

assembly_buffer
Packet reassembly and fragmentation handler
async_locks
Debuggable Async Locks
async_peek_stream
clone_stream
deferred_stream_processor
event_bus
Event Bus
eventual
eventual_base
eventual_value
eventual_value_clone
future_queue
hash_atom
interval
ip_addr_port
ip_extra
ipc
log_unwrap
Fork of tracing-unwrap crate, modified to also allow non-tracing loggers to function
must_join_handle
must_join_single_future
mutable_future
network_interfaces
network_result
pin
random
raw_timestamp
resolver
single_shot_eventual
sleep
socket_tools
spawn
split_url
startup_lock
static_string_table
tick_task
timeout
timeout_or
tools
trim_backtrace

Macros§

assert_err
bail_io_error_other
debug_target_enabled
io_error_other
network_result_raise
network_result_try
pin_dyn_future
pin_dyn_future_closure
pin_future
pin_future_closure
timeout_or_try

Structs§

AddressFlags
Some of the flags associated with an address.
AssemblyBuffer
Packet reassembly and fragmentation handler
AsyncMutex
AsyncMutexGuard
AsyncMutexGuardArc
AsyncPeekStream
AsyncRwLock
AsyncRwLockReadGuard
AsyncRwLockReadGuardArc
AsyncRwLockWriteGuard
AsyncRwLockWriteGuardArc
AsyncSemaphore
AsyncSemaphoreGuard
AsyncSemaphoreGuardArc
An owned guard that releases the acquired permit.
AsyncTagLockGuard
AsyncTagLockTable
AsyncTaskId
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
HashAtom
Pointer-identity hashing for unique objects Considers the === identity equals rather than the == Eq/PartialEq equals for objects that are guaranteed to be fixed in memory
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
NetworkInterfaceAddressState
NetworkInterfaces
NetworkInterfacesInner
Peek
PeekExact
Resolver
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
TrimmedBacktrace
UdpSocket
A UDP socket.
VeilidRng

Enums§

DeferredStreamResult
IfAddr
Ipv6MulticastScope
NetworkResult
ResolverError
SplitUrlHost
TimeoutOr

Constants§

DEBUG_LOCKS_DURATION_MS
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.
HasDuplicates
Check for duplicates but doesn’t require a sorted vec
IoNetworkResultExt
IoTimeoutOrExt
NetworkResultExt
NetworkResultResultExt
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
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.
TrimBacktraceTrait

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
display_duration
display_ts
domain_for_address
ensure_directory_private_owner
ensure_file_private_owner
get_concurrency
get_random_u32
get_random_u64
get_raw_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_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_result
process_batched_future_queue_void
process_batched_future_stream_result
process_batched_future_stream_void
random_bytes
retry_falloff_log
secs_to_timestamp_duration
set_tcp_stream_linger
sleep
socket2_operation
spawn
spawn_detached
spawn_detached_local
spawn_local
split_async_tcp_stream
split_port
timeout
timestamp_duration_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
PinBoxFutureStatic
ReadHalf
WriteHalf