INNER CODE UNIT · Rust
new
gosub-io/gosub-engine · crates/gosub_config/src/lib.rs:76
pub fn new(schema: impl IntoIterator<Item = SettingInfo>) -> Self {
Config(Arc::new(RwLock::new(ConfigStore::new(schema))))
}
/// Creates a config from the given schema, backed by `storage` and preloading its settings.
#[must_use]
pub fn with_storage(schema: impl IntoIterator<Item = SettingInfo>, storage: Box<dyn StorageAdapter>) -> Self {
let config = Self::new(schema);
config.set_storage(storage);
config
}
/// Swaps in a new storage adapter, loading its persisted settings over the current ones.
pub fn set_storage(&self, storage: Box<dyn StorageAdapter>) {
self.0.write().set_storage(storage);
}
/// Merges every setting from `other` into this config under an optional namespace.