Context + Stream + Collector + EnvironmentRuntime values and outputs
Core Rust values passed into makers, operators, and endpoint handlers. These are the stable application-facing handles to the generated runtime.
When to use
Use this page while implementing a generated business function or endpoint handler.
Behavior
- Contexts carry cancellation and correlation across graph boundaries.
- Collectors and stream contexts are the supported way to emit values; calling downstream functions directly bypasses graph semantics and observability.
- The service environment is supplied during construction so business implementations can create scoped metrics, obtain loggers, and resolve configured dependencies.
Core runtime types
Types normally visible in preserved implementation signatures.
MessageContextPer-message contextCarries cancellation and correlation metadata. Pass ownership into collect so downstream tasks receive the same context.
&dyn RuntimeStreamStream metadataProvides the current generated stream through a trait object without exposing its concrete implementation.
Collector<T>Operator outputcollect(context, value).await forwards an owned value; clone only when business logic must retain another copy.
StreamContext<T, R, E>Source endpoint contextcollect and error_collect emit typed values into the graph.
SinkStreamContext<T, R, E>Sink endpoint contextEmits typed transport results and endpoint errors.
Payload<T>Shared payloadUses Arc<T> semantics so graph fan-out can share immutable values efficiently.
RuntimeEnvironmentMaker dependencyCloneable handle to runtime configuration, logging, metrics, tracing, and dependencies.
RuntimeResult<T>Construction resultReturns the implementation or a startup error from a maker.
Generated extension pattern
stream.collect(context, value).await;
stream.error_collect(context, error).await;
out.collect(context, result).await;