microsandbox_protocol/core.rs
1//! Core protocol message payloads.
2
3use serde::{Deserialize, Serialize};
4
5//--------------------------------------------------------------------------------------------------
6// Types
7//--------------------------------------------------------------------------------------------------
8
9/// Payload for `core.ready` messages.
10///
11/// Sent by the guest agent to signal that it has finished initialization
12/// and is ready to receive commands. Includes timing data for boot
13/// performance measurement.
14#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct Ready {
16 /// `CLOCK_BOOTTIME` nanoseconds captured at the start of `main()`.
17 ///
18 /// Represents how long the kernel took to boot before userspace started.
19 pub boot_time_ns: u64,
20
21 /// Nanoseconds spent in `init::init()` (mounting filesystems).
22 pub init_time_ns: u64,
23
24 /// `CLOCK_BOOTTIME` nanoseconds captured just before sending this message.
25 ///
26 /// Represents total time from kernel boot to agent readiness.
27 pub ready_time_ns: u64,
28}
29
30/// Payload for `core.relay.client.disconnected` messages.
31///
32/// Sent by the host relay when one SDK client socket disconnects. The
33/// guest agent uses the assigned correlation ID range to clean up resources
34/// owned by that client, such as open filesystem handles.
35#[derive(Debug, Clone, Serialize, Deserialize)]
36pub struct RelayClientDisconnected {
37 /// First correlation ID assigned to the disconnected client.
38 pub id_start: u32,
39
40 /// Exclusive upper bound of the disconnected client's ID range.
41 pub id_end_exclusive: u32,
42}