this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Adding serialize function for top-level item struct:

+24 -2
+24 -2
src/item.rs
··· 4 4 pub struct Item { 5 5 id: Uuid, 6 6 quantity: i32, 7 - name: String 7 + name: String, 8 + system: Box<dyn ItemSystem> 8 9 } 9 10 10 - pub trait ItemSystem: Serialize {} 11 + pub trait ItemSystem: Serialize {} 12 + 13 + impl Serialize for Item { 14 + fn serialize(&self) -> Vec<u8> { 15 + #[derive(serde::Serialize)] 16 + struct ItemSerialize { 17 + pub id: String, 18 + pub quantity: i32, 19 + pub name: String, 20 + pub system: Vec<u8> 21 + } 22 + 23 + let item_serialize = ItemSerialize{ 24 + id: self.id.to_string(), 25 + quantity: self.quantity, 26 + name: self.name.to_owned(), 27 + system: self.system.serialize() 28 + }; 29 + 30 + rmp_serde::to_vec(&item_serialize).unwrap() 31 + } 32 + }