mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-25 05:08:21 -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>);
|