pub trait WireFormatAdapter: Send {
// Required methods
fn dialect(&self) -> &'static str;
fn translate(&mut self, event: &FlowExecutionEvent) -> Vec<Event>;
fn flush_terminator(&mut self) -> Vec<Event>;
// Provided method
fn build_complete_envelope_event(
&mut self,
envelope: &CompleteEnvelope,
) -> Vec<Event> { ... }
}Expand description
Wire-format adapter trait — translates internal flow-execution events into per-dialect SSE wire events.
Adapters are stateful — a fresh adapter is constructed per
request via select_adapter. The adapter tracks per-request
state (event ID counter, step index, per-tool-call index, etc.)
internally.
All methods are &mut self to permit internal counter updates.
Adapters MUST be Send so the SSE producer can move them across
the spawn boundary.
Required Methods§
Sourcefn dialect(&self) -> &'static str
fn dialect(&self) -> &'static str
Closed-catalog dialect identifier this adapter implements.
One of "axon", "openai", "anthropic".
Sourcefn translate(&mut self, event: &FlowExecutionEvent) -> Vec<Event>
fn translate(&mut self, event: &FlowExecutionEvent) -> Vec<Event>
Translate a single internal flow-execution event into zero or more wire SSE events.
Returning an empty Vec is valid — some dialects swallow
certain internal events (e.g., openai doesn’t have a per-step
step_start concept; AxonDialectAdapter emits one).
NOTE: the producer calls build_complete_envelope_event()
instead of translate() for FlowComplete so the adapter
receives the full algebraic-policy side-channel data. The
translate(FlowComplete) path is retained for adapters /
callers that don’t have the full envelope available; it
produces a minimal envelope without enforcement_summaries /
runtime_warnings / effect_policies.
Sourcefn flush_terminator(&mut self) -> Vec<Event>
fn flush_terminator(&mut self) -> Vec<Event>
Emit any final terminator frames after the internal
FlowComplete / FlowError event has been translated.
- axon: emits no extra terminator (the
axon.completeevent fromtranslate()is itself the terminator). - openai: emits
data: [DONE]. - anthropic: emits
event: message_stopif not already emitted as part of FlowComplete translation.
Provided Methods§
Sourcefn build_complete_envelope_event(
&mut self,
envelope: &CompleteEnvelope,
) -> Vec<Event>
fn build_complete_envelope_event( &mut self, envelope: &CompleteEnvelope, ) -> Vec<Event>
§Fase 33.z.k.g (v1.28.0) — Build the dialect-specific
“complete” event with the full algebraic-policy side-channel
data accumulated over the flow’s lifetime. The producer calls
this in place of translate(FlowComplete) so adapters can
surface enforcement_summaries / runtime_warnings /
effect_policies per their wire-format conventions.
Default impl: produces the same output as
translate(FlowComplete{...}) reconstructed from the envelope
— adapters that don’t override see the envelope’s flow-level
fields but no side-channel data.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".