Skip to main content

EffectHandler

Trait EffectHandler 

Source
pub trait EffectHandler {
    // Required method
    fn dispatch(
        &mut self,
        kind: &str,
        op: &str,
        args: Vec<Value>,
    ) -> Result<Value, String>;

    // Provided method
    fn note_call_budget(&mut self, _budget_cost: u64) -> Result<(), String> { ... }
}
Expand description

Host-side effect dispatch. Implementors decide what kind/op mean and how arguments map to side effects.

Required Methods§

Source

fn dispatch( &mut self, kind: &str, op: &str, args: Vec<Value>, ) -> Result<Value, String>

Provided Methods§

Source

fn note_call_budget(&mut self, _budget_cost: u64) -> Result<(), String>

Hook called by the VM at every function call so handlers can enforce per-call budget consumption (#225). The argument is the sum of [budget(N)] declared on the callee’s signature; the handler returns Err to refuse the call (the VM converts to VmError::Effect). Default impl is a no-op so legacy handlers and pure-only runs are unaffected.

Implementors§