Expand description
§polyoxide-ws
The WebSocket kit the polyoxide socket clients share. Each block here was carried as a copy by every socket crate (five of them); this crate holds the one copy, and each venue keeps only what is its own.
ensure_crypto_providerinstalls the process-default rustls provider atokio-tungsteniteconnect needs.Backoffis the reconnect delay schedule.Timingholds a supervised connection’s ping, staleness, backoff, connect and rotation timings,timing_setters!gives a builder its setters, andnext_waitis the wait until the first deadline.WsErroris the one socket error, read through itsKind.polyoxide_venue::impl_ws_classification!classifies it in the venue crate that wraps it.SocketTransportis how a connection is dialled, giving aBoxSocketand reporting itsCapabilities;TungsteniteTransportis the native one, andtransport_setters!gives a builder itsruntimeandsocket_transportsetters.connectopens a connection within a timeout,connect_overupgrades a TCP connection a venue opened itself,with_timeoutbounds a venue’s own connect, andretrying_can_fixsays whether a reconnect can help after one failed.Connectionis the bare tier: one connection as aStreamof its frames in aMode, with the server’s close captured, and requests correlated with their answers throughCorrelated.Supervisorruns one supervised connection for a venue’sProtocol: pings on the wall clock, staleness, reconnect with backoff and a replay of the membership, rotation, outage markers, and membership changes through aMembershipHandle, yielding aSupervisedstream.
tungstenite is re-exported, so a venue names Message and
CloseFrame through this crate rather than depending on it.
On wasm32 the kit builds no TLS or TCP stack: its transport is the
browser’s WebSocket, connect_over and the scripted test server are
host-only, and the test-server feature turns on nothing.
Behind the test-server feature, the doc-hidden test_server module holds
the scripted local server and the helpers the offline suites share. It is
for tests, not consumers.
The crate depends on neither polyoxide-core nor polyoxide-venue, and
builds no HTTP or signing stack, so a credential-free feed built on it
stays light (AD-2). It logs under the polyoxide_ws target and never
installs a subscriber.
Re-exports§
pub use tungstenite;
Macros§
- timing_
setters - Generates the timing setters a supervised builder offers, each writing the
builder’s
timingfield, aTiming. - transport_
setters - Generates the transport setters a socket builder offers, each writing a
field of the builder:
runtime(Arc<dyn Runtime>)writesself.runtime, anOption<Arc<dyn polyoxide_rt::Runtime>>, andsocket_transport(Arc<dyn SocketTransport>)writesself.socket_transport, anOption<Arc<dyn SocketTransport>>.
Structs§
- Backoff
- The reconnect delay schedule: doubling from an initial delay to a ceiling, and back to the start after a connection that delivered something.
- Capabilities
- What a
SocketTransportcan do. - Connection
- One open connection, as a
Streamof its frames. - Membership
Handle - Changes the membership of a running
Supervised. - Supervised
- A supervised connection: a
Streamof the protocol’s events, and of the errors it skips past or stops on, that survives drops, stalls and rotations by reconnecting and replaying its membership. - Supervisor
- Starts a supervised connection for a
Protocol. - Timing
- The timings a supervised connection runs on.
- Tungstenite
Transport - The native transport: tokio-tungstenite over TCP, with TLS from rustls.
- WsError
- A WebSocket failure: a transport error, a refused upgrade, a server close, or one of the kit’s own timeouts.
Enums§
- Correlated
- What a frame read while a request awaits its answer is, as the caller’s matcher reads it.
- Decoded
- What one frame decodes to.
- Kind
- What kind of failure a
WsErroris. - Mode
- Which frames a
Connectionyields. - Offline
- What becomes of a membership change made while no connection is up.
- Outage
- Why a connection went down, for
Protocol::disconnected, which owns it, so a protocol’s marker can carry the error. - Queue
- The queue between the task and the consumer.
- Recovery
- What to do after a failure.
Constants§
- DEFAULT_
CONNECT_ TIMEOUT - How long one connection attempt may take unless a venue says otherwise: the TCP connect, the TLS handshake and the WebSocket upgrade together.
- MIN_
BACKOFF - The shortest delay. Zero would never grow, so a dead host would be retried on every timer tick.
- PING_
UNSUPPORTED - The message of the
Kind::Unsupportederror a transport that sends no ping frames (a browser’s) gives for a ping: a caller that refuses a ping before sending it builds its error from this text, so the refusal reads the same as the transport’s own.
Traits§
- Protocol
- A venue’s socket protocol, as the
Supervisordrives it. - Socket
Io - An open connection as the kit reads and writes it: a stream of frames and a sink for them, both failing with tungstenite’s error.
- Socket
Transport - How a WebSocket connection is dialled.
Functions§
- connect
- Open a connection through the target’s default
SocketTransportand runtime, giving up aftertimeout. - connect_
over - Upgrade a TCP connection the caller opened itself: the TLS handshake when
requestis awss://URL, then the WebSocket upgrade. - default_
socket_ transport - The transport a socket uses when none is injected:
TungsteniteTransporton a host target andWebSocketTransportonwasm32. - ensure_
crypto_ provider - Make sure rustls has a default
CryptoProviderbefore a connection opens. - next_
wait - The wait until the first of several deadlines falls due.
- retrying_
can_ fix - Whether reconnecting can help after a connect failed this way.
- with_
timeout - Run a caller’s own connect future, giving up after
timeoutwithKind::ConnectTimeout.
Type Aliases§
- BoxSocket
- An open connection, boxed: what a
SocketTransportreturns andConnectionreads.