Skip to main content

HostHooks

Trait HostHooks 

Source
pub trait HostHooks:
    Send
    + Sync
    + 'static {
    // Required methods
    fn event(&self, module: &str, event: PluginEvent) -> bool;
    fn log(&self, module: &str, level: LogLevel, message: &str);
    fn wake(&self);
}
Expand description

What the engine provides to the plugins it loads.

Every method is called from whichever thread the plugin used, at any time from the moment the module initializes until the process ends, so an implementation is a queue push rather than a piece of work.

Required Methods§

Source

fn event(&self, module: &str, event: PluginEvent) -> bool

Take an event a module pushed. Returns false when the engine is no longer accepting events, which is what a plugin’s worker thread sees while the app shuts down.

Source

fn log(&self, module: &str, level: LogLevel, message: &str)

Take a diagnostic line from a module.

Source

fn wake(&self)

Ask for another tick, so a queued event is drained without waiting for input.

Implementors§