pub struct WebSocketMessage {
pub message_type: MessageType,
pub direction: MessageDirection,
pub data: String,
pub raw_data: Option<Vec<u8>>,
pub timestamp_ms: u64,
pub connection_id: String,
}Expand description
A captured WebSocket message
Fields§
§message_type: MessageTypeMessage type
direction: MessageDirectionMessage direction
data: StringMessage data (text or base64 encoded binary)
raw_data: Option<Vec<u8>>Raw binary data (if binary message)
timestamp_ms: u64Timestamp (milliseconds since connection start)
connection_id: StringConnection ID this message belongs to
Implementations§
Source§impl WebSocketMessage
impl WebSocketMessage
Sourcepub fn text(data: &str, direction: MessageDirection, timestamp_ms: u64) -> Self
pub fn text(data: &str, direction: MessageDirection, timestamp_ms: u64) -> Self
Create a new text message
Sourcepub fn binary(
data: Vec<u8>,
direction: MessageDirection,
timestamp_ms: u64,
) -> Self
pub fn binary( data: Vec<u8>, direction: MessageDirection, timestamp_ms: u64, ) -> Self
Create a new binary message
Sourcepub fn with_connection(self, connection_id: &str) -> Self
pub fn with_connection(self, connection_id: &str) -> Self
Set connection ID
Sourcepub const fn is_received(&self) -> bool
pub const fn is_received(&self) -> bool
Check if this message was received
Sourcepub fn json<T: for<'de> Deserialize<'de>>(&self) -> ProbarResult<T>
pub fn json<T: for<'de> Deserialize<'de>>(&self) -> ProbarResult<T>
Parse data as JSON
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 · 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
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