Skip to main content

MapMapping

Struct MapMapping 

Source
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 logic or "unset": true, never both;
  • on_null needs logic, 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: Value

JSONLogic 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: bool

Remove 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: OnNull

What a null result from logic does. Defaults to OnNull::Skip, the historical behaviour.

Trait Implementations§

Source§

impl Clone for MapMapping

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MapMapping

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MapMapping

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for MapMapping

Source§

fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.