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§

CHUNK
Most content one BLOB_CHUNK frame carries, in bytes. The sender reads, and the receiver holds, at most this much of a file at a time.
HELLO_TIMEOUT
How long the exchange waits for the peer’s Hello.
IDLE_TIMEOUT
How long the initial exchange goes without progress before it gives up on the peer.
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 control frame payload accepted, in bytes. Bounds the memory one peer can make the other allocate for one message.
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. None at a clean end of stream.
read_framed
Read one tagged frame’s payload. None at a clean end of stream.
run_session
Run a session to completion.
write_blob_chunk
Send the next piece of the content started last. More than CHUNK bytes is Error::FrameTooLarge, and nothing is written.
write_blob_end
Say the content started last is complete.
write_blob_start
Start sending the content hash, len bytes long.
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.