use crate::{comp, state}; use serde_derive::{Deserialize, Serialize}; use std::marker::PhantomData; // Automatically derive From for EcsResPacket // for each variant EcsResPacket::T(T). sphynx::sum_type! { #[derive(Clone, Debug, Serialize, Deserialize)] pub enum EcsResPacket { Time(state::Time), TimeOfDay(state::TimeOfDay), } } impl sphynx::ResPacket for EcsResPacket {} // Automatically derive From for EcsCompPacket // for each variant EcsCompPacket::T(T.) sphynx::sum_type! { #[derive(Clone, Debug, Serialize, Deserialize)] pub enum EcsCompPacket { Pos(comp::Pos), Vel(comp::Vel), Ori(comp::Ori), Body(comp::Body), Player(comp::Player), CanBuild(comp::CanBuild), Stats(comp::Stats), } } // Automatically derive From for EcsCompPhantom // for each variant EcsCompPhantom::T(PhantomData). sphynx::sum_type! { #[derive(Clone, Debug, Serialize, Deserialize)] pub enum EcsCompPhantom { Pos(PhantomData), Vel(PhantomData), Ori(PhantomData), Body(PhantomData), Player(PhantomData), CanBuild(PhantomData), Stats(PhantomData), } } impl sphynx::CompPacket for EcsCompPacket { type Phantom = EcsCompPhantom; }