Skip to main content

Module uds_session

Module uds_session 

Source
Expand description

UdsSession — one [web_transport_trait::Session] over a Unix-domain socket.

Epic #131 / moq M1. Same-host processes keep an ipc transport after the ZMQ removal, but re-platformed off ZMQ framing onto the same generic plane that quinn and iroh use: a [web_transport_trait::Session]. Because both the RPC plane (super::rpc_session::SessionRpcTransport / super::rpc_session::serve_rpc_connection) and the streaming plane (moq_net::{Client, Server}) are generic over Session, one UdsSession impl carries both over a single UnixStream — exactly as the QUIC/iroh sessions do.

§Why a multiplexer

web_transport_trait::Session is a stream-multiplexed abstraction (open_bi/open_uni/accept_bi/accept_uni). QUIC and iroh provide that natively; a UnixStream is a single ordered byte-stream. So UdsSession carries a [yamux] multiplexer — flow-controlled, head-of-line-correct concurrent substreams over the one socket. moq-lite needs exactly this: one bidi SETUP control stream plus one uni stream per Group. It never uses datagrams, so those trait methods are stubbed (max_datagram_size() == 0).

§Two wire conventions (UDS has neither ALPN nor a uni/bidi distinction)

  1. Plane byte (PLANE_RPC / PLANE_MOQ) — written once on the raw UnixStream before yamux wraps it. Replaces ALPN: the listener reads it to route the connection to the RPC dispatcher vs moq_net::Server::accept.
  2. Substream tag ([TAG_BIDI] / [TAG_UNI]) — yamux substreams are all bidirectional, so the opener prefixes each new substream with one tag byte and the acceptor reads it to route the substream to accept_bi vs accept_uni. A uni opener simply never reads its half.

§Driver

yamux’s Connection is single-owner and poll-driven (not Clone), but Session: Clone and is called concurrently. So one driver task owns the Connection and services open_*/inbound-stream work over channels; cloned UdsSession handles all talk to it. This mirrors libp2p-yamux.

Structs§

UdsError
Error type for UdsSession and its streams.
UdsRecvStream
Inbound half of a UDS substream. Wraps the yamux read half.
UdsSendStream
Outbound half of a UDS substream. Wraps the yamux write half; finish half-closes (sends FIN) so the peer’s read sees EOF.
UdsSession
A [web_transport_trait::Session] over a Unix-domain socket, multiplexed by yamux. Clone-cheap (shares one driver via Arc). Carries both the RPC and moq planes — see the module docs.

Constants§

PLANE_MOQ
See PLANE_RPC. Routes the connection to moq_net::Server::accept.
PLANE_RPC
Connection-plane selector written as the first byte on the raw socket. The RPC dispatcher and the moq server are distinct planes (as ALPN distinguishes them on QUIC); one UnixStream serves exactly one.

Functions§

accept_uds
Accept side: read the plane byte from a freshly-accepted UnixStream, then wrap it in a server-mode yamux session. The caller routes by plane (PLANE_RPC → RPC dispatcher, PLANE_MOQ → moq_net::Server::accept).
connect_uds
Connect to a UDS endpoint, select plane, and return a multiplexed session.