pub trait Recorder:
WasmCompatSend
+ WasmCompatSync
+ 'static {
// Required methods
fn handlers(&self, handlers: Vec<HandlerDescriptor>);
fn begin(
&self,
id: EffectId,
key: HandlerKey,
kind: EffectKind,
origin: DispatchContext,
);
fn discard(&self, id: EffectId);
fn patch(&self, id: EffectId, kind: EffectKind);
fn keep_events(&self) -> bool;
fn event(&self, id: EffectId, item: &Item<StreamEvent>);
fn origin(&self, id: EffectId, origin: &Origin);
fn tool_output(&self, id: EffectId, output: ToolResultContext);
fn resolve(&self, id: EffectId, outcome: Result<Answered, ErrorReport>);
// Provided method
fn stream_error(&self, _id: EffectId, _error: &ErrorReport) { ... }
}Expand description
What a driver tells about the dispatches it serves. A driver calls
handlers once when recording starts,
begin as each dispatch is handed to its handler,
event for every streamed event when
keep_events says so, and
resolve when the outcome is known. A recorder is
shared between the driver and its owner, so every method takes &self;
it rides in the dispatch observer and uses the platform compatibility bounds.
Required Methods§
Sourcefn handlers(&self, handlers: Vec<HandlerDescriptor>)
fn handlers(&self, handlers: Vec<HandlerDescriptor>)
Handlers the driver serves: those registered when recording started, then each one installed later, as it is installed. A key described again is the same handler re-registered; the latest description stands.
Sourcefn begin(
&self,
id: EffectId,
key: HandlerKey,
kind: EffectKind,
origin: DispatchContext,
)
fn begin( &self, id: EffectId, key: HandlerKey, kind: EffectKind, origin: DispatchContext, )
A dispatch begins: its id, the key it was routed to, the effect, and where it came from (its parent and scope).
Sourcefn discard(&self, id: EffectId)
fn discard(&self, id: EffectId)
Removes a begun dispatch decided by a layer before handler execution. Replay reruns layer decisions rather than recording them as handler outcomes.
Sourcefn patch(&self, id: EffectId, kind: EffectKind)
fn patch(&self, id: EffectId, kind: EffectKind)
Replaces the recorded request with a same-family layer patch, so it reflects the request served by the innermost handler.
Sourcefn keep_events(&self) -> bool
fn keep_events(&self) -> bool
Whether streamed items are wanted verbatim (Self::event).
Sourcefn event(&self, id: EffectId, item: &Item<StreamEvent>)
fn event(&self, id: EffectId, item: &Item<StreamEvent>)
One streamed item of id.
Sourcefn origin(&self, id: EffectId, origin: &Origin)
fn origin(&self, id: EffectId, origin: &Origin)
Who the streamed reply of id is from, before its first item, when
keep_events says so.
Sourcefn tool_output(&self, id: EffectId, output: ToolResultContext)
fn tool_output(&self, id: EffectId, output: ToolResultContext)
Explicitly published output, a tool’s or a layer’s facts, delivered
before resolve. A driver snapshots it without consuming the
caller’s published context.
Provided Methods§
Sourcefn stream_error(&self, _id: EffectId, _error: &ErrorReport)
fn stream_error(&self, _id: EffectId, _error: &ErrorReport)
An error item at its original position in a kept stream. Unlike the folded outcome, this includes errors after an earlier terminal item.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".