def Context.forward
import bend-trace-context@0.2.0.0/trace_context.bend as TraceContextimport Base
3393# Forward a received context unchanged into a carrier: its context fields are
3394# replaced by the traceparent value of the received pair and by its
3395# tracestate fields joined into one field, and the other fields keep their
3396# order. The pair must be there, its tracestate must fit the output budget of
3397# `limits` whole, and both fields must read back under `limits`; otherwise
3398# forwarding fails with a ForwardError and writes nothing, so a received
3399# traceparent never travels with an edited or truncated tracestate (W3C 3.4).
3400# The pair of a context that extraction accepted is refused only when its
3401# tracestate exceeds the output budget, a context built from parts has no
3402# pair to forward, and forwarding again into the carrier written gives that
3403# carrier again.
3404# Laws: forward_carrier, forward_nothing, forward_from_parts,
3405# forward_too_large, forward_extracted and forward_idempotent.
3406def Context.forward(+limits: Limits, incoming: IncomingContext, carrier: List<&2, Header>) ->
3407 Result<&2, &2, ForwardError, List<&2, Header>>:
3408 Forward.pair(limits, IncomingContext.received(incoming), carrier)