Skip to main content

EffectHandler

Trait EffectHandler 

Source
pub trait EffectHandler: Send + Sync {
    // Required methods
    fn handles(&self, effect: &Effect) -> bool;
    fn perform(&self, effect: &Effect) -> Result<EffectResult>;
}
Expand description

Performs one kind of effect.

Handlers are tried in order; the first that claims an effect wins.

Lives here rather than beside the driver that runs them, so a crate can implement a handler without depending on the execution engine — soma-llm is one, and what it needs is a provider client, not a scheduler.

Required Methods§

Source

fn handles(&self, effect: &Effect) -> bool

Will this handler take that effect?

Source

fn perform(&self, effect: &Effect) -> Result<EffectResult>

Perform it. Blocking.

A transport failure should come back as EffectResult::Failed, not Err — the step decides whether to retry, fall back, or stop. Reserve Err for conditions the step cannot act on.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§