Skip to main content

Crate node_device_session

Crate node_device_session 

Source
Expand description

Shared device-session server (C-5): transport-neutral /econ-v1/device-session/1.

Carriers implement SessionStreams + HostBus and call serve or serve_with_registry. Pass WebRtcSignaling when the carrier can answer webrtc.signal/1; otherwise that method is refused with unsupported_transport.

The shared WebRTC answerer lives in webrtc: wire a webrtc::WebRtcAnswerer with a carrier-specific webrtc::WebRtcCarrier (STUN, portmap, clock, session bind). Iroh/p2p-only pieces (QUIC ProtocolHandler, gossip STUN discovery adapters) stay in the carrier apps. Live-session revalidation is shared here via SessionRegistry.

Re-exports§

pub use webrtc::ByteBudget;
pub use webrtc::MapRefusal;
pub use webrtc::MappedSessionPort;
pub use webrtc::NoSessionPortMapper;
pub use webrtc::NullWebRtcCarrier;
pub use webrtc::SessionPortMapper;
pub use webrtc::StaticWebRtcCarrier;
pub use webrtc::WebRtcAnswerer;
pub use webrtc::WebRtcCarrier;
pub use webrtc::WebRtcHandle;
pub use webrtc::SESSION_BYTES;

Modules§

caps
Capability names the host bus is expected to map.
webrtc
Transport-independent WebRTC answerer for webrtc.signal/1.

Structs§

IngressSocket
Host-owned Unix socket that alone may attest device-session provenance.
OpenOk
Proven session identity after a successful session.open/1.
Refusal
A host refusal the device is allowed to see (code + public detail).
RevalidateReport
Result of one SessionRegistry::revalidate pass.
ServeOptions
Optional knobs for serve_with_options.
Session
Verified (or renewed) session identity returned by the host bus.
SessionRegistry
Registry of live full-mode device sessions for periodic revalidation.
WireSocket
Node wire socket that wire/1 streams splice onto (ADR-310).

Enums§

FrameError
Errors from encoding/decoding a request frame.
OpenMode
Session mode after a successful open.
ResponseError
Errors from decoding a response frame.
SessionEnd
Why crate::serve returned.
SessionPath
How the session reached the node (stamped on the ingress).

Constants§

ALPN
ALPN for /econ-v1/device-session/1.
DEFAULT_WIRE_SOCKET
Default path of the node’s trusted wire socket (ADR-310).
DEVICE_CALL_METHOD
A device calls a node service.
HTTP_REQUEST_METHOD
One HTTP request on an authenticated session stream.
MAX_FRAME_BYTES
Maximum size of a single wire frame.
MAX_PREAMBLE
Node-side cap on the preamble line, newline included (ADR-310 Amendment 1).
PATH_HEADER
Path header stamped on every attested upstream request.
RESPONSE_STATUS_ERR
Response status: error.
RESPONSE_STATUS_OK
Response status: success.
REVOKED_CLOSE_CODE
Application close code when revalidation (or explicit revoke) tears a session down.
SESSION_HEADER
Provenance header stamped on every attested upstream request.
SESSION_OPEN_METHOD
First stream: {credential} or {mode:renewal}.
SESSION_RENEW_METHOD
One-shot first stream: {} → a new credential, then connection close.
SUPERSEDED_CLOSE_CODE
Application close code when a newer session supersedes an older one.
WEBRTC_SIGNAL_METHOD
WebRTC signaling on an authenticated session stream.
WIRE_METHOD
Node-wire splice on an authenticated session stream / DataChannel.
WS_STREAM_METHOD
A live WebSocket bridge on an authenticated session stream.

Traits§

HostBus
The app’s bus to the host for device-session capabilities.
SessionStreams
One authenticated peer connection (handshake already proved Self::peer_key).
WebRtcSignaling
Carrier-owned WebRTC signaling for webrtc.signal/1.

Functions§

decode_request
Decode a request frame, borrowing the payload.
decode_response
Decode a response frame.
encode_http_tunnel_request
Encode an http.request/1 body for tests and carriers.
encode_request
Encode [u16 BE method_len][method][payload].
encode_response
Encode [u8 status][body].
is_definitive_refusal_code
Exact-match check: only these codes close a live session.
peek_method
Read only the method prefix; payload stays unread.
preamble_line
The one-line preamble the node trusts on the wire socket.
serve
Serve one authenticated peer connection until it ends.
serve_with_options
Like serve, with optional registry and wire socket via ServeOptions.
serve_with_registry
Like serve, but registers a successful full-mode open in registry (for once-a-minute revalidation) and removes it when this call returns.
splice_to_wire_socket
Connect to wire_socket, write the preamble, splice recv/send both ways.
verify_refusal_code
Pull a known verify refusal code out of a host error string, if (and only if) it is one of the six codes the host’s refusal shape carries.
wire_socket_path
Resolve the wire socket path: NODE_WIRE_SOCKET when set, else the default.

Type Aliases§

BoxRecv
Boxed read half of one bidirectional stream.
BoxSend
Boxed write half of one bidirectional stream.
SessionClose
Closes the underlying crate::SessionStreams connection.