chiark / gitweb /
wip library
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 8 Sep 2020 22:34:07 +0000 (23:34 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 8 Sep 2020 22:34:07 +0000 (23:34 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
library/wikimedia.toml
src/bin/otterlib.rs [new file with mode: 0644]
src/imports.rs
src/shapelib.rs

index ad8e94fdcb7a2902e7bf8d39526af0db8b25db7b..98fa65dd410e11876482d8c165ef3a6b590b530f 100644 (file)
@@ -4,15 +4,16 @@
 
 [chess]
 
-shape = "circle"
+outline.Circle = { }
 size = [45]
-shift = [22.5, 22.5];
+scale = 0.20
+shift = [22.5, 22.5]
 category = "chess"
 
-files = "
+files = """
 blt45  a white bishop
 adt45  a black knight
-"
+"""
 [chess.scraper]
 
 method = "wikimedia"
diff --git a/src/bin/otterlib.rs b/src/bin/otterlib.rs
new file mode 100644 (file)
index 0000000..bd903b6
--- /dev/null
@@ -0,0 +1,9 @@
+pub use otter::imports::*;
+
+#[throws(anyhow::Error)]
+fn main(){
+  let mut s = String::new();
+  io::stdin().read_to_string(&mut s)?;
+  let l : shapelib::Library = toml::from_str(&s)?;
+  dbg!(l);
+}
index ec8fc428f4cf8f58571fb0b40f8b0a8dbfbeae38..561cfd9da5414176f277c49dc18267e4c31984d6 100644 (file)
@@ -100,6 +100,7 @@ pub use crate::api::{Lens,TransparentLens};
 pub use crate::utils::*;
 pub use crate::spec::*;
 pub use crate::debugreader::DebugReader;
+pub use crate::shapelib;
 
 pub use nix::unistd::Uid;
 
index 6adb94362806657c502da79515a20251e59fb3fe..37daf3e90494740834f516763aa1b5c878c1cf82 100644 (file)
@@ -4,12 +4,13 @@
 
 pub use crate::imports::*;
 
-#[derive(Deserialize)]
+#[derive(Deserialize,Debug)]
+#[serde(transparent)]
 pub struct Library {
   pub sections: LinkedHashMap<String, Section>,
 }
 
-#[derive(Deserialize)]
+#[derive(Deserialize,Debug)]
 pub struct Section {
   pub shape: Box<dyn OutlineSpec>,
   pub size: Vec<Coord>,
@@ -19,15 +20,20 @@ pub struct Section {
   pub scraper: toml::Value,
 }
 
-#[derive(Deserialize)]
+#[derive(Deserialize,Debug)]
 pub struct FileList (Vec<FileEntry>);
 
-#[derive(Deserialize)]
+#[derive(Deserialize,Debug)]
 pub struct FileEntry {
   pub filespec: String,
   pub desc: Html,
 }
 
-#[typetag::serde(tag="outline")]
-pub trait OutlineSpec {
+#[typetag::deserialize(tag="outline")]
+pub trait OutlineSpec : Debug {
 }
+
+#[derive(Deserialize,Debug)]
+pub struct Circle { }
+#[typetag::deserialize]
+impl OutlineSpec for Circle { }