pub trait StreamTransformer: Send {
// Required method
fn transform(&mut self, event: Event) -> Vec<Event>;
}Expand description
Rewrites events on their way from an agent to the transport.
§Why &mut self
Any useful transformer is a small state machine: dropping a tool call means
remembering which id was dropped so its TOOL_CALL_ARGS go too. Taking
&mut self says that directly instead of pushing every implementation into
RefCell. The chain is owned by the run, so there is no sharing to lose.
§Contract
Returning an empty Vec drops the event. Returning several events splices
them in, in order. A transformer that drops the start of something must drop
its continuation and terminator too, or the ordering verifier will reject
what it produces.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".