Skip to main content

Recorder

Trait Recorder 

Source
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§

Source

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.

Source

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).

Source

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.

Source

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.

Source

fn keep_events(&self) -> bool

Whether streamed items are wanted verbatim (Self::event).

Source

fn event(&self, id: EffectId, item: &Item<StreamEvent>)

One streamed item of id.

Source

fn origin(&self, id: EffectId, origin: &Origin)

Who the streamed reply of id is from, before its first item, when keep_events says so.

Source

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.

Source

fn resolve(&self, id: EffectId, outcome: Result<Answered, ErrorReport>)

The outcome of id.

Provided Methods§

Source

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".

Implementors§