TraceContext.TraceState.truncate: def of bend-trace-context@0.2.0.0 Import: import bend-trace-context@0.2.0.0/trace_context.bend as TraceContext Lines 2487-2496 of bend-trace-context@0.2.0.0/trace_context.bend: https://jend.leeeet.dev/read.txt?path=bend-trace-context@0.2.0.0/trace_context.bend&start_line=2487&end_line=2496 import Base # Fit a state to the output budget of `limits` by removing whole entries # (W3C 3.3.3.1, spec #1): while the value is over the budget, remove the # rightmost entry larger than 128 octets, or the rightmost entry when none is, # and stop as soon as it fits. The surviving entries keep their order (laws # truncate_steps, truncate_fits, truncate_whole, truncate_order and # truncate_dropped). def TraceState.truncate(limits: Limits, state: TraceState) -> Truncation: +entries = TraceState.entries(state) +kept = Entries.truncate(List.length(&2, StateEntry, entries), Limits.tracestate_output(limits), entries) Truncation{TraceState.from_entries(kept, TraceState.empty()), Entries.dropped(entries, kept)} Uses (11): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.length https://jend.leeeet.dev/definition.txt?path=bend-trace-context@0.2.0.0/trace_context.bend&name=Entries.dropped https://jend.leeeet.dev/definition.txt?path=bend-trace-context@0.2.0.0/trace_context.bend&name=Entries.truncate https://jend.leeeet.dev/definition.txt?path=bend-trace-context@0.2.0.0/trace_context.bend&name=Limits https://jend.leeeet.dev/definition.txt?path=bend-trace-context@0.2.0.0/trace_context.bend&name=Limits.tracestate_output https://jend.leeeet.dev/definition.txt?path=bend-trace-context@0.2.0.0/trace_context.bend&name=StateEntry https://jend.leeeet.dev/definition.txt?path=bend-trace-context@0.2.0.0/trace_context.bend&name=TraceState https://jend.leeeet.dev/definition.txt?path=bend-trace-context@0.2.0.0/trace_context.bend&name=TraceState.empty https://jend.leeeet.dev/definition.txt?path=bend-trace-context@0.2.0.0/trace_context.bend&name=TraceState.entries https://jend.leeeet.dev/definition.txt?path=bend-trace-context@0.2.0.0/trace_context.bend&name=TraceState.from_entries https://jend.leeeet.dev/definition.txt?path=bend-trace-context@0.2.0.0/trace_context.bend&name=Truncation