1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
use std::fmt::{Debug, Display, Formatter, Result}; use serde::{Deserialize, Serialize}; #[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize, num_enum::TryFromPrimitive)] #[repr(u8)] pub enum Port { P1 = 0, P2 = 1, P3 = 2, P4 = 3, } impl Display for Port { fn fmt(&self, f: &mut Formatter) -> Result { use Port::*; match *self { P1 => write!(f, "P1"), P2 => write!(f, "P2"), P3 => write!(f, "P3"), P4 => write!(f, "P4"), } } } #[derive(Clone, Copy, Debug, PartialEq, Serialize)] pub enum Direction { Left, Right } frame_data!(Position { x: f32, y: f32, }, { }); frame_data!(Velocity { x: f32, y: f32, }, { });