24 lines
742 B
Rust
24 lines
742 B
Rust
use libpso::{PSOPacket, PacketParseError};
|
|
use libpso::crypto::PSOCipher;
|
|
|
|
|
|
pub enum OnConnect {
|
|
Packet(Box<dyn PSOPacket>),
|
|
Cipher((Box<dyn PSOCipher>, Box<dyn PSOCipher>)),
|
|
}
|
|
|
|
pub trait ServerPacket: Sized {
|
|
fn from_bytes(data: &Vec<u8>) -> Result<Self, PacketParseError>;
|
|
}
|
|
|
|
pub trait ServerState {
|
|
type Packet: ServerPacket;
|
|
type PacketError;
|
|
|
|
//fn handle(&mut self, pkt: &Self::Packet) -> Result<Vec<Box<dyn PSOPacket>>, Self::PacketError>;
|
|
fn on_connect(&mut self) -> Vec<OnConnect>;
|
|
//fn handle(&mut self, pkt: &Self::Packet) -> Result<Box<dyn Iterator<Item = Box<dyn PSOPacket>>>, Self::PacketError>;
|
|
fn handle(&mut self, pkt: &Self::Packet) -> Box<dyn Iterator<Item = Box<dyn PSOPacket>>>;
|
|
}
|
|
|