pub struct TableConfig { /* private fields */ }Expand description
One mod’s settings described by a Schema rather than a type: read
with Load::table_config, followed with TableConfig::on_change.
The file, its stages, the Mods screen and the join values work as they
do for a Config type.
§Examples
use enshwick::config::{Field, Schema, Stage};
fn init(load: &mut enshwick::Load<'_>) -> Result<(), enshwick::Off> {
let limit = Field::new("limit", Stage::Runtime, &4).with_doc("How many.", "");
let (settings, values) = load.table_config(Schema::new("", "config", vec![limit]))?;
assert_eq!(values["limit"].as_integer(), Some(4));
settings.on_change(load, |values| enshwick::info!("limit {}", values["limit"]))
}Implementations§
Source§impl TableConfig
impl TableConfig
Sourcepub fn on_change<F>(&self, load: &mut Load<'_>, handler: F) -> Result<(), Off>
pub fn on_change<F>(&self, load: &mut Load<'_>, handler: F) -> Result<(), Off>
Calls handler with the values in force each time the file changes,
after the console or the Mods screen sets one, and as a world loads
or stops, as Load::on_config_change does for a type: startup
values change only as a world loads or stops, restart values never.
A file that no longer reads or checks is logged and skipped.
§Errors
Off when the loader cannot watch settings.
§Examples
See TableConfig.
Trait Implementations§
Source§impl Clone for TableConfig
impl Clone for TableConfig
Auto Trait Implementations§
impl Freeze for TableConfig
impl RefUnwindSafe for TableConfig
impl Send for TableConfig
impl Sync for TableConfig
impl Unpin for TableConfig
impl UnsafeUnpin for TableConfig
impl UnwindSafe for TableConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more