pub trait ModelTurn: Send {
// Required method
fn next_event<'life0, 'async_trait>(
&'life0 mut self,
cancellation: Option<TurnCancellation>,
) -> Pin<Box<dyn Future<Output = Result<Option<ModelTurnEvent>, LoopError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn on_cancelled(&mut self) { ... }
}Expand description
A streaming model turn that yields events one at a time.
The loop driver calls next_event repeatedly
until it returns Ok(None) (stream exhausted) or
Ok(Some(ModelTurnEvent::Finished(_))).
Required Methods§
Sourcefn next_event<'life0, 'async_trait>(
&'life0 mut self,
cancellation: Option<TurnCancellation>,
) -> Pin<Box<dyn Future<Output = Result<Option<ModelTurnEvent>, LoopError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn next_event<'life0, 'async_trait>(
&'life0 mut self,
cancellation: Option<TurnCancellation>,
) -> Pin<Box<dyn Future<Output = Result<Option<ModelTurnEvent>, LoopError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieve the next event from the model’s response stream.
Returns Ok(None) when the stream is exhausted.
§Errors
Returns LoopError::Cancelled if cancellation fires, or a
provider-specific error wrapped in LoopError.
Provided Methods§
Sourcefn on_cancelled(&mut self)
fn on_cancelled(&mut self)
Notifies the turn before the driver drops it after explicit cancellation observed between events. This synchronous hook must not block. The default is a no-op; adapters can finalize retry accounting here.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".