this repo has no description
2
fork

Configure Feed

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

Modifying top-level game code to call serialization functions

+45 -1
+45 -1
src/lib.rs
··· 1 - use crate::{hooks::Hooks, actor::Actor, item::Item}; 1 + use crate::{hooks::Hooks, actor::Actor, item::Item, traits::Serialize}; 2 2 use std::collections::HashMap; 3 3 use uuid::Uuid; 4 4 use wasm_bindgen::prelude::*; ··· 34 34 hooks: Hooks::new(), 35 35 actors: HashMap::new(), 36 36 items: HashMap::new() 37 + } 38 + } 39 + 40 + fn get_actor(&mut self, uuid: String) -> Option<Vec<u8>> { 41 + match Uuid::parse_str(&uuid) { 42 + Ok(uuid) => { 43 + match self.actors.get_mut(&uuid) { 44 + Some(actor) => { 45 + Some(actor.serialize()) 46 + }, 47 + None => { 48 + println!("Could not find actor {}", uuid); 49 + None 50 + } 51 + } 52 + }, 53 + Err(err) => { 54 + println!("There was an error parsing UUID {}: {}", uuid, err.to_string()); 55 + None 56 + } 57 + } 58 + } 59 + 60 + fn get_hooks(&mut self) -> &mut Hooks { 61 + &mut self.hooks 62 + } 63 + 64 + fn get_item(&mut self, uuid: String) -> Option<Vec<u8>> { 65 + match Uuid::parse_str(&uuid) { 66 + Ok(uuid) => { 67 + match self.items.get_mut(&uuid) { 68 + Some(item) => { 69 + Some(item.serialize()) 70 + }, 71 + None => { 72 + println!("Could not find item {}", uuid); 73 + None 74 + } 75 + } 76 + }, 77 + Err(err) => { 78 + println!("There was an error parsing UUID {}: {}", uuid, err.to_string()); 79 + None 80 + } 37 81 } 38 82 } 39 83 }