kubi/kubi-udp/src/packet.rs
2023-02-04 22:20:19 +01:00

26 lines
587 B
Rust

use bincode::{Encode, Decode};
use crate::common::ClientId;
#[repr(u8)]
#[derive(Encode, Decode)]
pub enum ClientPacket<T> where T: Encode + Decode {
Data(T),
Connect,
Disconnect,
Heartbeat,
}
#[derive(Encode, Decode)]
pub struct IdClientPacket<T: Encode + Decode>(pub Option<ClientId>, pub ClientPacket<T>);
#[repr(u8)]
#[derive(Encode, Decode)]
pub enum ServerPacket<T> where T: Encode + Decode {
Data(T),
Connected(ClientId),
Disconnected(String),
}
#[derive(Encode, Decode)]
pub struct IdServerPacket<T: Encode + Decode>(pub Option<ClientId>, pub ServerPacket<T>);