pub enum WsMessage {
Request(WsRequest),
Response(WsResponse),
Event(WsEvent),
}Expand description
Discriminated union for parsing any incoming WS text frame.
Uses #[serde(untagged)] which tries variants in order.
Discriminating fields (order matters):
Request— matched first because it has a requiredmethodfieldResponse— hasid+ optionalresult/error(nomethod)Event— haseventfield, noidormethod
A message with both method and result would match Request.
This is correct because responses never have a method field.
Variants§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for WsMessage
impl<'de> Deserialize<'de> for WsMessage
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 WsMessage
impl RefUnwindSafe for WsMessage
impl Send for WsMessage
impl Sync for WsMessage
impl Unpin for WsMessage
impl UnsafeUnpin for WsMessage
impl UnwindSafe for WsMessage
Blanket Implementations§
impl<T> Allocation for T
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