From: Ian Jackson Date: Tue, 8 Sep 2020 21:56:28 +0000 (+0100) Subject: add hashlink and work on Library X-Git-Tag: otter-0.2.0~960 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=b0376a45aeb6e1e57a8d92699b68077d20f8aa95;p=otter.git add hashlink and work on Library Signed-off-by: Ian Jackson --- diff --git a/Cargo.lock.example b/Cargo.lock.example index 5cb43d59..1de541d0 100644 --- a/Cargo.lock.example +++ b/Cargo.lock.example @@ -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", diff --git a/Cargo.nail b/Cargo.nail index 37b23d90..9188459c 100644 --- a/Cargo.nail +++ b/Cargo.nail @@ -6,6 +6,7 @@ subdirs = """ server flexi_logger bundle-sources +hashlink #rocket """ diff --git a/Cargo.toml b/Cargo.toml index 3b838fb4..33fdf6a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 index 00000000..ad8e94fd --- /dev/null +++ b/library/wikimedia.toml @@ -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" diff --git a/src/imports.rs b/src/imports.rs index 2f85f84d..ec8fc428 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -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::*; diff --git a/src/lib.rs b/src/lib.rs index a08b577a..e69492ef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 index 00000000..6adb9436 --- /dev/null +++ b/src/shapelib.rs @@ -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, +} + +#[derive(Deserialize)] +pub struct Section { + pub shape: Box, + pub size: Vec, + pub middle: Option>, + pub category: String, + pub files: FileList, + pub scraper: toml::Value, +} + +#[derive(Deserialize)] +pub struct FileList (Vec); + +#[derive(Deserialize)] +pub struct FileEntry { + pub filespec: String, + pub desc: Html, +} + +#[typetag::serde(tag="outline")] +pub trait OutlineSpec { +}