Expand description
§The Veilid Framework
This is the core library used to create a Veilid node and operate it as part of an application.
veilid-core contains all of the core logic for Veilid and can be used in mobile applications as well as desktop
and in-browser WebAssembly apps.
§Getting started
The public API is accessed by getting a VeilidAPI object via a call to api_startup, api_startup_json.
From there, a RoutingContext object can get you access to public and private routed operations.
§Cargo features
The default veilid-core configurations are:
default- Usestokioas the async runtime.
If you use --no-default-features, you can switch to other runtimes:
default-async-std- Usesasync-stdas the async runtime.default-wasm- When building for thewasm32architecture, use this to enablewasm-bindgen-futuresas the async runtime.
Re-exports§
pub use async_trait;pub use tracing;pub use tracing_subscriber;pub use veilid_tools as tools;pub use veilid_tools::bytes;
Modules§
- as_
human_ base64 - serde
with-module for byte buffers: base64url-nopad string for human-readable formats, raw bytes otherwise. - as_
human_ opt_ base64 - serde
with-module forOption<Vec<u8>>: base64url-nopad string for human-readable formats, raw bytes otherwise. - as_
human_ opt_ string - serde
with-module forOption<T>that usesDisplay/FromStrfor human-readable formats and native serde otherwise. - as_
human_ string - serde
with-module that uses a value’sDisplay/FromStrfor human-readable formats and its native serde impl otherwise. - public_
key_ try_ untyped_ vld0 - serde
with-module accepting either a typed value or a bareVLD0value. - serialize_
arc - serde
with-module that (de)serializes anArc<T>transparently as its innerT. - serialize_
hash_ map_ as_ pairs - serde
with-module that (de)serializes aHashMap<K, V>as a sequence of(key, value)pairs. - serialize_
range_ set_ blaze - serde
with-module that (de)serializes aRangeSetBlaze<T>as a sequence of inclusive(start, end)pairs. - signature_
try_ untyped_ vld0 - serde
with-module accepting either a typed value or a bareVLD0value.
Macros§
- apibail_
already_ initialized - Return early with a VeilidAPIError::AlreadyInitialized error.
- apibail_
generic - Return early with a VeilidAPIError::Generic error carrying the given message.
- apibail_
internal - Return early with a VeilidAPIError::Internal error carrying the given message.
- apibail_
invalid_ argument - Return early with a VeilidAPIError::InvalidArgument error naming the calling context, the argument, and its rejected value.
- apibail_
invalid_ target - Return early with a VeilidAPIError::InvalidTarget error carrying the given message.
- apibail_
key_ not_ found - Return early with a VeilidAPIError::KeyNotFound error carrying the missing record key.
- apibail_
missing_ argument - Return early with a VeilidAPIError::MissingArgument error naming the calling context and the missing argument.
- apibail_
no_ connection - Return early with a VeilidAPIError::NoConnection error carrying the given message.
- apibail_
not_ initialized - Return early with a VeilidAPIError::NotInitialized error.
- apibail_
parse_ error - Return early with a VeilidAPIError::ParseError error carrying the given message and value.
- apibail_
timeout - Return early with a VeilidAPIError::Timeout error.
- apibail_
transaction_ not_ found - Return early with a VeilidAPIError::TransactionNotFound error carrying the given message.
- apibail_
try_ again - Return early with a VeilidAPIError::TryAgain error carrying the given message.
Structs§
- Aligned
U64 - 8-byte-aligned
u64newtype that serializes as a string for JSON safety. - Allow
Offline - Whether a DHT write may be deferred for later when the node is offline. Defaults to true.
- ApiTracing
Layer - API Tracing layer for ‘tracing’ subscribers
- Async
Crypto System Guard - Async cryptosystem guard to help break up heavy blocking operations
- Atomic
Option Timestamp - Atomic wrapper for optional timestamps used in structs so we can avoid locks for LRU and similar operations
- Atomic
Timestamp - Atomic wrapper for timestamps used in structs so we can avoid locks for LRU and similar operations
- Bare
Decapsulation Key - Fixed-purpose byte array holding the raw bytes of a
$name. - Bare
Encapsulation Key - Fixed-purpose byte array holding the raw bytes of a
$name. - Bare
Hash Digest - Fixed-purpose byte array holding the raw bytes of a
$name. - Bare
KemKey Pair - Untyped KEM encapsulation/decapsulation key pair, carrying no cryptosystem kind.
- Bare
KeyPair - Untyped public/secret key pair, carrying no cryptosystem kind.
- Bare
Member Id - Fixed-purpose byte array holding the raw bytes of a
$name. - Bare
Node Id - Fixed-purpose byte array holding the raw bytes of a
$name. - Bare
Opaque Record Key - Fixed-purpose byte array holding the raw bytes of a
$name. - Bare
Public Key - Fixed-purpose byte array holding the raw bytes of a
$name. - Bare
Record Key - Untyped DHT record key: an opaque record key with an optional record encryption secret.
- Bare
Route Id - Fixed-purpose byte array holding the raw bytes of a
$name. - Bare
Secret Key - Fixed-purpose byte array holding the raw bytes of a
$name. - Bare
Shared Secret - Fixed-purpose byte array holding the raw bytes of a
$name. - Bare
Signature - Fixed-purpose byte array holding the raw bytes of a
$name. - Byte
Count - 8-byte-aligned
u64newtype that serializes as a string for JSON safety. - Crypto
- Crypto factory implementation
- Crypto
Kind - A four-character code
- Crypto
System Guard - Guard to access a particular cryptosystem
- DHTRecord
Descriptor - DHT Record Descriptor
- DHTRecord
Report - DHT Record Report
- DHTSchemaDFLT
- Default DHT Schema (DFLT)
- DHTSchemaSMPL
- Simple DHT Schema (SMPL)
- DHTSchemaSMPL
Member - Simple DHT Schema (SMPL) Member
- DHTTransaction
- DHT Transactions the way you perform multiple simulateous atomic operations over a set of DHT records.
- DHTTransaction
SetValue Options - Options that override defaults for DHTTransaction::set
- Decapsulation
Key - A KEM secret key, opening blobs with
CryptoSystem::hpke_open(DHKEM-X25519 under VLD0, ML-KEM at VLD1). Signing usesSecretKey; under VLD0 this key is derivable from one viaCryptoSystem::decapsulation_key_from_signing_secret. A value tagged with theCryptoKindof the cryptosystem it belongs to. - Decapsulation
KeyGroup - An ordered group of typed values holding at most one entry per
CryptoKind. - Encapsulation
Key - A KEM public key, sealed to with
CryptoSystem::hpke_seal(DHKEM-X25519 under VLD0, ML-KEM at VLD1). Signing and identity usePublicKey; under VLD0 this key is derivable from one viaCryptoSystem::encapsulation_key_from_signing_key. A value tagged with theCryptoKindof the cryptosystem it belongs to. - Encapsulation
KeyGroup - An ordered group of typed values holding at most one entry per
CryptoKind. - FmtStrip
Veilid Fields - A filter for the
fmttracing layer that can be used to remove the Veilid-specific fields from the output Useful for getting the veilid-internal__VEILID_LOG_KEYfields gone from layers other thanApiTracingLayertracingfields can not be removed by tracing filters. They can only enable and disable events and spans. To remove fields requires plugging in at the layer separately, and this struct is intended for that purpose to reduce the noise veilid-core’s logging facilities produce. - Hash
Digest - A value tagged with the
CryptoKindof the cryptosystem it belongs to. - Hash
Digest Group - An ordered group of typed values holding at most one entry per
CryptoKind. - KemKey
Pair - A KEM key pair for HPKE seal/open. Signing key pairs use
KeyPair. A value tagged with theCryptoKindof the cryptosystem it belongs to. - KemKey
Pair Group - An ordered group of typed values holding at most one entry per
CryptoKind. - KeyPair
- A signing key pair. KEM key pairs use
KemKeyPair. A value tagged with theCryptoKindof the cryptosystem it belongs to. - KeyPair
Group - An ordered group of typed values holding at most one entry per
CryptoKind. - Latency
Stats - Measurement of communications latency to this node over all RPC questions
- LogOutput
- A log output to be included in the
log_outputsparameter ofVeilidLog::try_init - Member
Id - A value tagged with the
CryptoKindof the cryptosystem it belongs to. - Member
IdGroup - An ordered group of typed values holding at most one entry per
CryptoKind. - Node
Count - 8-byte-aligned
u64newtype that serializes as a string for JSON safety. - NodeId
- A value tagged with the
CryptoKindof the cryptosystem it belongs to. - Node
IdGroup - An ordered group of typed values holding at most one entry per
CryptoKind. - Nonce
- Fixed-purpose byte array holding the raw bytes of a
$name. - Opaque
Record Key - A value tagged with the
CryptoKindof the cryptosystem it belongs to. - Opaque
Record KeyGroup - An ordered group of typed values holding at most one entry per
CryptoKind. - Operation
Id - 8-byte-aligned
u64newtype that serializes as a string for JSON safety. - Peer
Stats - API-visible statistics for a peer in the routing table
- Peer
Table Data - Describe a recently accessed peer
- Private
Spec - Options for private routes (receiver privacy).
- Protected
Store - Secure key-value storage for user secrets, backed by the platform’s secure keyring when available and falling back to an on-disk insecure keyring when permitted by config.
- Protected
Store Inner - Mutable interior of the
ProtectedStore, holding the open keyring backend. - Public
Key - A signing public key: verification, identity, and node ids (Ed25519 under VLD0, ML-DSA at
VLD1). KEM encryption to a key uses
EncapsulationKey. A value tagged with theCryptoKindof the cryptosystem it belongs to. - Public
KeyGroup - An ordered group of typed values holding at most one entry per
CryptoKind. - Record
Key - A value tagged with the
CryptoKindof the cryptosystem it belongs to. - Record
KeyGroup - An ordered group of typed values holding at most one entry per
CryptoKind. - Route
Blob - An allocated route’s id paired with its encoded blob for import by another node.
- RouteId
- A value tagged with the
CryptoKindof the cryptosystem it belongs to. - Route
IdGroup - An ordered group of typed values holding at most one entry per
CryptoKind. - Routing
Context - Routing contexts are the way you specify the communication preferences for Veilid.
- Safety
Spec - Options for safety routes (sender privacy).
- Secret
Key - A signing secret key (Ed25519 under VLD0, ML-DSA at VLD1). KEM decryption uses
DecapsulationKey. A value tagged with theCryptoKindof the cryptosystem it belongs to. - Secret
KeyGroup - An ordered group of typed values holding at most one entry per
CryptoKind. - SetDHT
Value Options - Options that override defaults for set_dht_value
- Shared
Secret - A value tagged with the
CryptoKindof the cryptosystem it belongs to. - Shared
Secret Group - An ordered group of typed values holding at most one entry per
CryptoKind. - Signature
- A value tagged with the
CryptoKindof the cryptosystem it belongs to. - Signature
Group - An ordered group of typed values holding at most one entry per
CryptoKind. - TableDB
- A handle to an opened encrypted key-value table. Cheap to clone; clones share the same underlying database.
- TableDB
Transaction - A TableDB transaction Atomically commits a group of writes or deletes to the TableDB
- Table
Store - Veilid Table Storage. Database for storing key value pairs persistently and securely across runs.
- Timestamp
- 8-byte-aligned
u64newtype that serializes as a string for JSON safety. - Timestamp
Duration - 8-byte-aligned
u64newtype that serializes as a string for JSON safety. - TransactDHT
Records Options - Options for DHT record transactions
- Transfer
Stats - Measurement of how much data has transferred to or from this node over a time span
- Transfer
Stats Down Up - Transfer statistics in both directions: from a node to us (down) and from us to the node (up).
- Value
Data - A DHT value and its metadata
- Value
SeqNum - Value sequence number
- Value
Subkey Range Set - A set of DHT subkeys stored as inclusive ranges of ValueSubkey
- VeilidAPI
- The primary developer entrypoint into
veilid-corefunctionality. - Veilid
AppCall - Direct question blob passed to hosting application for processing to send an eventual AppReply.
- Veilid
AppMessage - Direct statement blob passed to hosting application for processing.
- Veilid
Capability - A four-character code
- Veilid
Component Guard - Borrow guard holding a shared reference to a registered component for the duration of
'a. - Veilid
Config - Top level of the Veilid configuration tree
- Veilid
Config Block Store - Block store configuration: content-addressed block storage.
- Veilid
Config Capabilities - Capabilities advertised by this node.
- Veilid
ConfigDHT - Configure the Distributed Hash Table (DHT). Defaults should be used here unless you are absolutely sure you know what you’re doing. If you change the count/fanout/timeout parameters, you may render your node inoperable for correct DHT operations.
- Veilid
Config Internal - Internal “footgun” configuration tree, parallel to the main config.
- Veilid
Config InternalDHT - Internal “footgun” DHT configuration. See VeilidConfigInternal. Changing the count/fanout/timeout parameters may render your node inoperable for correct DHT operations.
- Veilid
Config Internal Network - Internal “footgun” network configuration. See VeilidConfigInternal.
- Veilid
Config Internal Protocol - Internal “footgun” per-protocol configuration. See VeilidConfigInternal.
- Veilid
Config InternalRPC - Internal “footgun” RPC configuration. See VeilidConfigInternal.
- Veilid
Config InternalUDP - Internal “footgun” UDP configuration. See VeilidConfigInternal.
- Veilid
Config Network - Network subsystem configuration: connections, routing table, RPC, DHT, transports, and privacy.
- Veilid
Config Privacy - Privacy preferences for routes.
- Veilid
Config Protected Store - Protected store configuration: where secrets such as the device encryption key are kept.
- Veilid
Config Protocol - Configure Network Protocols.
- Veilid
ConfigRPC - Configure RPC.
- Veilid
Config Routing Table - Configure the network routing table.
- Veilid
ConfigTCP - Enable and configure TCP.
- Veilid
ConfigTLS - Configure TLS.
- Veilid
Config Table Store - Table store configuration: the encrypted key-value database backing node state.
- Veilid
ConfigUDP - Enable and configure UDP.
- Veilid
ConfigWS - Enable and configure Web Sockets.
- Veilid
Layer Filter - A
tracinglayer filter that gates events and spans by Veilid log facility, level, and log key. Its configuration can be changed at runtime. - Veilid
Layer Filter Config - How to initialize the list of filtered facilities
- Veilid
Log - A VeilidCore log message with optional backtrace.
- Veilid
LogDirective - Changes to the VeilidLayerFilter enabled facilities
- Veilid
Route Change - Describe a private or safety route change that has happened
- Veilid
Startup Options - The configuration built for each Veilid node during API startup
- Veilid
State - A queriable state of the internals of veilid-core.
- Veilid
State Attachment - Describe the attachment state of the Veilid node
- Veilid
State Config - Describe changes to the Veilid node configuration Currently this is only ever emitted once, however we reserve the right to add the ability to change the configuration or have it changed by the Veilid node itself during runtime.
- Veilid
State Network - Describe the current network state of the Veilid node
- Veilid
Tracing - A simple high-level logging mechanism for Veilid applications
- Veilid
Value Change - Describe when DHT records have subkey values changed
Enums§
- Attachment
State - Attachment abstraction for network ‘signal strength’.
- DHTReport
Scope - DHT Record Report Scope
- DHTSchema
- Enum over all the supported DHT Schemas
- Expiration
State - The state of a timestamp, either live (not expired) or dead (expired)
- LogOutput
Kind - Where a LogOutput sends its formatted log events.
- Safety
Selection - The choice of safety route to include in compiled routes.
- Sequence
Ordering - Ordering of RPC message delivery over a route or for RPC messages sent to a target
- Sequencing
- Preferred ordering of RPC message delivery over a route or for RPC messages sent to a target
- Stability
- Choice of nodes to include in allocated routes
- Target
- Valid destinations for a message sent over a routing context.
- VeilidAPI
Error - Error type returned by all fallible Veilid API operations.
- Veilid
Config Address Type - An IP address family (IP version) the node may use.
- Veilid
Config LogLevel - Logging level threshold (
Offdisables logging). - Veilid
LogKey Filter Mode - Selects which log keys a VeilidLayerFilter accepts.
- Veilid
LogLevel - Log level for VeilidCore.
- Veilid
Update - An update from the veilid-core to the host application describing a change to the internal state of the Veilid node.
Constants§
- CONNECTIVITY_
CAPABILITIES - Capabilities that contribute to network connectivity, used when refreshing the routing table.
- CRYPTO_
KIND_ VLD0 CryptoKindfourcc identifying the VLD0 cryptosystem.- CRYPTO_
KIND_ VLD0_ FOURCC - The VLD0 fourcc as a big-endian
u32. - DISTANCE_
METRIC_ CAPABILITIES - Capabilities that participate in the DHT distance metric, used when finding nodes close to a key.
- LOCAL_
NETWORK_ CAPABILITIES - Capabilities advertised by this node in the LocalNetwork routing domain.
- MAX_
CAPABILITIES - Maximum number of capabilities a node may advertise.
- MAX_
CONNECTIONS_ MAX - Maximum allowed total
network.max_connectionson native platforms. - MAX_
CONNECTIONS_ MIN - Minimum allowed total
network.max_connectionson native platforms. - MAX_
CRYPTO_ KINDS - Number of cryptosystem signatures to keep on structures if many are present beyond the ones we consider valid
- MEMBER_
ID_ LENGTH - Fixed length of MemberId (DHT Schema member id) in bytes
- PUBLIC_
INTERNET_ CAPABILITIES - Capabilities advertised by this node in the PublicInternet routing domain.
- VALID_
CRYPTO_ KINDS - Crypto kinds in order of preference, best cryptosystem is the first one, worst is the last one
- VEILID_
CAPABILITY_ APPMESSAGE - Node accepts application messages and calls.
- VEILID_
CAPABILITY_ DHT - Node participates in the distributed hash table.
- VEILID_
CAPABILITY_ RELAY - Node can act as an inbound relay for nodes that are not directly reachable.
- VEILID_
CAPABILITY_ ROUTE - Node can relay private routes for other nodes.
- VEILID_
CAPABILITY_ SIGNAL - Node can perform reverse-connect signalling to help nodes behind NAT make inbound connections.
- VEILID_
CAPABILITY_ VALIDATE_ DIAL_ INFO - Node can validate another node’s claimed dial info by attempting to reach it.
- VEILID_
LOG_ KEY_ FIELD - The tracing log field used by veilid-core to indicate which instance of the
VeilidAPIis doing the logging. - VLD0_
DECAPSULATION_ KEY_ LENGTH - Length of a KEM decapsulation key in bytes (x25519 secret key)
- VLD0_
ENCAPSULATION_ KEY_ LENGTH - Length of a KEM encapsulation key in bytes (x25519 public key)
- VLD0_
HASH_ DIGEST_ LENGTH - Length of a hash digest in bytes
- VLD0_
HPKE_ ENC_ LENGTH - Length of the
encfield of an HPKE sealed blob in bytes (DHKEM X25519 KEM ciphertext) - VLD0_
NONCE_ LENGTH - Length of a nonce in bytes
- VLD0_
PUBLIC_ KEY_ LENGTH - Length of a crypto key in bytes
- VLD0_
SECRET_ KEY_ LENGTH - Length of a secret key in bytes
- VLD0_
SHARED_ SECRET_ LENGTH - Length of a shared secret in bytes
- VLD0_
SIGNATURE_ LENGTH - Length of a signature in bytes
Statics§
- KNOWN_
PROTECTED_ STORE_ KEYS - Protected store keys that Veilid creates and manages, removed together by
delete_all.
Traits§
- Buffer
- In-place encryption/decryption byte buffers.
- Crypto
System - The set of cryptographic primitives a single cryptosystem provides: key generation, signing and verification, AEAD and unauthenticated encryption, Diffie-Hellman key exchange and shared secret derivation, hashing, password hashing, and random byte generation.
- OkVeilidAPI
Result - Extension methods for turning recoverable VeilidAPIError outcomes into
Ok(None). - Timestamp
Duration Timeout Future Ext - Future extension trait that mirrors
TimestampDuration::timeoutfor ergonomic chaining. Namedtimeout_durationto avoid conflict withfutures_time::FutureExt::timeout. - ToVeilidAPI
Error Argument - Trait for types that can be directly converted into parameters for VeilidAPIError
Functions§
- api_
startup - Initialize a Veilid node, with the configuration object.
- api_
startup_ json - Initialize a Veilid node, with the configuration in JSON format.
- common_
crypto_ kinds - Intersection of crypto kind vectors
- compare_
crypto_ kind - Sort best crypto kinds first Better crypto kinds are ‘less’, ordered toward the front of a list
- default_
veilid_ config - Return the default veilid config as a json object.
- deserialize_
json - Deserializes
Tfrom a JSON string, mapping parse failures toVeilidAPIError::ParseError. - deserialize_
json_ bytes - Deserializes
Tfrom JSON bytes, mapping parse failures toVeilidAPIError::ParseError. - deserialize_
json_ lenient - Lenient JSON deserialization for command-line /
set_configergonomics. - deserialize_
opt_ json - Deserializes
Tfrom an optional JSON string, returning aParseErrorwhen the argument isNone. - deserialize_
opt_ json_ bytes - Deserializes
Tfrom optional JSON bytes, returning aParseErrorwhen the argument isNone. - get_
default_ ssl_ directory - Default directory for TLS certificates and keys, given the program identity and a relative sub-path.
- serialize_
json - Serializes
valto a JSON string, panicking if serialization fails. - serialize_
json_ bytes - Serializes
valto JSON bytes, panicking if serialization fails. - serialize_
json_ pretty - Serializes
valto a pretty-printed JSON string, panicking if serialization fails. - veilid_
features - Return the features that were enabled when veilid-core was built.
- veilid_
version - Return the cargo package version of veilid-core in tuple format.
- veilid_
version_ string - Return the cargo package version of veilid-core in string format.
Type Aliases§
- Sequence
Ordering Set - A set of
SequenceOrderingvalues. - Update
Callback - Callback the application registers to receive
VeilidUpdateevents from a running node. - Value
Subkey - Value subkey
- VeilidAPI
Result - Result type for public Veilid API errors
- Veilid
Layer LogKey Filter - The type of a filtering closure accepted by
VeilidLayerFilter. The filter is passed a log key to filter on and returns true if the log key matches the desired log key of the application. This is an advanced filter for when a basic string comparison against a VeilidLogKey is insufficient, for example defining a logging layer that aggregates the logs of severalVeilidAPIinstances - Veilid
LogKey - A log filtering key that is a combination of the ‘program name’ and ‘namespace’ of the
VeilidAPIinstance This has a static lifetime because it is used in theveilid_log!()macros
Attribute Macros§
- async_
trait - Re-exported from
async-traitcrate