Skip to main content

Crate entelix_runnable

Crate entelix_runnable 

Source
Expand description

§entelix-runnable

Composition contract for entelix (invariant 7). Defines Runnable<I, O> and the universal .pipe() connector — Sequence, Parallel, Router, Lambda, Passthrough, plus the type-erased AnyRunnable for dynamic dispatch (F12 mitigation).

§Composition surface

Every adapter on RunnableExt returns a concrete Runnable<I, O> type — chains stay zero-cost in the steady state, with boxing only at the explicit erase() boundary. The standard adapters:

  • pipe(next) — sequence two runnables
  • with_retry(policy) — retry transient errors
  • with_fallbacks(others) — ordered fallbacks on transient errors
  • map(fn) — pure synchronous output transform
  • with_config(fn) — branch-local ExecutionContext mutation
  • with_timeout(duration) — wall-clock deadline override
  • stream_with(input, mode, ctx) — convenience streaming entry

Re-exports§

pub use stream::BoxStream;
pub use stream::DebugEvent;
pub use stream::RunnableEvent;
pub use stream::StreamChunk;
pub use stream::StreamMode;

Modules§

stream
Streaming surface for Runnable.

Structs§

Configured
Runnable<I, O> adapter that runs configurer on a cloned ExecutionContext before forwarding to the inner. The original ctx the parent passed in is left untouched.
Fallback
Runnable<I, O> adapter that falls back through a list of alternatives when the primary returns a classifier-approved transient error.
JsonOutputParser
Parses an assistant Message as JSON into T.
Mapping
Runnable<I, P> adapter applying a pure synchronous function to the inner’s output.
Retrying
Runnable<I, O> adapter applying a RetryPolicy to the inner runnable on every invocation.
RunnableLambda
Runnable<I, O> backed by a user-supplied async closure.
RunnableParallel
Runnable<I, HashMap<String, O>> that runs every registered branch in parallel against the same input.
RunnablePassthrough
Runnable<T, T> that returns its input unchanged.
RunnableRouter
Runnable<I, O> that picks one of several runnables based on a predicate over the input.
RunnableSequence
Two Runnables composed end-to-end. RunnableSequence<I, M, O> reads “input I → middle M → output O”. Created with .pipe().
StructuredOutputAdapter
Adapts a ChatModel<C, T> to Runnable<Vec<Message>, O> by routing every invoke through ChatModel::complete_typed::<O>.
Timed
Runnable<I, O> adapter that aborts the inner with Error::DeadlineExceeded if it does not complete within timeout.
ToolToRunnableAdapter
Wraps any Tool as Runnable<serde_json::Value, serde_json::Value>.

Traits§

AnyRunnable
Object-safe variant of Runnable that operates on serde_json::Value at the public interface. Useful for tool registries, dispatch tables, and dynamic plug-in points.
ChatModelExt
Extension methods on ChatModel that produce typed Runnable adapters.
Runnable
One end of a composable computation.
RunnableExt
Ergonomic composition surface, blanket-implemented for every Runnable<I, O>.

Functions§

erase
Wrap a typed Runnable<I, O> as an AnyRunnable by transcoding I/O through serde_json::Value. Returns Arc<dyn AnyRunnable> so the result drops directly into a registry.

Type Aliases§

AnyRunnableHandle
Convenience Arc<dyn AnyRunnable> alias for registries / dispatch tables.