Adds a little more data structure
This commit is contained in:
parent
f2a4db82cb
commit
abada675b0
|
|
@ -554,6 +554,7 @@ version = "0.8.12"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ edition = "2021"
|
|||
criterion = "0.5.1"
|
||||
divan = "0.1.14"
|
||||
serde = { version = "1.0.197", features = ["derive"] }
|
||||
toml = "0.8.12"
|
||||
toml = { version = "0.8.12", features = ["preserve_order"] }
|
||||
|
||||
[profile.dev]
|
||||
debug = 0
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@
|
|||
//!
|
||||
//! The `data_structure` module provides data structures for representing the loaded sections of a character or a model.
|
||||
//!
|
||||
//! To ensure correct usage of all datastructures, the following flow is applied
|
||||
//!
|
||||
//! Data -> CS_Raw -> CS_Empty -> CS_Ready
|
||||
//! -> CH_Raw -> CH_Empty -> CH_Ready
|
||||
|
||||
use serde::Deserialize;
|
||||
use toml::Table;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct GlobalConfig {
|
||||
|
|
@ -29,7 +27,7 @@ struct Config {
|
|||
|
||||
/// The data needed to generate a CharacterSheet this data is not implementation agnostic for now
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct Data {
|
||||
pub struct Data {
|
||||
/// Head section
|
||||
head: String,
|
||||
/// Eventual custom script
|
||||
|
|
@ -42,6 +40,11 @@ struct Data {
|
|||
css_footer: String,
|
||||
}
|
||||
|
||||
// #[derive(Deserialize, Debug)]
|
||||
// pub struct SkillsData {
|
||||
// sections: ,
|
||||
// }
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod tests {
|
||||
// use super::{Config, Data, GlobalConfig};
|
||||
|
|
|
|||
|
|
@ -6,20 +6,36 @@
|
|||
//! Data -> CS_Raw -> CS_Empty -> CS_Ready
|
||||
//! -> CH_Raw -> CH_Ready -^
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{
|
||||
data_structure::Data,
|
||||
loader::{LoadError, SheetModel},
|
||||
};
|
||||
|
||||
/// A raw CharacterSheet, with everything ready to generate all fields
|
||||
pub struct CS_Raw {}
|
||||
pub trait CsRaw {
|
||||
fn from_data(data: &Data) -> Self;
|
||||
fn build(&self) -> impl CsEmpty;
|
||||
}
|
||||
|
||||
/// A build CharacterSheet, ready to be filled with the skills loaded
|
||||
pub struct CS_Empty {}
|
||||
pub trait CsEmpty {
|
||||
fn fill(&self, skills: &impl ChRaw) -> impl ChReady;
|
||||
}
|
||||
|
||||
/// A finished CharacterSheet, ready to be exported
|
||||
pub struct CS_Ready {}
|
||||
pub trait CsReady {
|
||||
fn export<T>(&self, path: T) -> Result<(), LoadError>;
|
||||
}
|
||||
|
||||
/// A raw SkillList, loaded from file, ready to generate all skills
|
||||
pub struct CH_Raw {}
|
||||
pub trait ChRaw {
|
||||
fn from_data(data: &SheetModel) -> impl ChReady;
|
||||
}
|
||||
|
||||
/// A build SkillList, ready to be added to a CharacterSheet
|
||||
pub struct CH_Ready {}
|
||||
pub trait ChReady {}
|
||||
|
||||
/// Can generate a character sheet
|
||||
pub trait Generator {
|
||||
|
|
|
|||
Reference in New Issue