Skip to main content

Crate tupa_core_macros

Crate tupa_core_macros 

Source
Expand description

Tupã core procedural macro — the pipeline! DSL for defining typed policy pipelines.

This crate implements the pipeline! macro that generates pipeline structs implementing tupa_core::Pipeline, tupa_engine::ExecutorPipeline, and tupa_engine::ParallelPipeline traits.

§Example

use tupa_core::pipeline;

pipeline! {
    name: MyPipeline,
    input: MyInput,
    steps: [
        step("process") { process(input) }
    ],
    constraints: [
        metric("score").ge(0.0)
    ]
}

Inside each step body, input: &MyInput and ctx: &StepContext are both in scope. Use ctx.get_f64("prior_metric") to access outputs of upstream steps without re-computing them.

§Computed constraint thresholds

Constraint thresholds can be arbitrary expressions referencing input:

constraints: [
    metric("equity_floor").ge(0.0),                          // literal
    metric("equity").ge(input.min_equity_usdt).fail_fast(),  // computed, abort-on-fail
]

The macro expands to a struct with associated methods for execution.

Macros§

pipeline
Procedural macro defining a Tupã policy pipeline.
safe
Construct a Safe<f64, Marker>, proving built-in constraints at compile time for constant expressions and falling back to a runtime check otherwise.