summaryrefslogtreecommitdiff
path: root/src/fromtoparameter.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-09-27 15:33:09 +0200
committertroido <troido@protonmail.com>2020-09-27 15:33:09 +0200
commita20bcfed7d3b6aacc3211514d9804651a458e725 (patch)
treed4d4aaab553a3a9065e9dba8ef4fdec9ccf45778 /src/fromtoparameter.rs
parentc3a282d04f1fd5c7cc4cf5ebb478129c2b1c42fa (diff)
better serialisation structure for encyclopediae
["list", [1, 2, 3]] is now just [1, 2, 3] and {"type": builtwall", "kwargs": {"health": 50}} is now {":template": "builtwall", "health": 50}
Diffstat (limited to 'src/fromtoparameter.rs')
-rw-r--r--src/fromtoparameter.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/fromtoparameter.rs b/src/fromtoparameter.rs
index 8d169d0..13483d7 100644
--- a/src/fromtoparameter.rs
+++ b/src/fromtoparameter.rs
@@ -76,7 +76,6 @@ tofrom!(i64: Int);
tofrom!(f64: Float);
tofrom!(bool:Bool);
tofrom!(String: String);
-tofrom!(Pos: Pos);
tofrom!(Template: Template);
tofrom!(PlayerId(String));
@@ -177,3 +176,13 @@ where
Parameter::List(vec![self.0.to_parameter(), self.1.to_parameter(), self.2.to_parameter()])
}
}
+
+impl FromToParameter for Pos {
+ fn from_parameter(p: Parameter) -> Option<Self>{
+ let (x, y) = <(i64, i64)>::from_parameter(p)?;
+ Some(Self{x, y})
+ }
+ fn to_parameter(self) -> Parameter {
+ (self.x, self.y).to_parameter()
+ }
+}