From 2d5f83fab6e122ea3830e9fa39d11b3a1bc99c33 Mon Sep 17 00:00:00 2001 From: jake Date: Mon, 9 Nov 2020 18:54:44 -0700 Subject: [PATCH] make inv item stuff serializable --- src/entity/item/mod.rs | 8 ++++---- src/ship/items/mod.rs | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/entity/item/mod.rs b/src/entity/item/mod.rs index a1aa305..22e2913 100644 --- a/src/entity/item/mod.rs +++ b/src/entity/item/mod.rs @@ -17,10 +17,10 @@ use crate::ship::drops::ItemDropType; pub struct ItemEntityId(pub u32); #[derive(Hash, PartialEq, Eq, Debug, Clone)] pub struct ItemId(u32); -#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] pub struct BankName(pub String); -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum ItemLocation { Inventory { character_id: CharacterEntityId, @@ -167,7 +167,7 @@ pub struct NewItemEntity { pub item: ItemDetail, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct ItemEntity { pub id: ItemEntityId, pub location: ItemLocation, @@ -175,7 +175,7 @@ pub struct ItemEntity { } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub enum InventoryItemEntity { Individual(ItemEntity), Stacked(Vec), diff --git a/src/ship/items/mod.rs b/src/ship/items/mod.rs index 3268b04..facbc11 100644 --- a/src/ship/items/mod.rs +++ b/src/ship/items/mod.rs @@ -3,8 +3,9 @@ mod floor; mod inventory; mod manager; pub mod use_tool; +use serde::{Serialize, Deserialize}; -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)] pub struct ClientItemId(pub u32); // TODO: remove these and fix use statements in the rest of the codebase