From 83ffcc667999879197508aba0d1f910ca7cb000b Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Fri, 30 Dec 2022 09:29:12 -0500 Subject: Populate result after a board is played --- protocol/src/move_result.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 protocol/src/move_result.rs (limited to 'protocol/src/move_result.rs') diff --git a/protocol/src/move_result.rs b/protocol/src/move_result.rs new file mode 100644 index 0000000..8dad6ef --- /dev/null +++ b/protocol/src/move_result.rs @@ -0,0 +1,23 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug)] +pub enum MoveResult { + Current(Current), + Next(Next), +} + +impl MoveResult { + pub fn current(self) -> Result { + match self { + MoveResult::Current(o) => Ok(o), + MoveResult::Next(_) => Err(anyhow::anyhow!("Not in current state")), + } + } + + pub fn next(self) -> Result { + match self { + MoveResult::Next(f) => Ok(f), + MoveResult::Current(_) => Err(anyhow::anyhow!("Not in next state")), + } + } +} -- cgit v1.2.3