summaryrefslogtreecommitdiff
path: root/protocol/src/play_result.rs
diff options
context:
space:
mode:
Diffstat (limited to 'protocol/src/play_result.rs')
-rw-r--r--protocol/src/play_result.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/protocol/src/play_result.rs b/protocol/src/play_result.rs
new file mode 100644
index 0000000..21961ee
--- /dev/null
+++ b/protocol/src/play_result.rs
@@ -0,0 +1,20 @@
+pub enum MoveResult<Stay, Go> {
+ Stay(Stay),
+ Go(Go),
+}
+
+impl<Stay, Go> MoveResult<Stay, Go> {
+ pub fn stay(self) -> Result<Stay, anyhow::Error> {
+ match self {
+ MoveResult::Stay(o) => Ok(o),
+ MoveResult::Go(_) => Err(anyhow::anyhow!("Not in stay state")),
+ }
+ }
+
+ pub fn go(self) -> Result<Go, anyhow::Error> {
+ match self {
+ MoveResult::Go(f) => Ok(f),
+ MoveResult::Stay(_) => Err(anyhow::anyhow!("Not in go state")),
+ }
+ }
+}