summaryrefslogtreecommitdiff
path: root/src/encyclopedia.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/encyclopedia.rs')
-rw-r--r--src/encyclopedia.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/encyclopedia.rs b/src/encyclopedia.rs
index 7b40373..8de5424 100644
--- a/src/encyclopedia.rs
+++ b/src/encyclopedia.rs
@@ -5,7 +5,9 @@ use crate::{
assemblage::Assemblage,
componentwrapper::PreEntity,
Template,
- template::EntityType
+ template::EntityType,
+ Result,
+ aerr
};
#[derive(Default, Clone)]
@@ -15,16 +17,16 @@ pub struct Encyclopedia {
impl Encyclopedia {
- pub fn from_json(val: Value) -> Result<Encyclopedia, &'static str> {
+ pub fn from_json(val: Value) -> Result<Encyclopedia> {
let mut items = HashMap::new();
- for (k, v) in val.as_object().ok_or("encyclopedia not a json object")?.into_iter() {
+ for (k, v) in val.as_object().ok_or(aerr!("encyclopedia not a json object"))?.into_iter() {
items.insert(EntityType(k.clone()), Assemblage::from_json(v)?);
}
Ok(Encyclopedia{items})
}
- pub fn construct(&self, template: &Template) -> Result<PreEntity, &'static str> {
- let assemblage = self.items.get(&template.name).ok_or("unknown assemblage name")?;
+ pub fn construct(&self, template: &Template) -> Result<PreEntity> {
+ let assemblage = self.items.get(&template.name).ok_or(aerr!("unknown assemblage name"))?;
assemblage.instantiate(template)
}