diff --git a/weaponry/Cargo.toml b/weaponry/Cargo.toml index 9889c9a..6f59e85 100644 --- a/weaponry/Cargo.toml +++ b/weaponry/Cargo.toml @@ -6,11 +6,12 @@ edition = "2024" [dependencies] comfy-table = "7.1.4" fastrand = "2.3.0" -iter-enum = "1.2.0" +# iter-enum = "1.2.0" pretty_assertions = "1.4.1" probability = "0.20.3" rayon = "1.10.0" rusqlite = { version = "0.33.0", features = ["bundled"] } +serde = { version = "1.0.217", features = ["derive"] } struct-field-names-as-array = "0.3.0" strum = { version = "0.27.0", features = ["derive"] } diff --git a/weaponry/src/interfaces.rs b/weaponry/src/interfaces.rs index 301f250..dd119b9 100644 --- a/weaponry/src/interfaces.rs +++ b/weaponry/src/interfaces.rs @@ -142,7 +142,7 @@ pub trait ToTex { /// This element can be converted to a csv for further analysis pub trait ToAnalysis { /// Convert this object into a csv - fn to_csv(&self) -> String; + fn write_csv(&self) -> String; } /// Garanties that a struct can be generated from a database diff --git a/weaponry/src/weaponry_structs/equipement_fields.rs b/weaponry/src/weaponry_structs/equipement_fields.rs index a352e7e..458b717 100644 --- a/weaponry/src/weaponry_structs/equipement_fields.rs +++ b/weaponry/src/weaponry_structs/equipement_fields.rs @@ -4,9 +4,10 @@ use std::fmt::Display; +use serde::Deserialize; use strum::Display; -#[derive(Clone, Default, Debug)] +#[derive(Clone, Default, Debug, Deserialize)] #[cfg_attr(test, derive(PartialEq))] /// The special category, a vec of string, for display purposes only pub struct SpecialCategory(pub(super) Vec); @@ -24,7 +25,7 @@ pub enum NatureTarget { /// Enum of all different physical weapon damage types #[allow(clippy::missing_docs_in_private_items)] -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Deserialize)] #[cfg_attr(test, derive(PartialEq))] pub enum PhysicalDamageType { Blunt, @@ -43,7 +44,7 @@ impl From<&str> for PhysicalDamageType { /// /// Signifying wether the damage is pure or [secondary] or [[tertiary]] #[allow(clippy::missing_docs_in_private_items, missing_docs)] -#[derive(Clone, Debug, Display)] +#[derive(Clone, Debug, Display, Deserialize)] #[cfg_attr(test, derive(PartialEq))] pub enum DamageMod { Primary(PhysicalDamageType), @@ -62,7 +63,7 @@ impl From<&str> for DamageMod { /// Combined damage type, as a vector of all damage types /// /// Meant to be serialised to tex and deserialized directly from the table -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Deserialize)] #[cfg_attr(test, derive(PartialEq))] pub struct DamageType(pub(super) Vec); @@ -88,7 +89,7 @@ impl Display for DamageType { /// List all weapon categories #[allow(clippy::missing_docs_in_private_items, missing_docs)] -#[derive(Clone, Debug, PartialEq, Display)] +#[derive(Clone, Debug, PartialEq, Display, Deserialize)] // #[cfg_attr(test, derive(PartialEq))] pub enum WeaponCategory { Exotic, diff --git a/weaponry/src/weaponry_structs/equipement_impl_io.rs b/weaponry/src/weaponry_structs/equipement_impl_io.rs index 14c7ccd..c4f84eb 100644 --- a/weaponry/src/weaponry_structs/equipement_impl_io.rs +++ b/weaponry/src/weaponry_structs/equipement_impl_io.rs @@ -2,6 +2,18 @@ // File: weaponry/src/weaponry_structs/equipement_impl_io.rs //! All implementation IO specific (mainly export and serde) +// impl ToAnalysis for RefinedEquipementList{ +// fn write_csv(&self) -> String { +// let mut wtr = csv::Writer::from_writer(); +// } +// } + +// impl ToAnalysis for RefinedEquipement { +// fn write_csv(&self) -> String { + +// } +// } + #[cfg(test)] mod test { // use super::*; diff --git a/weaponry/src/weaponry_structs/equipement_structs.rs b/weaponry/src/weaponry_structs/equipement_structs.rs index 1a6b4de..480caab 100644 --- a/weaponry/src/weaponry_structs/equipement_structs.rs +++ b/weaponry/src/weaponry_structs/equipement_structs.rs @@ -4,6 +4,7 @@ use std::rc::Rc; +use serde::Deserialize; use struct_field_names_as_array::FieldNamesAsArray; use crate::interfaces::{FilterFunction, FilterFunctionType}; @@ -55,7 +56,7 @@ impl FilterFunction { /// The inner statistics of the equipement, used across all parts and final weapon #[allow(clippy::missing_docs_in_private_items, missing_docs)] -#[derive(Clone, Default, FieldNamesAsArray, Debug)] +#[derive(Clone, Default, FieldNamesAsArray, Debug, Deserialize)] #[cfg_attr(test, derive(PartialEq))] pub struct InnerEquipementStats { pub id: Vec,