wsprism_core/protocol/
text.rs

1//! Ext Lane envelope (JSON).
2//!
3//! The core stores `data` as `RawValue` to enable lazy parsing by downstream
4//! services and plugins. Unknown fields are rejected to keep the contract
5//! strict and predictable.
6
7use serde::Deserialize;
8use serde_json::value::RawValue;
9
10/// Ext Lane envelope (Text frame).
11///
12/// This is the canonical JSON structure parsed on the server. Services may
13/// choose to further deserialize `data` depending on `svc`/`type`.
14#[derive(Debug, Deserialize)]
15#[serde(deny_unknown_fields)]
16pub struct Envelope {
17    /// Protocol version.
18    pub v: u8,
19    /// Service name (e.g., "chat").
20    pub svc: String,
21    /// Message type (field name is `type` in JSON).
22    #[serde(rename = "type")]
23    pub msg_type: String,
24    /// Feature flags bitmask.
25    #[serde(default)]
26    pub flags: u32,
27    /// Optional sequence number.
28    #[serde(default)]
29    pub seq: Option<u64>,
30    /// Optional room id.
31    #[serde(default)]
32    pub room: Option<String>,
33    /// Optional payload, stored as raw JSON (lazy parsing).
34    #[serde(default)]
35    pub data: Option<Box<RawValue>>,
36}