use libpso::PacketParseError; use libpso::crypto::PSOCipher; #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct ClientId(pub usize); pub enum OnConnect { Packet(S), Cipher((Box, Box)), } pub trait RecvServerPacket: Sized { fn from_bytes(data: &[u8]) -> Result; } pub trait SendServerPacket: Sized { fn as_bytes(&self) -> Vec; } pub trait ServerState { type SendPacket: SendServerPacket; type RecvPacket: RecvServerPacket; type PacketError; fn on_connect(&mut self, id: ClientId) -> Vec>; fn handle(&mut self, id: ClientId, pkt: &Self::RecvPacket) -> Result + Send>, Self::PacketError>; fn on_disconnect(&mut self, id: ClientId) -> Vec<(ClientId, Self::SendPacket)>; }