Skip to main content

Config

Derive Macro Config 

Source
#[derive(Config)]
{
    // Attributes available to this derive:
    #[config]
}
Expand description

Implements enshwick::config::Config for a struct with named fields.

The settings file a player sees on first start is generated from the type: the struct’s doc comment heads the file, each field’s doc comment precedes its key, and each value comes from Default. Struct attributes: #[config(validate = path)] names a fn(&Self) -> Result<(), E>, E a String, a &str or a ConfigError such as ConfigError::text, that checks parsed values; #[config(text = "key")] the text key of the set’s translated title.

Field attributes: one stage of startup, runtime (the default), restart, client and sync, or the pair startup, sync, applied when a world loads and taken from the server by a joined client; range = a..=b, a.. or ..=b; choices = [..]; text = "key", the text key of the field’s translated label; secret, a value never sent to a client and changed in the file only, so never with sync; group, on a field that is a Config of its own, makes it a table of the file. The derive implements schema, values, merge_values and a validate that checks ranges and choices before the struct’s own check.