def TraceDraw.take

bend-trace-context@0.2.0.0 · trace_context.bend:1057

import bend-trace-context@0.2.0.0/trace_context.bend as TraceContext
import Base

1057# Add a word to the current trace ID candidate. The fourth word completes it,
1058# most significant first, and the candidate is checked.
1059def TraceDraw.take(word: U32, remaining: Nat, words: TraceWords, excluded: Maybe<&2, TraceId>) -> TraceStep:
1060  match words:
1061    case NoTraceWord{}:
1062      NeedTraceWord{TraceDraw{remaining, OneTraceWord{word}, excluded}}
1063    case OneTraceWord{first}:
1064      NeedTraceWord{TraceDraw{remaining, TwoTraceWords{first, word}, excluded}}
1065    case TwoTraceWords{first, second}:
1066      NeedTraceWord{TraceDraw{remaining, ThreeTraceWords{first, second, word}, excluded}}
1067    case ThreeTraceWords{first, second, third}:
1068      TraceDraw.check(Draw.asserted(TraceId.from_words(first, second, third, word)), excluded, remaining)

Uses (10)

Used by (1)