veloren/common/src/msg/ecs_packet.rs
Joshua Barretto 62b91eb01b Integrated Sphynx
Former-commit-id: 5d96983a385bb77a2876aa7439158252b7e2f0fc
2019-04-14 14:23:43 +01:00

30 lines
910 B
Rust

use std::marker::PhantomData;
use serde_derive::{Serialize, Deserialize};
use crate::comp;
// Automatically derive From<T> for Packet for each variant Packet::T(T)
sphynx::sum_type! {
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum EcsPacket {
Pos(comp::phys::Pos),
Vel(comp::phys::Vel),
Dir(comp::phys::Dir),
Character(comp::Character),
Player(comp::Player),
}
}
// Automatically derive From<T> for Phantom for each variant Phantom::T(PhantomData<T>)
sphynx::sum_type! {
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum EcsPhantom {
Pos(PhantomData<comp::phys::Pos>),
Vel(PhantomData<comp::phys::Vel>),
Dir(PhantomData<comp::phys::Dir>),
Character(PhantomData<comp::Character>),
Player(PhantomData<comp::Player>),
}
}
impl sphynx::Packet for EcsPacket {
type Phantom = EcsPhantom;
}