diff --git a/src/ship/items/actions.rs b/src/ship/items/actions.rs index a5561bc..8e57d79 100644 --- a/src/ship/items/actions.rs +++ b/src/ship/items/actions.rs @@ -18,6 +18,8 @@ use crate::entity::item::ItemModifier; use crate::ship::shops::ShopItem; use crate::ship::drops::{ItemDrop, ItemDropType}; +type BoxFuture = Pin + Send>>; + pub enum TriggerCreateItem { Yes, No @@ -27,7 +29,7 @@ pub(super) fn take_item_from_floor( character_id: CharacterEntityId, item_id: ClientItemId ) -> impl Fn((ItemStateProxy, TR), ()) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway + Send, TR: EntityGatewayTransaction + 'static, @@ -46,7 +48,7 @@ where pub(super) fn add_floor_item_to_inventory( character: &CharacterEntity ) -> impl Fn((ItemStateProxy, TR), FloorItem) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + Clone + 'static, @@ -96,7 +98,7 @@ pub(super) fn take_item_from_inventory( item_id: ClientItemId, amount: u32, ) -> impl Fn((ItemStateProxy, TR), ()) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -120,7 +122,7 @@ pub(super) fn add_inventory_item_to_shared_floor( map_area: MapArea, drop_position: (f32, f32, f32), ) -> impl Fn((ItemStateProxy, TR), InventoryItem) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -153,7 +155,7 @@ pub(super) fn take_meseta_from_inventory( character_id: CharacterEntityId, amount: u32, ) -> impl Fn((ItemStateProxy, TR), ()) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -174,7 +176,7 @@ pub(super) fn add_meseta_to_inventory( character_id: CharacterEntityId, amount: u32 ) -> impl Fn((ItemStateProxy, TR), ()) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -197,7 +199,7 @@ pub(super) fn add_meseta_to_shared_floor( map_area: MapArea, drop_position: (f32, f32) ) -> impl Fn((ItemStateProxy, TR), ()) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -226,7 +228,7 @@ pub(super) fn take_meseta_from_bank( character_id: CharacterEntityId, amount: u32, ) -> impl Fn((ItemStateProxy, TR), ()) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -246,7 +248,7 @@ pub(super) fn add_meseta_from_bank_to_inventory( character_id: CharacterEntityId, amount: u32, ) -> impl Fn((ItemStateProxy, TR), ()) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -267,7 +269,7 @@ pub(super) fn add_meseta_to_bank( character_id: CharacterEntityId, amount: u32, ) -> impl Fn((ItemStateProxy, TR), ()) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -289,7 +291,7 @@ pub(super) fn take_item_from_bank( item_id: ClientItemId, amount: u32, ) -> impl Fn((ItemStateProxy, TR), ()) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -309,7 +311,7 @@ where pub(super) fn add_bank_item_to_inventory( character: &CharacterEntity, ) -> impl Fn((ItemStateProxy, TR), BankItem) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -360,7 +362,7 @@ where pub(super) fn add_inventory_item_to_bank( character_id: CharacterEntityId, ) -> impl Fn((ItemStateProxy, TR), InventoryItem) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -396,7 +398,7 @@ pub(super) fn equip_inventory_item( item_id: ClientItemId, equip_slot: u8, ) -> impl Fn((ItemStateProxy, TR), ()) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -418,7 +420,7 @@ pub(super) fn unequip_inventory_item( character_id: CharacterEntityId, item_id: ClientItemId, ) -> impl Fn((ItemStateProxy, TR), ()) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -441,7 +443,7 @@ pub(super) fn sort_inventory_items( character_id: CharacterEntityId, item_ids: Vec, ) -> impl Fn((ItemStateProxy, TR), ()) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -463,7 +465,7 @@ where pub(super) fn use_consumed_item( character: CharacterEntity, ) -> impl Fn((ItemStateProxy, TR), InventoryItem) - -> Pin), ItemStateError>> + Send>> + -> BoxFuture), ItemStateError>> where EG: EntityGateway + Clone + 'static, TR: EntityGatewayTransaction + 'static, @@ -489,7 +491,7 @@ pub(super) fn feed_mag_item( character: CharacterEntity, mag_item_id: ClientItemId, ) -> impl Fn((ItemStateProxy, TR), InventoryItem) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -605,7 +607,7 @@ where pub(super) fn sell_inventory_item( character_id: CharacterEntityId, ) -> impl Fn((ItemStateProxy, TR), InventoryItem) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -645,7 +647,7 @@ where T: Clone + Send + Sync, F: Fn(I) -> FR + Send + Sync + Clone + 'static, FR: Fn((ItemStateProxy, TR), T) - -> Pin> + Send>> + Send + Sync, + -> BoxFuture> + Send + Sync, { let item = match input.pop() { Some(item) => item, @@ -661,11 +663,11 @@ where Ok((state, output)) } -pub(super) fn iterate<'k, EG, TR, I, O, T, F, FR>( +pub(super) fn iterate( input: Vec, func: F, ) -> impl Fn((ItemStateProxy, TR), T) - -> Pin), ItemStateError>> + Send>> + -> BoxFuture), ItemStateError>> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -674,7 +676,7 @@ where T: Send + Clone + 'static + std::fmt::Debug, F: Fn(I) -> FR + Send + Sync + Clone + 'static, FR: Fn((ItemStateProxy, TR), T) - -> Pin> + Send>> + Send + Sync, + -> BoxFuture> + Send + Sync, T: Clone + Send + Sync, { move |(item_state, transaction), arg| { @@ -701,7 +703,7 @@ where O: Send, T: Clone + Send, F: Fn((ItemStateProxy, TR), T) - -> Pin> + Send>> + Send + Sync, + -> BoxFuture> + Send + Sync, F: Clone, { let item = match input.pop() { @@ -717,17 +719,17 @@ where Ok((state, output)) } -pub(super) fn foreach<'k, EG, TR, O, T, F>( +pub(super) fn foreach( func: F ) -> impl Fn((ItemStateProxy, TR), Vec) - -> Pin), ItemStateError>> + Send>> + -> BoxFuture), ItemStateError>> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, O: Send, T: Send + Clone + 'static + std::fmt::Debug, F: Fn((ItemStateProxy, TR), T) - -> Pin> + Send>> + Send + Sync + 'static, + -> BoxFuture> + Send + Sync + 'static, F: Clone, T: Clone + Send + Sync, { @@ -760,7 +762,7 @@ where pub(super) fn add_item_to_inventory( character: CharacterEntity, ) -> impl Fn((ItemStateProxy, TR), InventoryItem) - -> Pin> + Send>> + Clone + -> BoxFuture> + Clone where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -790,7 +792,7 @@ pub(super) fn record_trade( character_to: CharacterEntityId, character_from: CharacterEntityId, ) -> impl Fn((ItemStateProxy, TR), Vec) - -> Pin), ItemStateError>> + Send>> + Clone + -> BoxFuture), ItemStateError>> + Clone where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -816,7 +818,7 @@ where pub(super) fn assign_new_item_id( ) -> impl Fn((ItemStateProxy, TR), InventoryItem) - -> Pin> + Send>> + Clone + -> BoxFuture> + Clone where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -834,7 +836,7 @@ pub(super) fn convert_item_drop_to_floor_item( character_id: CharacterEntityId, item_drop: ItemDrop, ) -> impl Fn((ItemStateProxy, TR), ()) - -> Pin> + Send>> + Clone + -> BoxFuture> + Clone where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -935,7 +937,7 @@ where pub(super) fn add_item_to_local_floor( character_id: CharacterEntityId, ) -> impl Fn((ItemStateProxy, TR), FloorItem) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -954,7 +956,7 @@ where pub(super) fn apply_modifier_to_inventory_item( modifier: ItemModifier, ) -> impl Fn((ItemStateProxy, TR), InventoryItem) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static, @@ -977,7 +979,7 @@ where pub(super) fn as_individual_item( ) -> impl Fn((ItemStateProxy, TR), InventoryItem) - -> Pin> + Send>> + -> BoxFuture> where EG: EntityGateway, TR: EntityGatewayTransaction + 'static,