pub struct MapMapping {
pub path: PathTemplate<ContextRoot>,
pub logic: Value,
pub unset: bool,
pub on_null: OnNull,
/* private fields */
}Expand description
A single mapping that transforms and assigns data — or, with
unset, removes it.
Three rules hold between the keys, and a definition breaking one fails to
parse (so Workflow::validate_authored
reports it as IssueCode::InvalidMapping
and Engine::build refuses it):
- a mapping has
logicor"unset": true, never both; on_nullneedslogic, since it says what a null result does;- a removal may not name a context root (
data,metadata,temp_data). A literal path is checked here; a computed one that resolves to a root fails that mapping at run time instead.
Fields§
§path: PathTemplate<ContextRoot>Target path where the result will be stored (e.g., "data.user.name").
Supports dot notation for nested paths and # prefix for numeric field
names.
JSONLogic, so a mapping can compute where it writes:
{"cat": ["data.accounts.", {"var": "data.id"}, ".balance"]}. The
static spelling is a literal string, which folds at compile time and
keeps the precomputed split this hot loop has always used — a dynamic
path is the only one that pays to split per write.
logic: ValueJSONLogic expression (kept as serde_json::Value since this is the
shape the compiler accepts; not runtime data).
Value::Null on an unset mapping, which has none.
unset: boolRemove the key at path instead of writing to it. Takes no logic.
A no-op when the key is already absent. A removal is recorded on the
audit trail as a Change with removed set.
This exists because null cannot mean “clear”: a null result is
skipped (see OnNull::Skip), which is what lets
{"if": [cond, value, null]} mean “set or keep”.
on_null: OnNullWhat a null result from logic does. Defaults to
OnNull::Skip, the historical behaviour.