use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct StateStore {
domains: BTreeMap<String, Value>,
}
impl StateStore {
#[must_use]
pub fn new() -> Self {
Self::default()
}
pub fn set(&mut self, key: impl Into<String>, value: Value) {
self.domains.insert(key.into(), value);
}
#[must_use]
pub fn get(&self, key: &str) -> Option<&Value> {
self.domains.get(key)
}
pub fn remove(&mut self, key: &str) -> Option<Value> {
self.domains.remove(key)
}
#[must_use]
pub fn is_empty(&self) -> bool {
self.domains.is_empty()
}
#[must_use]
#[allow(clippy::missing_const_for_fn)]
pub fn domains(&self) -> &BTreeMap<String, Value> {
&self.domains
}
}