Skip to main content

Module local

Module local 

Source
Expand description

Local protocol — daemon ↔ same-host CLI (and atticd).

Hot path. Sub-millisecond budget for warm-cache lookups. rkyv 0.8 over a length-prefixed multiplex frame, transported via tokio::net::UnixStream. The transport itself lives in the future sui-daemon crate; this module ships the typed wire shapes those transport layers will consume.

§Wire shape

Every byte on the wire belongs to a WireFrame. The framing is:

[magic : 4B = "SUI1"] [length : 4B u32 LE] [body : N bytes of rkyv-archived WireFrame]

The magic + length prefix is what lets a misaligned reader fail fast (the rkyv access itself validates the body, so a corrupted body never gets cast to a typed reference). Length includes only the body — not the 8 prefix bytes. Max body length is bounded by daemon configuration; defaults to 64 MiB to comfortably hold a batched closure-info request without runaway.

§Request / response model

Bidirectional multiplexed: each frame carries a RequestId (u64) so multiple in-flight requests share one stream without head-of-line blocking. Heartbeats are first-class frames so a long idle connection doesn’t NAT-time-out. The daemon may push unsolicited events (eval-cache invalidations) under request_id = 0, which clients route to a subscription handler.

Structs§

ArchivedHeartbeat
An archived Heartbeat
ArchivedLocalError
An archived LocalError
ArchivedStatsSnapshot
An archived StatsSnapshot
Heartbeat
HeartbeatResolver
The resolver for an archived Heartbeat
LocalError
Daemon-side errors. Codes are stable IDs; messages are operator- readable strings (English; not localized).
LocalErrorResolver
The resolver for an archived LocalError
StatsSnapshot
StatsSnapshotResolver
The resolver for an archived StatsSnapshot

Enums§

ArchivedErrorCode
An archived ErrorCode
ArchivedLocalRequest
An archived LocalRequest
ArchivedLocalResponse
An archived LocalResponse
ArchivedWireFrame
An archived WireFrame
ErrorCode
Stable error codes. Append-only.
ErrorCodeResolver
The resolver for an archived ErrorCode
LocalRequest
Every request the local protocol can carry today. Append new variants at the bottom — rkyv tag stability rule.
LocalRequestResolver
The resolver for an archived LocalRequest
LocalResponse
Every response the local protocol can carry today.
LocalResponseResolver
The resolver for an archived LocalResponse
WireFrame
One frame on the wire. All inter-process communication on the local link is one or more of these.
WireFrameResolver
The resolver for an archived WireFrame

Constants§

FRAME_MAGIC
Magic bytes at the start of every frame on the local protocol. Bumping requires a MAX_LOCAL_PROTOCOL_VERSION bump too.

Type Aliases§

RequestId
Multiplex correlation id. 0 is reserved for unsolicited server pushes (cache invalidations, progress events).