pub trait Model {
// Required method
fn call(&mut self, req: &ModelRequest<'_>) -> Result<ModelReturn, AxError>;
// Provided methods
fn provider_account(&self) -> Option<ProviderAccountBinding> { ... }
fn account_roster(&self) -> Option<AccountRoster> { ... }
fn select_account(&mut self, _account: &ServerLabel) { ... }
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 provider_account(&self) -> Option<ProviderAccountBinding>
fn provider_account(&self) -> Option<ProviderAccountBinding>
The non-secret identity recorded before each actual request: the roster’s provider and current account, answered without asking the vault.
Sourcefn account_roster(&self) -> Option<AccountRoster>
fn account_roster(&self) -> Option<AccountRoster>
The accounts this adapter can call as; None for an adapter with
no named account. With two accounts or more each entry’s
usable asks the vault, so a caller asks once per round.
Sourcefn select_account(&mut self, _account: &ServerLabel)
fn select_account(&mut self, _account: &ServerLabel)
Selects the account every later request of this adapter uses, without sending a request; a name outside the roster leaves the selection as it was. The credential is redeemed at call time, so selecting cannot fail.
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".