steamkit/networking/steam3/net_msg_event_args.rs
1//! Arguments of the `NetMsgReceived` event.
2
3use std::net::SocketAddr;
4
5/// Data received from the network.
6#[derive(Clone, Debug, PartialEq, Eq)]
7pub struct NetMsgEventArgs {
8 /// The raw bytes that were received.
9 pub data: Vec<u8>,
10 /// The endpoint the data was received from.
11 pub end_point: SocketAddr,
12}
13
14impl NetMsgEventArgs {
15 /// Creates a new instance.
16 pub fn new(data: Vec<u8>, end_point: SocketAddr) -> Self {
17 Self { data, end_point }
18 }
19
20 /// A copy with different data and the same endpoint.
21 pub fn with_data(&self, data: Vec<u8>) -> NetMsgEventArgs {
22 NetMsgEventArgs {
23 data,
24 end_point: self.end_point,
25 }
26 }
27}