Expand description
Sans-IO protocol client (specification §5–§10): one Session per connection to one host,
plus signing helpers for community owners (owner) and members (member).
The session never performs I/O and never reads a clock: the caller passes every received
transport text to Session::receive with the current time, drains outbound texts with
Session::poll_transmit, and calls Session::poll_timeouts periodically (at least
every second or so) to drive retries (§7.3), fragment expiry (§5.2) and acks (§10.5).
app ── hello()/send()/send_signal() ──▶ Session ── poll_transmit() ──▶ transport
app ◀── Vec<ClientEvent> ── receive(text, now_ms) ◀── transport
app ── poll_timeouts(now_ms) ──▶ retries, sync.ack, sync.resumeLifecycle: Session::hello → session.welcome verified against the configured host and
community (ClientEvent::Welcome) → commands. After a reconnect the caller calls
Session::hello again; unanswered commands are then resent with the same request_id
and byte-identical body (§6.3, §7.3), and the caller sends Session::resume_request.
Modules§
- member
- Helpers for a member: a fresh community-scoped key (§6.1: never reused), its
registration for
invite.redeem/membership.request(§4.4), invitation links (§8.6), and following the community to a new host (migration.reauth). - owner
- Helpers for a community owner, the holder of the root key (§4, ADR-0005, ADR-0011): the
genesis descriptor and host delegation,
community.create, root rotation and descriptor revisions. The root key never leaves the owner’s device; only signed objects do.
Structs§
- Cursor
- One stream’s position: the highest contiguous sequence applied, and events held aside.
- Cursor
Table - The member cursor and one cursor per channel (§10).
- Gap
- A detected gap in a sequenced stream.
- Received
Event - A received event: the envelope (sequence, timestamp, actor) and its decoded body.
- Response
- A final response.
Debughides the body, which may embed a secret (an invitation link). - Retry
Policy - Exponential backoff:
initial_ms, then ×factor, capped atcap_ms; give up oncegive_up_mshave passed since the first send (§7.3: 5 s, ×2, 60 s, 24 h). - Session
- A sans-IO client session. See the module documentation.
- Session
Config - Everything a
super::Sessionneeds besides the transport. - Verified
Welcome - A welcome that passed every check. Everything in it comes from verified signed objects or was compared with them.
Enums§
- Build
Error - An owner or member object (descriptor, delegation, registration, body) could not be built.
- Client
Error - A command could not be prepared or the session refuses to send it.
- Client
Event - One outcome for the application.
- Expected
Host - The host the client expects to reach. The welcome’s host key must match (§4.5, §8.6).
- Protocol
Error - Input ignored safely (§5.2, §5.3, §1.1, §9.4).
- Session
State - Where the session is in its lifecycle (§6.1, §6.2).
- Welcome
Error - Why a
session.welcomewas rejected (§4.3, §4.5, §6.2).
Constants§
- ACK_
LINGER_ MS - How long a due
sync.ackwaits for a command to go with (§10.5). A SimpleX connection sends one message at a time, so a command sent right after a lone ack would wait a relay round trip behind it; the cadence (8 frames or 30 s) has room for this. - CLIENT_
CAPABILITIES - Capabilities this client offers in
session.hello(§6.2): fragment reassembly. - DEFAULT_
TEXT_ BUDGET - Default per-message text budget in UTF-8 bytes (§5.1). The real value is fixed by the
transport adapter from
simplex_client::limits; this crate never depends on it. - EVENTS_
BATCH_ TYPE typeof the coalesced event batch envelope (§10.5).
Functions§
- decode_
response - Decodes a successful response body as the response type of command
B.