use std::fmt::Display;
use std::net::SocketAddr;
use crate::base::connection_net_event::ConnectionNetEvent;
use crate::net::channel::Channel;
#[derive(Debug, Clone)]
pub struct TokioEvent {
type_: ConnectionNetEvent,
remote_addr: SocketAddr,
channel: Channel,
}
impl TokioEvent {
pub fn new(type_: ConnectionNetEvent, remote_addr: SocketAddr, channel: Channel) -> Self {
Self {
type_,
remote_addr,
channel,
}
}
#[inline]
pub fn type_(&self) -> &ConnectionNetEvent {
&self.type_
}
#[inline]
pub fn remote_addr(&self) -> &SocketAddr {
&self.remote_addr
}
#[inline]
pub fn channel(&self) -> &Channel {
&self.channel
}
}
impl Display for TokioEvent {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"TokioEvent {{ type_: {:?}, remote_addr: {:?}, channel: {:?} }}",
self.type_, self.remote_addr, self.channel
)
}
}