#[repr(C, align(8))]pub struct Frame {
pub magic: [u8; 2],
pub version: u8,
pub status: Status,
pub pid: u32,
pub timestamp: u64,
pub nonce: u64,
pub payload: u64,
}Expand description
On-wire health frame — exactly 32 bytes, 8-byte aligned, little-endian
integer fields. The struct is repr(C) so its layout is ABI-stable across
compilations and trivially verifiable by inspection.
Construct frames directly via the public fields, then call
Frame::encode to write to a socket buffer or Frame::decode to read
one. There is no Default; agents always supply a real pid, nonce and
timestamp.
Fields§
§magic: [u8; 2]Magic prefix, always equal to MAGIC.
version: u8Protocol version, always equal to VERSION on emit.
status: StatusHealth status reported by the agent. Encoded on the wire as a
single byte at offset 3 (Status discriminants are #[repr(u8)]).
pid: u32OS process id of the emitting agent.
timestamp: u64Monotonic timestamp chosen by the emitter (typically nanoseconds since some agent-local epoch). Observers do not interpret it; they only compare consecutive timestamps for the same pid.
nonce: u64Strictly increasing counter, starting at 1 on the first beat after
Varta::connect. The panic hook pins this to NONCE_TERMINAL to
mark a final critical frame. Regular beats cap at NONCE_TERMINAL - 1.
payload: u64Free-form 8-byte payload — application-defined health context (queue depth, error code, etc.). Carried opaquely by the protocol.
Implementations§
Source§impl Frame
impl Frame
Sourcepub const fn new(
status: Status,
pid: u32,
timestamp: u64,
nonce: u64,
payload: u64,
) -> Frame
pub const fn new( status: Status, pid: u32, timestamp: u64, nonce: u64, payload: u64, ) -> Frame
Sourcepub fn encode(&self, out: &mut [u8; 32])
pub fn encode(&self, out: &mut [u8; 32])
Serialise this frame into a 32-byte buffer in canonical little-endian layout. The output buffer is overwritten in place; this method allocates nothing.
Sourcepub fn decode(bytes: &[u8; 32]) -> Result<Frame, DecodeError>
pub fn decode(bytes: &[u8; 32]) -> Result<Frame, DecodeError>
Decode a 32-byte buffer back into a Frame, validating magic,
version, and status in that order. Returns DecodeError on the
first failed check; the integer fields are not interpreted further.