def TraceParent.read
import bend-trace-context@0.2.0.0/trace_context.bend as TraceContextimport Base
2931# Read one received traceparent value by the rules of a participant, and
2932# return its known fields as a v00 value, flag byte included:
2933# - a value over the traceparent input budget of `limits`, counted in UTF-8
2934# octets with its whitespace, is refused with TraceParentTooLarge;
2935# - optional whitespace around the value is removed (RFC 9110, section 5.5);
2936# - a value with a comma joins repeated fields and is refused with
2937# RepeatedTraceParent, even when the comma is in fields of a later
2938# version: no version defines a comma, and a host that joins repeated
2939# fields separates them with one (RFC 9110, section 5.3);
2940# - version 00 is read exactly by TraceParentV00.parse: 55 characters and
2941# nothing after them;
2942# - version ff is refused with ForbiddenVersion (W3C 3.2.2.1);
2943# - versions 01 to fe are read by their known prefix: the fields of version
2944# 00, followed by the end of the value or by a dash and fields that are
2945# not read, whatever they hold other than a comma or a control character,
2946# which is refused with ControlCharacter (W3C 3.2.4 and 4.1.2; RFC 9110,
2947# section 5.5).
2948# RemoteContext.from_traceparent then keeps the sampled and random-trace-id
2949# flags. Laws: read_v00, read_v00_exact, read_future, read_ff, read_comma,
2950# read_over_budget and read_within_budgets.
2951def TraceParent.read(limits: Limits, +value: String) -> Result<&2, &2, TraceParentError, TraceParentV00>:
2952 Read.within(Utf8.left(value, Some{Limits.traceparent_input(limits)}), value)