pub struct Message {
pub id: Uuid,
pub msg_type: MessageType,
pub timestamp: i64,
pub payload: Payload,
pub correlation_id: Option<Uuid>,
}Expand description
WebSocket message
Fields§
§id: UuidMessage ID
msg_type: MessageTypeMessage type
timestamp: i64Timestamp (milliseconds since epoch)
payload: PayloadPayload
correlation_id: Option<Uuid>Optional correlation ID (for request/response)
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(msg_type: MessageType, payload: Payload) -> Self
pub fn new(msg_type: MessageType, payload: Payload) -> Self
Create a new message
Sourcepub fn unsubscribe(topic: String) -> Self
pub fn unsubscribe(topic: String) -> Self
Create an unsubscribe message
Sourcepub fn leave_room(room: String) -> Self
pub fn leave_room(room: String) -> Self
Create a leave room message
Sourcepub fn message_type(&self) -> MessageType
pub fn message_type(&self) -> MessageType
Get message type
Sourcepub fn with_correlation_id(self, id: Uuid) -> Self
pub fn with_correlation_id(self, id: Uuid) -> Self
Set correlation ID
Sourcepub fn is_response_to(&self, message_id: &Uuid) -> bool
pub fn is_response_to(&self, message_id: &Uuid) -> bool
Check if this is a response to another message
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
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 Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
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