use std::collections::HashMap;
use std::sync::{Arc, RwLock};
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum FeatureValue {
String(String),
Integer(i64),
Boolean(bool),
}
#[derive(Clone, Debug, Default)]
pub struct World {
features: Arc<RwLock<HashMap<String, FeatureValue>>>,
}
impl World {
#[must_use]
pub fn new() -> Self {
Self::default()
}
pub fn set_feature(&self, iri: impl Into<String>, value: FeatureValue) {
self.features
.write()
.expect("world feature lock poisoned")
.insert(iri.into(), value);
}
#[must_use]
pub fn feature(&self, iri: &str) -> Option<FeatureValue> {
self.features
.read()
.expect("world feature lock poisoned")
.get(iri)
.cloned()
}
}