lnkit 0.2.1

Multiplayer game library
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use lnkit::prelude::*;

#[derive(Debug, Deserialize)]
#[serde(tag = "t", content = "c")]
pub enum Input {
    Jump,
    Left(bool),
    Down(bool),
    Up(bool),
    Right(bool),
}

impl TryFrom<Message> for Input {
    type Error = serde_json::Error;
    fn try_from(msg: Message) -> Result<Self, Self::Error> {
        serde_json::from_slice(&msg.into_data())
    }
}