Skip to main content

ConfigPatch

Derive Macro ConfigPatch 

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

Generate a sparse typed patch alongside a named configuration struct.

Use #[config_patch(name = CustomPatch)] on the struct to override the generated patch name. Fields marked #[config_patch(nested)] recursively use the patch generated for their type, including optional nested structs. Updating an absent optional nested value starts from its default. Fields marked #[config_patch(merge)] use std::iter::Extend semantics, while #[config_patch(merge_with = path)] delegates to a function taking (&mut T, T). Merge fields also expose replace_* methods. Every field exposes clear_*, which removes that pending change from the patch without changing the target. Other fields are atomic: absence leaves the target unchanged and presence replaces the field, including vectors and maps.