pub trait Model {
// Required method
fn call(&mut self, req: &ModelRequest<'_>) -> Result<ModelReturn, AxError>;
// Provided methods
fn call_streaming(
&mut self,
req: &ModelRequest<'_>,
_onto: Increments<'_>,
) -> Result<ModelReturn, AxError> { ... }
fn call_speculating(
&mut self,
req: &ModelRequest<'_>,
onto: Increments<'_>,
_early: EarlyCalls<'_>,
) -> Result<ModelReturn, AxError> { ... }
}Expand description
The model port. Production adapter: gateway::endpoint; second adapter: citysim scripted model. Implementations never sample clocks or read global state.
Required Methods§
fn call(&mut self, req: &ModelRequest<'_>) -> Result<ModelReturn, AxError>
Provided Methods§
Sourcefn call_streaming(
&mut self,
req: &ModelRequest<'_>,
_onto: Increments<'_>,
) -> Result<ModelReturn, AxError>
fn call_streaming( &mut self, req: &ModelRequest<'_>, _onto: Increments<'_>, ) -> Result<ModelReturn, AxError>
The same call, reporting text as it arrives.
The default answers by calling Model::call and reporting
nothing, which is the honest behaviour for an adapter that has no
stream: a caller gets the same ModelReturn at the same moment
and simply sees no increments. An adapter that overrides this owes
the same ModelReturn it would have returned from call,
including the same failures — a stream cut halfway is a read
error, never a shortened answer.
§Errors
Whatever Model::call would fail with.
Sourcefn call_speculating(
&mut self,
req: &ModelRequest<'_>,
onto: Increments<'_>,
_early: EarlyCalls<'_>,
) -> Result<ModelReturn, AxError>
fn call_speculating( &mut self, req: &ModelRequest<'_>, onto: Increments<'_>, _early: EarlyCalls<'_>, ) -> Result<ModelReturn, AxError>
The streaming call, also handing over each tool call as soon as it is complete.
The default hands nothing over and answers with
Model::call_streaming, which is honest for an adapter whose
wire cannot say when a call is complete: the caller simply gets no
head start. An adapter that overrides this owes the same
ModelReturn and failures as call_streaming, and every call it
hands over equals the one in that ModelReturn.
§Errors
Whatever Model::call_streaming would fail with.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".