Remove some generics & make some typedefs.
This commit is contained in:
parent
eee34eb3ff
commit
dacb031443
1 changed files with 9 additions and 7 deletions
|
@ -4,16 +4,18 @@ use serde_json::Value;
|
|||
pub mod server;
|
||||
|
||||
pub type PlayerId = usize;
|
||||
pub type PlayerInput = Value;
|
||||
pub type GameState = Value;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[serde(tag = "t")]
|
||||
pub enum ClientMessage<I = Value, S = Value> {
|
||||
pub enum ClientMessage {
|
||||
#[serde(rename = "s")]
|
||||
SetState { s: S },
|
||||
SetState { s: GameState },
|
||||
#[serde(rename = "i")]
|
||||
Input { i: I },
|
||||
Input { i: PlayerInput },
|
||||
#[serde(rename = "g")]
|
||||
GetState { c: usize, s: S },
|
||||
GetState { c: usize, s: GameState },
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Clone)]
|
||||
|
@ -24,16 +26,16 @@ pub struct Meta {
|
|||
|
||||
#[derive(Serialize, Debug, Clone)]
|
||||
#[serde(tag = "t")]
|
||||
pub enum ServerMessage<I = Vec<Value>, S = Value> {
|
||||
pub enum ServerMessage {
|
||||
#[serde(rename = "m")]
|
||||
Meta {
|
||||
#[serde(flatten)]
|
||||
m: Meta,
|
||||
},
|
||||
#[serde(rename = "s")]
|
||||
SetState { u: Option<PlayerId>, s: S },
|
||||
SetState { u: Option<PlayerId>, s: GameState },
|
||||
#[serde(rename = "i")]
|
||||
Input { i: I },
|
||||
Input { i: Vec<PlayerInput> },
|
||||
#[serde(rename = "g")]
|
||||
GetState { c: usize },
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue