chiark / gitweb /
wdt: Provide game_spec_data
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 26 Jan 2021 23:17:26 +0000 (23:17 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 26 Jan 2021 23:17:47 +0000 (23:17 +0000)
No caller yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Cargo.lock.example
wdriver.rs
wdriver/Cargo.toml

index 44a3d31d7285ba7b05c857578f82be25befdecf4..5d7d391e9cbe2f45723f5b6a652a0544e999c56b 100644 (file)
@@ -1743,6 +1743,7 @@ dependencies = [
  "structopt",
  "strum",
  "thirtyfour_sync",
+ "toml 0.5.8",
  "void",
  "x11rb",
 ]
index b2370e34cf5752b51d5b81de49695598daa86a3b..69a6615dc58e4353ba87ad5359e8ec81abe9679e 100644 (file)
@@ -643,6 +643,18 @@ impl DirSubst {
   pub fn game_spec_path(&self) -> String {
     self.subst("@specs@/demo.game.toml")?
   }
+
+  #[throws(AE)]
+  pub fn game_spec_data(&self) -> otter::spec::GameSpec {
+    let path = self.game_spec_path()?;
+    (||{
+      let data = fs::read(&path).context("read")?;
+      let data = toml::de::from_slice(&data).context("parse")?;
+      Ok::<_,AE>(data)
+    })()
+      .context(path)
+      .context("game spec")?
+  }
 }
 
 #[throws(AE)]
index e0a2b8cb08a4ff04feaaa0bd107eb54640802942..1f2d3f8f534a95bedb3da728bb3e836973e709c3 100644 (file)
@@ -34,6 +34,7 @@ serde_json = "1"
 structopt = "0.3"
 strum = { version = "0.20", features = ['derive'] }
 thirtyfour_sync = "0.22"
+toml = "0.5"
 void = "1"
 x11rb = "0.8"