pub struct WebSocketMessage {
pub event: String,
pub data: Value,
}Expand description
Adapter-neutral WebSocket message used by gateways and adapters.
Fields§
§event: String§data: ValueImplementations§
Source§impl WebSocketMessage
impl WebSocketMessage
pub fn new(event: impl Into<String>, data: impl Into<Value>) -> Self
pub fn event(&self) -> &str
pub fn data(&self) -> &Value
pub fn data_as<T>(&self) -> Result<T>where
T: DeserializeOwned,
pub fn data_field(&self, name: &str) -> Result<Option<Value>>
pub fn data_field_as<T>(&self, name: &str) -> Result<T>where
T: DeserializeOwned,
pub fn optional_data_field_as<T>(&self, name: &str) -> Result<Option<T>>where
T: DeserializeOwned,
pub fn data_field_string(&self, name: &str) -> Result<String>
pub fn optional_data_field_string(&self, name: &str) -> Result<Option<String>>
pub fn validated_data<T>(&self) -> Result<T>where
T: DeserializeOwned + Validate,
pub fn text(event: impl Into<String>, data: impl Into<String>) -> Self
pub fn json<T>(event: impl Into<String>, data: &T) -> Result<Self>where
T: Serialize,
Trait Implementations§
Source§impl Clone for WebSocketMessage
impl Clone for WebSocketMessage
Source§fn clone(&self) -> WebSocketMessage
fn clone(&self) -> WebSocketMessage
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 WebSocketMessage
impl Debug for WebSocketMessage
Source§impl<'de> Deserialize<'de> for WebSocketMessage
impl<'de> Deserialize<'de> for WebSocketMessage
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
Source§impl From<WebSocketMessage> for WebSocketExceptionResponse
impl From<WebSocketMessage> for WebSocketExceptionResponse
Source§fn from(message: WebSocketMessage) -> Self
fn from(message: WebSocketMessage) -> Self
Converts to this type from the input type.
Source§impl IntoWebSocketReply for WebSocketMessage
impl IntoWebSocketReply for WebSocketMessage
fn into_websocket_reply(self) -> Option<WebSocketMessage>
Source§impl PartialEq for WebSocketMessage
impl PartialEq for WebSocketMessage
Source§impl Serialize for WebSocketMessage
impl Serialize for WebSocketMessage
impl StructuralPartialEq for WebSocketMessage
Auto Trait Implementations§
impl Freeze for WebSocketMessage
impl RefUnwindSafe for WebSocketMessage
impl Send for WebSocketMessage
impl Sync for WebSocketMessage
impl Unpin for WebSocketMessage
impl UnsafeUnpin for WebSocketMessage
impl UnwindSafe for WebSocketMessage
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