pub enum PacketBody {
ApiRequest {
request_id: u64,
route: String,
params: Value,
attachments: Vec<FileAttachment>,
metadata: Value,
},
ApiResponse {
request_id: u64,
ok: bool,
status: u16,
data: Value,
error: Option<ErrorPayload>,
metadata: Value,
},
EventEmit {
event_id: u64,
name: String,
data: Map<String, Value>,
attachments: Vec<FileAttachment>,
metadata: Value,
expect_ack: bool,
},
EventAck {
event_id: u64,
ok: bool,
receipt: Value,
error: Option<ErrorPayload>,
},
}Expand description
JSON-level message body transported inside a WSCALL frame.
The wire format uses short single-letter keys and a numeric k tag to
minimize per-frame overhead:
| Variant | k | Fields |
|---|---|---|
ApiRequest | 0 | i r p a m |
EventEmit | 1 | i n d a m e |
ApiResponse | 2 | i o s d m [er] |
EventAck | 3 | i o rc [er] |
Variants§
ApiRequest
Client-to-server API request.
ApiResponse
Server-to-client API response.
EventEmit
Event emission in either direction.
The data payload is always a JSON object (never a scalar or string).
Fields
§
attachments: Vec<FileAttachment>EventAck
Acknowledgement for an emitted event.
Implementations§
Source§impl PacketBody
impl PacketBody
pub fn message_type(&self) -> MessageType
Sourcepub fn attachments(&self) -> &[FileAttachment]
pub fn attachments(&self) -> &[FileAttachment]
Returns the attachments carried by this packet (empty for responses/acks).
Sourcepub fn set_attachments(&mut self, attachments: Vec<FileAttachment>)
pub fn set_attachments(&mut self, attachments: Vec<FileAttachment>)
Injects decoded binary attachments back into the packet body.
Trait Implementations§
Source§impl Clone for PacketBody
impl Clone for PacketBody
Source§fn clone(&self) -> PacketBody
fn clone(&self) -> PacketBody
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PacketBody
impl Debug for PacketBody
Source§impl<'de> Deserialize<'de> for PacketBody
impl<'de> Deserialize<'de> for PacketBody
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 Freeze for PacketBody
impl RefUnwindSafe for PacketBody
impl Send for PacketBody
impl Sync for PacketBody
impl Unpin for PacketBody
impl UnsafeUnpin for PacketBody
impl UnwindSafe for PacketBody
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