#[derive(FunctionConfig)]
{
// Attributes available to this derive:
#[config]
#[output]
}
Expand description
Derives FunctionConfig (and ConfigField, so a
derived config nests).
Derives FunctionConfig for a function’s typed configuration, and
ConfigField, so a derived config nests inside another.
It applies to a struct with named fields. Each field is compiled from the
key of its name through the field type’s ConfigField implementation,
every issue at its own path, unknown keys first.
| Attribute | On | Meaning |
|---|---|---|
#[config(rename = "k")] | field | The JSON key; the default is the field’s name |
#[config(default = <literal>)] | field | A string, integer, float or bool, compiled through the field’s type when the key is absent |
#[config(default_json = "<json>")] | field | Any JSON default, as text; text that is not JSON is a compile error |
#[config(serde)] | field | Read with serde_json; an error is INPUT_PARSE, and an absent key is read from null. Resolved as it serializes, so the type is Serialize too |
#[config(records)] | field | The engine records the field’s result; inherited by everything below it |
#[output(default = "p")] | output | The default when the key is absent or null |
#[output(primary)] | output | Required on exactly one output when there are several |
#[config(check = path)] | struct | fn(&Self, &mut CompileCx<'_>), called only when every field compiled |
A field is an output when it carries #[output(...)], or its type’s last
path segment is Output, or it is an Option of such a type. A field’s
doc comment is its description.
The primary output, the one marked or the only one, is what
FunctionConfig::primary_output returns, so its type is Output or
Option<Output>; any other is refused.
FunctionConfig::resolve gives every field with a value, set by the
input or by its default, keyed by its key, in declaration order, each
through its type’s ConfigField::resolve, and a serde field as it
serializes; an Option left unset is absent.