INNER CODE UNIT · Rust
with_storage
gosub-io/gosub-engine · crates/gosub_config/src/lib.rs:82
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.
///
/// Each of `other`'s settings is registered here as `"{namespace}.{key}"` (or bare `key` when
/// `namespace` is empty), carrying over its description, default, constraint and current value.
/// One-time snapshot, not a live link: later changes in `other` are not reflected here. Keys
/// that already exist are left untouched (and logged). Merged settings are not written to this
/// config's storage adapter unless later `set`. Returns the number of settings merged.