def Context.root_with
import bend-trace-context@0.2.0.0/trace_context.bend as TraceContextimport Base
1518# Generated contexts from a caller's source. `read` returns the source's next
1519# state with each word result. The source is trusted to be random: a generated
1520# trace ID asserts random-trace-id. A root is a trace ID, with none to
1521# exclude, then a span ID: TraceId.generate_with, then SpanId.generate_with
1522# from the source's next state (TracePlan.root and TracePlan.generate_with).
1523# It reads at most 48 words and has the sampled indication `sampled`, as it
1524# is given: no default applies here, and False gives an unsampled root,
1525# emitted with flags 02, as Context.continue_or_start_with starts one by
1526# default (spec #41, "Sampling decision when starting a trace"). Laws:
1527# root_composed, root_tape, root_ends, root_exhaustion and generated_root.
1528def Context.root_with(~S: Type, ~read: S -> IO(S & Result<&1, &1, U32 & String, U32>), source: S, sampled: Bool) ->
1529 IO(S & Result<&2, &2, GenerationError, LocalContext>):
1530 TracePlan.generate_with(~S, ~read, source, TracePlan.root(sampled))