Skip to main content

Module client

Module client 

Source
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.resume

Lifecycle: 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.
CursorTable
The member cursor and one cursor per channel (§10).
Gap
A detected gap in a sequenced stream.
ReceivedEvent
A received event: the envelope (sequence, timestamp, actor) and its decoded body.
Response
A final response. Debug hides the body, which may embed a secret (an invitation link).
RetryPolicy
Exponential backoff: initial_ms, then ×factor, capped at cap_ms; give up once give_up_ms have passed since the first send (§7.3: 5 s, ×2, 60 s, 24 h).
Session
A sans-IO client session. See the module documentation.
SessionConfig
Everything a super::Session needs besides the transport.
VerifiedWelcome
A welcome that passed every check. Everything in it comes from verified signed objects or was compared with them.

Enums§

BuildError
An owner or member object (descriptor, delegation, registration, body) could not be built.
ClientError
A command could not be prepared or the session refuses to send it.
ClientEvent
One outcome for the application.
ExpectedHost
The host the client expects to reach. The welcome’s host key must match (§4.5, §8.6).
ProtocolError
Input ignored safely (§5.2, §5.3, §1.1, §9.4).
SessionState
Where the session is in its lifecycle (§6.1, §6.2).
WelcomeError
Why a session.welcome was rejected (§4.3, §4.5, §6.2).

Constants§

ACK_LINGER_MS
How long a due sync.ack waits 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
type of the coalesced event batch envelope (§10.5).

Functions§

decode_response
Decodes a successful response body as the response type of command B.