Skip to main content

Crate sapphire_framework_session

Crate sapphire_framework_session 

Source
Expand description

The replication session two sapphire-framework replicas run over a byte stream.

One Replica per side, one bidirectional stream, and a framed exchange of version vectors, path updates and content. This crate is the only place that knows the wire format; it neither knows nor cares what carries the bytes.

Two shapes of session are built on that exchange:

  • run_session — a one-shot catch-up. It returns once both sides are caught up.
  • open_live_session — the same catch-up, then a stream that stays open: each side pushes what it commits and applies what arrives.

See docs/superpowers/specs/2026-09-15-p2p-sync-iroh-design.md §3.7 and §4.2.

Structs§

LiveSession
A session that stays open after the initial exchange.
SessionOutcome
What a session did.

Enums§

Error
Errors raised by a session.
Frame
One frame off the wire.
Message
One control message.

Constants§

HELLO_TIMEOUT
How long the exchange waits for the peer’s Hello.
INLINE_LIMIT
Largest payload carried inline in an Updates page, in bytes. Anything larger is fetched by hash within the same session.
MAX_FRAME_LEN
Longest frame payload accepted, in bytes. Matches the replication core’s DEFAULT_MAX_FILE_SIZE, and bounds the memory one peer can make the other allocate.
SESSION_FORMAT_VERSION
The session format this build speaks. Sent in the first message and checked.

Functions§

open_live_session
Run the initial exchange and then keep the session open.
read_frame
Read one frame’s tag and payload, dispatching on tag with read_tagged.
read_framed
Read one tagged frame’s payload. None at a clean end of stream.
run_session
Run a session to completion.
write_blob
Send content.
write_control
Send a control message.
write_framed
Send one frame: tag, then a four-byte big-endian length, then payload.

Type Aliases§

Result
Result alias for a session.