chiark / gitweb /
add hashlink and work on Library
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 8 Sep 2020 21:56:28 +0000 (22:56 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 8 Sep 2020 21:56:28 +0000 (22:56 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Cargo.lock.example
Cargo.nail
Cargo.toml
library/wikimedia.toml [new file with mode: 0644]
src/imports.rs
src/lib.rs
src/shapelib.rs [new file with mode: 0644]

index 5cb43d59e34a7a1f28009082f253cc7afef474c2..1de541d0b4dc49463a8ef3715ba2946a529af53c 100644 (file)
@@ -70,6 +70,12 @@ dependencies = [
  "opaque-debug",
 ]
 
+[[package]]
+name = "ahash"
+version = "0.3.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217"
+
 [[package]]
 name = "aho-corasick"
 version = "0.7.13"
@@ -590,12 +596,30 @@ version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
 
+[[package]]
+name = "hashbrown"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25"
+dependencies = [
+ "ahash",
+ "autocfg",
+]
+
 [[package]]
 name = "hashbrown"
 version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7"
 
+[[package]]
+name = "hashlink"
+version = "0.6.0-alpha.0"
+dependencies = [
+ "hashbrown 0.8.2",
+ "serde",
+]
+
 [[package]]
 name = "heck"
 version = "0.3.1"
@@ -709,7 +733,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2"
 dependencies = [
  "autocfg",
- "hashbrown",
+ "hashbrown 0.9.0",
 ]
 
 [[package]]
@@ -1021,6 +1045,7 @@ dependencies = [
  "fehler",
  "flexi_logger",
  "fs2",
+ "hashlink",
  "htmlescape",
  "index_vec",
  "inventory",
index 37b23d90715a25b05d8cd855a46e0b755777a7ff..9188459c24c0372b7216561a56ec5a48794312e9 100644 (file)
@@ -6,6 +6,7 @@ subdirs = """
 server
 flexi_logger
 bundle-sources
+hashlink
 #rocket
 """
 
index 3b838fb41c700fba56a23dfa0ecdb781e216cbee..33fdf6a5fa6a2d2a0bd6267f065fa5e1dc7c0480 100644 (file)
@@ -85,6 +85,7 @@ vecdeque-stableix = "1"
 #sha2 = "0.8"
 #generic-array = "0.12"
 
+hashlink = { version = "0.5", features = ["serde_impl"] }
 
 #clap = "2"
 #structopt = "0.3"
diff --git a/library/wikimedia.toml b/library/wikimedia.toml
new file mode 100644 (file)
index 0000000..ad8e94f
--- /dev/null
@@ -0,0 +1,21 @@
+# Copyright 2020 Ian Jackson
+# SPDX-License-Identifier: AGPL-3.0-or-later OR CC-BY-SA-3.0
+# There is NO WARRANTY.
+
+[chess]
+
+shape = "circle"
+size = [45]
+shift = [22.5, 22.5];
+category = "chess"
+
+files = "
+blt45  a white bishop
+adt45  a black knight
+"
+[chess.scraper]
+
+method = "wikimedia"
+licences = [ "Cc-by-sa-3.0", "GFDL|migration=relicense" ]
+url_prefix = "https://commons.wikimedia.org/wiki/File:Chess "
+url_suffix = ".svg"
index 2f85f84dd590e5e50fdc6b85548b5714cdc3ec74..ec8fc428f4cf8f58571fb0b40f8b0a8dbfbeae38 100644 (file)
@@ -83,6 +83,8 @@ pub use num_traits::Bounded;
 
 pub use flexi_logger::{LogSpecification};
 
+pub use hashlink::LinkedHashMap;
+
 pub use crate::global::*;
 pub use crate::gamestate::*;
 pub use crate::pieces::*;
index a08b577a8cb4c9d697fe84a22fddb7232af56207..e69492ef955565df7ff038386900182666f5337d 100644 (file)
@@ -23,4 +23,5 @@ pub mod commands;
 pub mod utils;
 pub mod mgmtchannel;
 pub mod debugreader;
+pub mod shapelib;
 #[path="slotmap-slot-idx.rs"] pub mod slotmap_slot_idx;
diff --git a/src/shapelib.rs b/src/shapelib.rs
new file mode 100644 (file)
index 0000000..6adb943
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright 2020 Ian Jackson
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+pub use crate::imports::*;
+
+#[derive(Deserialize)]
+pub struct Library {
+  pub sections: LinkedHashMap<String, Section>,
+}
+
+#[derive(Deserialize)]
+pub struct Section {
+  pub shape: Box<dyn OutlineSpec>,
+  pub size: Vec<Coord>,
+  pub middle: Option<Vec<f64>>,
+  pub category: String,
+  pub files: FileList,
+  pub scraper: toml::Value,
+}
+
+#[derive(Deserialize)]
+pub struct FileList (Vec<FileEntry>);
+
+#[derive(Deserialize)]
+pub struct FileEntry {
+  pub filespec: String,
+  pub desc: Html,
+}
+
+#[typetag::serde(tag="outline")]
+pub trait OutlineSpec {
+}