kubi/kubi-udp/src/packet.rs

26 lines
579 B
Rust
Raw Normal View History

2023-01-31 20:16:23 -06:00
use bincode::{Encode, Decode};
2023-02-03 12:36:52 -06:00
use crate::common::ClientId;
2023-01-31 20:16:23 -06:00
#[repr(u8)]
#[derive(Encode, Decode)]
pub enum ClientPacket<T> where T: Encode + Decode {
2023-02-01 18:54:12 -06:00
Data(T),
2023-01-31 20:16:23 -06:00
Connect,
Disconnect,
Heartbeat,
2023-02-01 18:54:12 -06:00
}
2023-02-03 12:36:52 -06:00
#[derive(Encode, Decode)]
pub struct IdClientPacket<T: Encode + Decode>(pub Option<ClientId>, pub ClientPacket<T>);
2023-02-01 18:54:12 -06:00
#[repr(u8)]
#[derive(Encode, Decode)]
pub enum ServerPacket<T> where T: Encode + Decode {
Data(T),
2023-02-03 19:47:09 -06:00
Connected(ClientId),
2023-02-01 18:54:12 -06:00
Disconnected,
2023-01-31 20:16:23 -06:00
}
2023-02-03 19:47:09 -06:00
#[derive(Encode, Decode)]
pub struct IdServerPacket<T: Encode + Decode>(pub Option<ClientId>, pub ServerPacket<T>);