From 9c744b30bc61fef3dafdb4d91a26d29317e6db24 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 18 Sep 2020 23:53:44 +0100 Subject: [PATCH] shapelib: wip commentary about new arrangements, not at all done yet Signed-off-by: Ian Jackson --- src/shapelib.rs | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/shapelib.rs b/src/shapelib.rs index ae0c3725..11d1006a 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -4,29 +4,34 @@ pub use crate::imports::*; +// Naming convention: +// *Defn read from library toml file +// *Info, *List from toml etc. but processed +// *Details some shared structure +// Item } once loaded and part of a game, +// Outline } no Arc's as we serialise/deserialize during save/load + #[derive(Debug)] -pub struct LibraryContents { +pub struct ContentsDefn { dirname: String, items: HashMap, } #[derive(Debug,Clone)] -#[derive(Serialize)] // xxx -#[derive(Deserialize)] // xxx -pub struct LibraryItemDetails { +#[derive(Serialize,Deserialize)] +pub struct ItemDetails { desc: Html, } #[derive(Debug,Clone)] -pub struct LibraryItemInfo { +pub struct LibraryItemDefn { // xxx ??? details: Arc, - info: Arc, + info: Arc, } -#[derive(Debug,Deserialize)] -#[derive(Serialize)] // xxx -pub struct LibraryGroupInfo { - outline: Box, +#[derive(Debug,Deserialize,Serialize)] +pub struct GroupInfo { + outline: Box, size: Vec, #[serde(default="num_traits::identities::One::one")] scale: f64, @@ -36,8 +41,7 @@ pub struct LibraryGroupInfo { } #[derive(Debug,Deserialize)] -#[derive(Serialize)] // xxx -struct LibraryGroupSpec { +struct GroupDefn { #[serde(default)] item_prefix: String, #[serde(default)] item_suffix: String, #[serde(default)] stem_prefix: String, @@ -50,19 +54,21 @@ struct LibraryGroupSpec { #[derive(Deserialize,Debug)] #[serde(try_from="String")] #[derive(Serialize)] // xxx -struct FileList (Vec); +struct FileList (Vec); #[derive(Deserialize,Debug)] #[derive(Serialize)] // xxx -struct FileEntry { +struct FileInfo { item_spec: String, r_file_spec: String, desc: Html, } +trait Outline { } + //#[typetag::deserialize] #[typetag::serde] // xxx -trait OutlineSpec : Debug + Sync + Send { +trait OutlineDefn : Debug + Sync + Send { fn check(&self, lgi: &LibraryGroupInfo) -> Result<(),LibraryLoadError>; } @@ -95,13 +101,13 @@ type TV = toml::Value; type SE = SpecError; #[derive(Debug,Serialize,Deserialize)] -pub struct LibPieceSpec { +pub struct LibPieceSpec { // xxx rename, see above lib: String, item: String, } #[derive(Debug,Serialize,Deserialize)] -struct LibraryItem { +struct Item { // xxx totally redo the contents svg: Html, details: Arc, info: Arc, -- 2.30.2