pub struct CarryContract { /* private fields */ }Expand description
The carry a workloop threads from one generation to the next, and the DEFAULTS that seed generation 1 (R-carry).
§🔴 WHY DEFAULTS ARE A CONTRACT AND NOT A CONVENIENCE
A workloop’s iteration body reads its carry fields unconditionally — the
generated input codec requires them. Every generation after the first gets
them from the previous iteration’s route start payload. Generation 1 has
no previous iteration, so unless something seeds those fields the very
first run of a loop fails to decode its own input: a start payload that
passes schema admission and is then unreadable by the workflow it was
admitted for.
Seeding is therefore the engine’s job at the START, not the author’s job at every call site — an operator starting a loop cannot be expected to know which fields the compiled codec will demand.
§🔴 CALLER VALUES WIN
The merge is default-filling, never overwriting: a field the caller supplied keeps the caller’s value. A default that clobbered an explicit start value would make the declaration silently override the operator.
Implementations§
Source§impl CarryContract
impl CarryContract
Sourcepub fn new(defaults: BTreeMap<String, Value>) -> Result<Self, WorkloopSpecError>
pub fn new(defaults: BTreeMap<String, Value>) -> Result<Self, WorkloopSpecError>
Builds a carry contract from declared field defaults.
§Errors
Refuses an empty field name (WorkloopSpecError::EmptyCarryField).
Sourcepub fn seed(&self, input: &Payload) -> Result<Payload, WorkloopSpecError>
pub fn seed(&self, input: &Payload) -> Result<Payload, WorkloopSpecError>
Merge the declared defaults into a generation-1 start payload.
Returns the payload unchanged when nothing is declared. Caller-supplied fields are preserved; only ABSENT fields are filled.
§Errors
Refuses a start payload that is not a JSON object
(WorkloopSpecError::CarrySeedTargetNotAnObject) — there is nowhere
to put a named field in a scalar or an array, and silently dropping the
seed would reproduce the very decode failure seeding exists to prevent.
Trait Implementations§
Source§impl Clone for CarryContract
impl Clone for CarryContract
Source§fn clone(&self) -> CarryContract
fn clone(&self) -> CarryContract
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more