From f7706683939053c70509373d5d70638d11ce3c8e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 8 Sep 2020 23:34:07 +0100 Subject: [PATCH] wip library Signed-off-by: Ian Jackson --- library/wikimedia.toml | 9 +++++---- src/bin/otterlib.rs | 9 +++++++++ src/imports.rs | 1 + src/shapelib.rs | 18 ++++++++++++------ 4 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 src/bin/otterlib.rs diff --git a/library/wikimedia.toml b/library/wikimedia.toml index ad8e94fd..98fa65dd 100644 --- a/library/wikimedia.toml +++ b/library/wikimedia.toml @@ -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 index 00000000..bd903b6f --- /dev/null +++ b/src/bin/otterlib.rs @@ -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); +} diff --git a/src/imports.rs b/src/imports.rs index ec8fc428..561cfd9d 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -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; diff --git a/src/shapelib.rs b/src/shapelib.rs index 6adb9436..37daf3e9 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -4,12 +4,13 @@ pub use crate::imports::*; -#[derive(Deserialize)] +#[derive(Deserialize,Debug)] +#[serde(transparent)] pub struct Library { pub sections: LinkedHashMap, } -#[derive(Deserialize)] +#[derive(Deserialize,Debug)] pub struct Section { pub shape: Box, pub size: Vec, @@ -19,15 +20,20 @@ pub struct Section { pub scraper: toml::Value, } -#[derive(Deserialize)] +#[derive(Deserialize,Debug)] pub struct FileList (Vec); -#[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 { } -- 2.30.2