mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-15 03:48:42 -06:00
26 lines
587 B
Rust
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>);
|