pub struct Message<T> {
pub message_type: MessageType,
pub correlation_id: Option<String>,
pub payload: T,
}Expand description
Generic WebSocket message container for requests, responses, and events.
§Example (Request)
{
"type": "request",
"correlation_id": "abc123",
"payload": {
"action": "createsession",
"name": "My Session"
}
}§Example (Response)
{
"type": "response",
"correlation_id": "abc123",
"payload": {
"action": "sessioncreated",
"session_id": "sess_xyz",
"name": "My Session"
}
}§Example (Event)
{
"type": "event",
"payload": {
"event": "nodestatechanged",
"session_id": "sess_xyz",
"node_id": "gain1",
"state": { "Running": null }
}
}Fields§
§message_type: MessageTypeThe type of message (Request, Response, or Event)
correlation_id: Option<String>Optional correlation ID for matching requests with responses. Present in Request and Response messages, absent in Event messages.
payload: TThe message payload (RequestPayload, ResponsePayload, or EventPayload)
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Message<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Message<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<T> Freeze for Message<T>where
T: Freeze,
impl<T> RefUnwindSafe for Message<T>where
T: RefUnwindSafe,
impl<T> Send for Message<T>where
T: Send,
impl<T> Sync for Message<T>where
T: Sync,
impl<T> Unpin for Message<T>where
T: Unpin,
impl<T> UnwindSafe for Message<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more