Expand description
Handlers return a Reply: an outcome or an owned stream. Dispatch
carries identity, requested delivery mode and scopes. ErasedHandler
is the shared registry boundary; drivers own polling and cancellation.
Provider and tool authors retain their domain traits through adapters.
Reply::written offers a writer that mints stream block identities.
use rig_core::serve::Dispatch;
use rig_core::effect::EffectId;
let dispatch = Dispatch::new(EffectId::from_raw(1), false);
assert!(!dispatch.is_stream());Re-exports§
pub use adapters::Serving;
Modules§
- adapters
- Effect handlers adapting model, tool, and retrieval traits. Each adapter translates its effect family into trait calls and returns outcomes or streaming events.
Structs§
- Dispatch
- An effect’s identity, requested delivery mode, and driver-provided scopes. Reply transport and cancellation remain owned by the driver.
- Dispatch
Context - Recorded parent dispatch, stable program scope identifier and purpose, without live runtime handles.
- Erased
Handler - Shared, type-erased handler. Clones retain the same handler allocation.
Implements
Send + Syncon native targets, but not on WASM. - Layer
- A handler wrapped in a policy: a
Servelike any other, registered under the inner handler’s descriptor (with the layer’s name added, outermost first). Built withErasedHandler::layered. - Record
Buffer - Collects the record of every dispatch it is told about, in the order the
dispatches began, whatever order they resolve in. A dispatch recorded by
it (
Dispatch::recorded_by), and every dispatch nested in it, becomes oneEffectRecordonce resolved: a layer’sdiscarddrops it and apatchreplaces its request, as an effect log keeps them. Clones share the records. - Sink
Closed - The receiver of an external answer or writer has been dropped.
- Stream
Tap - What a unary consumer, the record, or a layer’s verdict takes from a stream: its outcome, the response the stream ends with or the first error item. The origin folded the response; the tap only watches for it.
- Stream
Writer - A streaming answer under construction, a handler’s completion writer.
Obtained by
Reply::written;finishends the reply with the response it folds into, while a writer dropped without it leaves a truncated stream.
Enums§
- After
Serve - What a layer decides about an answer on its way out.
- Before
Serve - What a layer decides about a dispatch before the handler sees it.
- Reply
- An answer, or an owned stream whose execution belongs to the driver.
Traits§
- Intercept
- Host policy before a handler and after its first answer. A suspended verdict keeps execution in flight; driver cancellation drops its future. Streamed verdict futures are polled on the stream consumer’s thread. The layer name identifies policy when recording and validating replay.
- Observe
- What an observer of one dispatch sees: its outcome and, when wanted, each streamed item.
- Recorder
- What a driver tells about the dispatches it serves. A driver calls
handlersonce when recording starts,beginas each dispatch is handed to its handler,eventfor every streamed event whenkeep_eventssays so, andresolvewhen 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. - Serve
- A registered effect handler returning an outcome or an owned stream.
Functions§
- cancelled
- The consumer stopped listening before an answer was observed.
- catch_
panics work, the task that drives the dispatchid, with a panic in it (in the handler or in its reply’s stream) turned into an internal error thatrecorder, if any, also records as the dispatch’s outcome. Unwinding drops the dispatch’s observer, which records a cancellation; this replaces it.- serve_
inline - Serve an effect inline, using the same reply conversions as a driver.
- serve_
inline_ with - Serve inline with driver scopes, including tool context and publication.
- stream_
truncated - The retryable report of a reply that ended before the provider ended it
(
ProviderError::Truncated). Retryability does not guarantee a subsequent attempt will succeed.
Type Aliases§
- Handler
Future - Boxed handler reply future,
Sendon native targets and locally polled on WASM.