Unsure about some deep dependencies

This commit is contained in:
Dandaedre 2025-02-28 19:58:46 +01:00
parent eaed13f320
commit 4380ad5591
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
2 changed files with 36 additions and 8 deletions

View File

@ -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 <<<Self as Scenario>::InitialEquipementListType as RecipeCollection>::Recipes as Combinable>::Inner: std::ops::Add
// where
// for<'a> &'a <<Self as Scenario>::Recipe as Combinable>::Inner: std::ops::Add, for<'a> &'a <<<Self as Scenario>::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<impl RecipeCollection<Recipes = Self::Recipe>>;
// /// The inner element that all serialised data will be serialized into after the intermediate step
// type Recipe;
// for<'a> &'a <<Self as RecipeCollection>::Recipes as Combinable>::Inner: std::ops::Add,
/// Create a Scenario from a given config
fn new_with_config(config: Self::Config) -> Result<Self, FatalEquipementError>
@ -296,7 +304,25 @@ pub trait Scenario {
fn deserde_into_equipement<T>(
&self,
filter: Option<&str>,
) -> Result<InitialEquipementList, FatalEquipementError>
) -> Result<Self::InitialEquipementListType, FatalEquipementError>
where
T: From<Self::InitialEquipementType> + Into<Self::Recipe>;
T: From<Self::InitialEquipementType>
+ Into<<<Self as Scenario>::InitialEquipementListType as RecipeCollection>::Recipes>;
// /// Automatically deserialize into an equipement
// // TODO: Add to trait
// // TODO: Add an optionnal initial filter ?
// fn deserde_into_equipement<T>(
// &self,
// filter: Option<&str>,
// ) -> Result<Self::InitialEquipementListType, FatalEquipementError>
// where
// T: From<Self::InitialEquipementType> + Into<<<Self as Scenario>::InitialEquipementType as RecipeCollection>::Recipes>,
// <Self as Scenario>::InitialEquipementListType: RecipeCollection,
// {
// RecipeCollection::from_iter_intermediate::<T>(
// self.get_database()
// .serialise_into_intermediate::<T>(self.get_tablename(), filter)?,
// )
// }
}

View File

@ -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<Self, FatalEquipementError>
where
@ -140,9 +141,10 @@ impl Scenario for CrossRecipeScenario {
fn deserde_into_equipement<T>(
&self,
filter: Option<&str>,
) -> Result<InitialEquipementList, FatalEquipementError>
) -> Result<Self::InitialEquipementListType, FatalEquipementError>
where
T: From<<CrossRecipeScenario as Scenario>::InitialEquipementType> + Into<Equipement>,
T: From<Self::InitialEquipementType>
+ Into<<<Self as Scenario>::InitialEquipementListType as RecipeCollection>::Recipes>,
{
RecipeCollection::from_iter_intermediate::<T>(
self.get_database()