Skip to main content

WsMessage

Enum WsMessage 

Source
pub enum WsMessage {
    SerialIn {
        data: String,
    },
    SerialOut {
        data: String,
    },
    State {
        state: GuestState,
    },
    Launch,
    Reset,
    Hello {
        version: String,
    },
    KernelChanged {
        ok: bool,
        mtime: i64,
        size: u64,
        sha256_prefix: String,
        reason: Option<String>,
    },
    ConfigUpdate {
        config: Value,
    },
    ConfigInvalid {
        error: String,
        line: Option<u32>,
        col: Option<u32>,
    },
    ScenarioStart {
        scenario: String,
    },
    ScenarioAbort {
        reason: String,
    },
    ScenarioResult {
        verdict: String,
        scenario: String,
        started_at: String,
        ended_at: String,
        actions: Value,
        transcript: Value,
        error: Option<String>,
    },
}
Expand description

Wire-level message exchanged over the /ws endpoint.

Externally tagged via #[serde(tag = "type")], producing JSON of the form {"type": "SerialIn", "data": "..."}. Byte payloads (SerialIn, SerialOut) are base64-encoded so the protocol stays JSON-only on the wire — see 02-CONTEXT.md decision “/ws message protocol — tagged JSON only”.

Note: #[serde(deny_unknown_fields)] is intentionally NOT applied — Phase 4 may add variants additively and older clients should ignore unknown fields gracefully (02-RESEARCH.md Open Question 3).

Phase 4 (additive): ScenarioStart, ScenarioAbort, and ScenarioResult extend this enum without renaming or reordering any existing variant. The bootroom run driver awaits a single ScenarioResult frame per scenario and translates verdict to a process exit code (RUN-01, RUN-08).

Variants§

§

SerialIn

Host -> guest. Bytes injected into guest stdin. data is base64.

Fields

§data: String
§

SerialOut

Guest -> host. Bytes the guest emitted on serial. data is base64. Browser emits these for the server to log; server may forward in Phase 4 headless mode.

Fields

§data: String
§

State

Server -> client. Authoritative guest status pill state. When the /ws connection is live this overrides the browser’s local view.

Fields

§

Launch

Client -> server. Asks the server (and observers) to log a Launch action; the browser then page-reloads to re-instantiate qemu-wasm.

§

Reset

Client -> server. Asks the server (and observers) to log a Reset action; in Phase 2 this is identical to Launch from the browser’s perspective.

§

Hello

Server -> client on connect. version is the server’s CARGO_PKG_VERSION. Mismatched clients log a warning but proceed.

Fields

§version: String
§

KernelChanged

Server -> client. Watcher detected a kernel rebuild. ok=true means size-stability and ELF magic both passed; ok=false carries reason (e.g., "not ELF"). The browser shows a non-intrusive banner; Launch is user-initiated. WCH-05.

Fields

§ok: bool
§mtime: i64
§size: u64
§sha256_prefix: String
§reason: Option<String>
§

ConfigUpdate

Server -> client. bootroom.toml was edited and re-parsed successfully. config is the same JSON projection /api/config returns. CFG-10.

Fields

§config: Value
§

ConfigInvalid

Server -> client. bootroom.toml was edited but re-parse failed. The last-known-good config remains active. line/col are 1-based when the error has a TOML span. CFG-10.

Fields

§error: String
§line: Option<u32>
§

ScenarioStart

Browser -> server (reserved). Sent by the scenario engine at scenario kickoff. Phase 4 does not require the server to act on this frame — URL-query detection (?scenario=<name>) is the canonical entry point — but the variant is reserved so future server-driven re-runs (--watch, v2) get the wire shape for free. Per 04-RESEARCH Open Question 1: ship now, leave unused.

Fields

§scenario: String
§

ScenarioAbort

Server -> client. Defensive cancellation. Phase 4 does not emit this frame on any code path; reserved so a future per-server outer-timeout path can request the browser to bail. Per 04-RESEARCH WsMessage block “Server -> client. Defensive cancellation”.

Fields

§reason: String
§

ScenarioResult

Browser -> server. Final scenario verdict + full transcript. The bootroom run driver awaits this frame on a oneshot::Receiver (parked on AppState) and translates verdict to a process exit code. Schema (RUN-01, RUN-08):

  • verdict: “pass” | “fail” | “timeout” | “error”
  • scenario: the scenario name as run
  • started_at / ended_at: ISO 8601 UTC timestamps with Z suffix (04-RESEARCH Open Question 3: UTC for machine-parseable logs)
  • actions: opaque JSON — per-action verdicts + per-assertion verdicts
  • transcript: opaque JSON — ordered event list (same shape as the --log-file JSONL stream defined in 04-06)
  • error: optional structured message for verdict ∈ {“timeout”, “error”}

The two opaque-JSON fields use serde_json::Value (not concrete nested structs) so the wire shape is forward-compatible: the browser engine builds the JSON; the server only forwards bytes to --log-file and translates verdict. Concrete nested structs would force schema-version coupling on every event-shape change.

Fields

§verdict: String
§scenario: String
§started_at: String
§ended_at: String
§actions: Value
§transcript: Value

Trait Implementations§

Source§

impl Clone for WsMessage

Source§

fn clone(&self) -> WsMessage

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WsMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for WsMessage

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for WsMessage

Source§

fn eq(&self, other: &WsMessage) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for WsMessage

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for WsMessage

Source§

impl StructuralPartialEq for WsMessage

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,