Implements Deserialize

This commit is contained in:
Dandaedre 2025-02-14 22:37:17 +01:00
parent a5f796d2dd
commit 26d22037ae
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
5 changed files with 23 additions and 8 deletions

View File

@ -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"] }

View File

@ -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

View File

@ -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<String>);
@ -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<DamageMod>);
@ -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,

View File

@ -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::*;

View File

@ -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<T> FilterFunction<T> {
/// 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<u8>,