spin_factor_key_value/
runtime_config.rspub mod spin;
use std::{collections::HashMap, sync::Arc};
use crate::StoreManager;
#[derive(Default, Clone)]
pub struct RuntimeConfig {
store_managers: HashMap<String, Arc<dyn StoreManager>>,
}
impl RuntimeConfig {
pub fn add_store_manager(&mut self, label: String, store_manager: Arc<dyn StoreManager>) {
self.store_managers.insert(label, store_manager);
}
pub fn has_store_manager(&self, label: &str) -> bool {
self.store_managers.contains_key(label)
}
pub fn get_store_manager(&self, label: &str) -> Option<Arc<dyn StoreManager>> {
self.store_managers.get(label).cloned()
}
}
impl IntoIterator for RuntimeConfig {
type Item = (String, Arc<dyn StoreManager>);
type IntoIter = std::collections::hash_map::IntoIter<String, Arc<dyn StoreManager>>;
fn into_iter(self) -> Self::IntoIter {
self.store_managers.into_iter()
}
}