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 actor struct

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