Expand description
vox — type-safe RPC with channels, virtual connections, and automatic schema evolution.
§Defining a service
Services are ordinary Rust traits annotated with #[vox::service]:
#[vox::service]
trait Hello {
async fn say_hello(&self) -> String;
}The macro generates a HelloClient (typed caller), a HelloDispatcher
(request router), and serialization glue. You implement the trait on a
struct and hand it to a dispatcher.
§Connecting
connect() is the fastest path to calling a remote service:
let client: HelloClient = vox::connect("127.0.0.1:9000").await?;
let reply = client.say_hello().await?;The address string selects the transport:
| Scheme | Transport |
|---|---|
tcp://host:port (or bare host:port) | TCP stream |
local://path | Unix socket / Windows named pipe |
ws://host:port/path | WebSocket |
§Serving
serve() accepts connections in a loop:
vox::serve("0.0.0.0:9000", HelloDispatcher::new(HelloService)).await?;For multi-service routing, use acceptor_fn():
ⓘ
vox::serve("0.0.0.0:9000", vox::acceptor_fn(|req, conn| {
match req.service() {
"Hello" => { conn.handle_with(HelloDispatcher::new(HelloService)); Ok(()) }
"Chat" => { conn.handle_with(ChatDispatcher::new(ChatService)); Ok(()) }
_ => Err(vec![]),
}
})).await?;§Generated clients
Generated clients expose public fields for connection lifecycle:
ⓘ
client.caller.closed().await; // wait for disconnect
client.caller.is_connected(); // check liveness
client.session.as_ref(); // access session handle (virtual connections)
client.say_hello().await?; // service method — no name clash§Lower-level APIs
For advanced use (custom transports, in-memory testing, virtual connections), use the builder APIs directly:
initiator_on()/acceptor_on()— establish over a rawLinkmemory_link_pair()— in-process link pair for testingDriver— run inbound RPC on a connection handleSessionHandle— open/close virtual connectionsproxy_connections()— bridge two connection handles
Re-exports§
pub use facet;pub use facet_reflect;pub use vox_postcard;
Modules§
- channel
- hash
- schema_
deser - session
- transport
- Transport implementations re-exported by the facade crate.
Structs§
- Acceptor
Fn - Wrapper that turns a closure into a
ConnectionAcceptor. - Attachment
- One transport attachment consumed by
LinkSource::next_link. - Bare
Conduit - Wraps a
Linkwith postcard serialization. No reconnect, no reliability. - Caller
- Concrete caller type wrapping a
DriverCallerwith optional middleware. - Channel
Id - ID of a channel between two peers.
- Channel
Listener - A
VoxListenerbacked by a channel. - Channel
Listener Sender - Sender half of a
ChannelListener. - Client
Context - Borrowed per-call context exposed to client middleware.
- Client
Logging - Client
Logging Options - Client
Request - Borrowed request wrapper exposed to client middleware.
- Connect
Builder - Connection
Handle - Connection
Id - Connection ID identifying a virtual connection on a link.
- Connection
Request - Metadata wrapper with typed getters for well-known
vox-*keys. - Connection
Settings - Per-connection limits advertised by a peer.
- Connection
State - Static data for one active connection.
- Driver
- Per-connection driver. Tracks in-flight request attempts, dispatches
incoming requests to a
Handler, and manages channel state / flow control. - Driver
Caller - Allocates a request ID, registers a response slot, sends one request attempt through the connection, and awaits the corresponding response.
- Driver
Channel Sink - Concrete
ChannelSinkbacked by aConnectionSender. - Driver
Reply Sink - Concrete
ReplySinkimplementation for the driver. - Extensions
- Per-request type-indexed storage shared across middleware hooks and handlers.
- Handshake
Result - Result of a completed CBOR handshake.
- InMemory
Operation Store - Default in-memory operation store.
- Memory
Link - In-process
Linkbacked by tokio mpsc channels. - Memory
Link Rx - Receiving half of a
MemoryLink. - Memory
Link RxError - MemoryLink never fails on recv — the only “error” is channel closed (returns None).
- Memory
Link Tx - Sending half of a
MemoryLink. - Message
Family - Type-level tag for
Messageas aMsgFamily. - Message
Plan - Pre-built translation plan for deserializing the
Messagewire type. - Metadata
Entry - A single metadata entry with a key, value, and flags.
- Metadata
Flags - Metadata entry flags.
- Method
Descriptor - Static descriptor for a single RPC method.
- Method
Id - A unique method identifier — hash of service name, method name, arg shapes, return shape
- Noop
Client - Liveness-only client for a connection root.
- Peek
- A read-only view into a value with runtime type information.
- Pending
Connection - A connection that has been opened but not yet accepted.
- Request
Call - Request
Context - Borrowed per-request context exposed to opted-in Rust service handlers.
- Request
Response - Response
Parts - A decoded response value paired with response metadata.
- Retry
Policy - Static retry policy for a method.
- Rx
- Receiver handle: “I receive”. The holder of an
Rx<T>receives items of typeT. - Schema
Recv Tracker - Tracks schemas received from the remote peer on the current connection.
- Sealed
Response - A sealed response stored in the operation store.
- SelfRef
- A decoded value
Tthat may borrow from its own backing storage. - Server
Logging - Server
Logging Options - Server
Request - Middleware-facing view of one decoded server request.
- Server
Response - Middleware-facing view of one outbound server response.
- Server
Response Context - Owned context available when observing an outbound server response.
- Service
Descriptor - Static descriptor for a vox RPC service.
- Session
- Session state machine.
- Session
Acceptor Builder - Session
Config - Shared configuration for all session builders.
- Session
Handle - Cloneable handle for opening and closing virtual connections.
- Session
Initiator Builder - Session
Keepalive Config - Session-level protocol keepalive configuration.
- Session
Registry - Session
Source Initiator Builder - Session
Transport Acceptor Builder - Session
Transport Initiator Builder - Single
Attachment Source - A one-shot
LinkSourcebacked by a single attachment. - Sink
Call - Concrete
Callimplementation backed by aReplySink. - Split
Link - Link wrapper that re-combines pre-split Tx/Rx halves into a
Link. - Stable
Conduit - Tx
- Sender handle: “I send”. The holder of a
Tx<T>sends items of typeT. - With
Tracker - Pairs a value with the
SchemaRecvTrackerthat was active when the value was received. Used to thread per-message schema context through the caller API without storing trackers on long-lived structs.
Enums§
- Backing
- Bare
Conduit Error - Channel
Retry Mode - Client
Call Outcome - Handshake
Error - Metadata
Value - Metadata value.
- Operation
State - State of an operation in the store.
- Parity
- Whether a peer will use odd or even IDs for requests and channels on a given connection.
- Payload
- A payload — arguments for a request, or return type for a response.
- RxError
- Error when receiving from an
Rx. - Serve
Error - Error returned by
super::serve(). - Server
Call Outcome - Outcome observed by server middleware after handler dispatch.
- Server
Response Payload - Reflective view of one outbound server response payload.
- Session
Accept Outcome - Session
Error - Errors that can occur during session establishment or operation.
- Session
Role - Whether the session is acting as initiator or acceptor.
- Stable
Conduit Error - Transport
Mode - Requested conduit mode for the transport prologue.
- TxError
- Error when sending on a
Tx. - VoxError
- Protocol-level error wrapper distinguishing application errors from vox infrastructure errors.
Constants§
- OPERATION_
ID_ METADATA_ KEY - RETRY_
SUPPORT_ METADATA_ KEY - RETRY_
SUPPORT_ VERSION - VOX_
SERVICE_ METADATA_ KEY - Well-known metadata key for service name routing.
Traits§
- Call
- Represents an in-progress API-level call as seen by a server handler.
- Client
Middleware - Conduit
- Bidirectional typed transport. Wraps a
Linkand owns serialization. - Conduit
Acceptor - Yields new conduits from inbound connections.
- Conduit
Rx - Conduit
Tx - Sending half of a
Conduit. - Connection
Acceptor - DynConduit
Rx - DynConduit
Tx - Erased
Handler - Object-safe version of
Handler<DriverReplySink>. - From
VoxSession - Trait for constructing a typed client from a vox session.
- Handler
- Type-erased handler for incoming service calls.
- Into
Conduit - Converts a value into a
vox_types::Conduit. - Link
- Bidirectional raw-bytes transport.
- LinkRx
- Receiving half of a
Link. - Link
Source - LinkTx
- Sending half of a
Link. - Maybe
Send - Marker trait that requires
Sendon native targets, nothing on wasm32. - Maybe
Sync - Marker trait that requires
Syncon native targets, nothing on wasm32. - MsgFamily
- Maps a lifetime to a concrete message type.
- Operation
Store - Operation state backing for exactly-once delivery across session resumption.
- Reply
Sink - Sink for sending the terminal response for one request attempt.
- Server
Middleware - Observe inbound server requests before and after dispatch.
- VoxListener
- A listener that accepts incoming connections for
serve_listener().
Functions§
- accept_
transport - acceptor_
conduit - acceptor_
fn - Create a
ConnectionAcceptorfrom a closure. - acceptor_
on - acceptor_
on_ link - Convenience: perform CBOR handshake as acceptor on a raw link, then return a builder with the conduit ready to go.
- acceptor_
transport - channel
- Create a channel pair with shared state.
- connect
- Connect to a remote vox service, returning a typed client.
- ensure_
channel_ retry_ mode - handshake_
as_ acceptor - Perform the CBOR handshake as the acceptor.
- handshake_
as_ initiator - Perform the CBOR handshake as the initiator.
- initiate_
transport - initiator
- initiator_
conduit - initiator_
on - initiator_
on_ link - Convenience: perform CBOR handshake as initiator on a raw link, then return a builder with the conduit ready to go.
- initiator_
transport - memory_
link_ pair - Create a pair of connected
MemoryLinks. - metadata_
get_ str - Look up a string metadata value by key.
- metadata_
get_ u64 - Look up a u64 metadata value by key.
- prepare_
acceptor_ attachment - Prepare an acceptor-side attachment from an inbound link.
- proxy_
connections - Forward all request/channel traffic between two connections.
- recv_
client_ hello - Receive a stable conduit
ClientHellofrom a link. - serve
- Serve a vox service by address string, accepting connections in a loop.
- serve_
listener - Serve a vox service on a pre-bound listener.
- set_
channel_ binder - Set the thread-local channel binder, returning a guard that restores the previous value on drop.
- single_
attachment_ source - Build a one-shot
LinkSourcefrom a prepared attachment. - single_
link_ source - Build a one-shot initiator-side
LinkSourcefrom a raw link. - with_
channel_ binder - Set the thread-local channel binder for the duration of
f.
Type Aliases§
- BoxMiddleware
Future - BoxSession
Future - A pinned, boxed session future. On non-WASM this is
Send + 'static; on WASM it’s'staticonly (noSendrequirement). - Metadata
- A list of metadata entries.
Attribute Macros§
- service
- Marks a trait as a vox RPC service and generates all service code.