diff --git a/weaponry/src/interfaces.rs b/weaponry/src/interfaces.rs index 5d4badf..326b3f1 100644 --- a/weaponry/src/interfaces.rs +++ b/weaponry/src/interfaces.rs @@ -264,7 +264,10 @@ pub trait Reportable { /// A recipe full stack scenario, from loading database through view table generation /// /// The inner working while somehow abstracted are very tied together and tied to the impl -pub trait Scenario { +pub trait Scenario where for<'a> &'a <<::InitialEquipementListType as RecipeCollection>::Recipes as Combinable>::Inner: std::ops::Add +// where +// for<'a> &'a <::Recipe as Combinable>::Inner: std::ops::Add, for<'a> &'a <<::InitialEquipementListType as RecipeCollection>::Recipes as Combinable>::Inner: std::ops::Add +{ /// The inner database type type DatabaseType: RecipeDatabase; /// The type of the final recipe list @@ -273,8 +276,13 @@ pub trait Scenario { type Config; /// The initial equipement type, the database serialisation will be to be converted into this type type InitialEquipementType; - /// The inner element that all serialised data will be serialized into after the intermediate step - type Recipe; + /// The initial equipement list, about to be converted into a refined list + type InitialEquipementListType: RecipeCollection; //: Into>; + + // /// The inner element that all serialised data will be serialized into after the intermediate step + // type Recipe; + + // for<'a> &'a <::Recipes as Combinable>::Inner: std::ops::Add, /// Create a Scenario from a given config fn new_with_config(config: Self::Config) -> Result @@ -296,7 +304,25 @@ pub trait Scenario { fn deserde_into_equipement( &self, filter: Option<&str>, - ) -> Result + ) -> Result where - T: From + Into; + T: From + + Into<<::InitialEquipementListType as RecipeCollection>::Recipes>; + + // /// Automatically deserialize into an equipement + // // TODO: Add to trait + // // TODO: Add an optionnal initial filter ? + // fn deserde_into_equipement( + // &self, + // filter: Option<&str>, + // ) -> Result + // where + // T: From + Into<<::InitialEquipementType as RecipeCollection>::Recipes>, + // ::InitialEquipementListType: RecipeCollection, + // { + // RecipeCollection::from_iter_intermediate::( + // self.get_database() + // .serialise_into_intermediate::(self.get_tablename(), filter)?, + // ) + // } } diff --git a/weaponry/src/weaponry_structs/equipement_scenario.rs b/weaponry/src/weaponry_structs/equipement_scenario.rs index 90b6ad3..0d3c736 100644 --- a/weaponry/src/weaponry_structs/equipement_scenario.rs +++ b/weaponry/src/weaponry_structs/equipement_scenario.rs @@ -99,7 +99,8 @@ impl Scenario for CrossRecipeScenario { type FinalListType = RefinedEquipementList; type Config = ConfigEquipementScenario; type InitialEquipementType = InnerEquipementStats; - type Recipe = Equipement; + type InitialEquipementListType = InitialEquipementList; + // type Recipe = Equipement; fn new_with_config(config: Self::Config) -> Result where @@ -140,9 +141,10 @@ impl Scenario for CrossRecipeScenario { fn deserde_into_equipement( &self, filter: Option<&str>, - ) -> Result + ) -> Result where - T: From<::InitialEquipementType> + Into, + T: From + + Into<<::InitialEquipementListType as RecipeCollection>::Recipes>, { RecipeCollection::from_iter_intermediate::( self.get_database()