diff options
| author | troido <troido@protonmail.com> | 2020-09-25 14:18:13 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-09-25 14:18:13 +0200 |
| commit | 87727f9519eb37b565d8cc88e174935bac0e1d12 (patch) | |
| tree | 78eb9daaf511b9eeeb8f0eef197556f0353582e1 /src/componentwrapper.rs | |
| parent | 09306cb76c6e1eabb4082a985a0a0fa335bda5c1 (diff) | |
assemlage uses proper serialization too
Diffstat (limited to 'src/componentwrapper.rs')
| -rw-r--r-- | src/componentwrapper.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/componentwrapper.rs b/src/componentwrapper.rs index 320ae1b..340d0c0 100644 --- a/src/componentwrapper.rs +++ b/src/componentwrapper.rs @@ -1,6 +1,7 @@ use std::collections::{HashMap, HashSet}; -use serde::Deserialize; +use serde::{Serialize, Deserialize}; +use strum_macros::{EnumString, Display}; use specs::Builder; use rand::Rng; use std::str::FromStr; @@ -65,21 +66,13 @@ macro_rules! components { } } } - #[derive(Debug, PartialEq, Eq, Clone, Copy, Deserialize)] + #[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, EnumString, Display)] pub enum ComponentType { $( $comp, )* } impl ComponentType { - pub fn from_str(typename: &str) -> Option<ComponentType>{ - match typename { - $( - stringify!($comp) => Some(Self::$comp), - )* - _ => None - } - } pub fn parameters(&self) -> Vec<&str> { match self { $( |
