Skip to main content

EventHandler

Trait EventHandler 

Source
pub trait EventHandler:
    Send
    + Sync
    + 'static {
    // Required method
    fn on_event(
        &self,
        process: &ProcessorState<'_>,
    ) -> Result<Vec<AdviceMutation>, EventError>;
}
Expand description

An EventHandler defines a function that that can be called from the processor which can read the VM state and modify the state of the advice provider.

A struct implementing this trait can access its own state, but any output it produces must be stored in the process’s advice provider.

Required Methods§

Source

fn on_event( &self, process: &ProcessorState<'_>, ) -> Result<Vec<AdviceMutation>, EventError>

Handles the event when triggered.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl EventHandler for NoopEventHandler

Source§

impl<F> EventHandler for F
where F: for<'a> Fn(&'a ProcessorState<'_>) -> Result<Vec<AdviceMutation>, EventError> + Send + Sync + 'static,

Default implementation for both free functions and closures with signature fn(&ProcessorState) -> Result<(), HandlerError>