Trait perseus::PluginAction
source · [−]pub trait PluginAction<A, R, R2>: Send {
fn run(
&self,
action_data: A,
plugin_data: &HashMap<String, Box<dyn Any + Send>>
) -> R2;
fn register_plugin(
&mut self,
name: &str,
runner: impl Fn(&A, &(dyn Any + Send)) -> R + Send + 'static
);
fn register_plugin_box(&mut self, name: &str, runner: Runner<A, R>);
}
Expand description
A trait for the interface for a plugin action, which abstracts whether it’s a functional or a control action.
Required Methods
Runs the action. This takes data that the action should expect, along with a map of plugins to their data.
Registers a plugin that takes this action.
Panics
If the action type can only be taken by one plugin, and one has already been set, this may panic (e.g. for control actions), as this is a critical, unrecoverable error that Perseus doesn’t need to do anything after. If a plugin registration fails, we have to assume that all work in the engine may be not what the user intended.
fn register_plugin_box(&mut self, name: &str, runner: Runner<A, R>)
fn register_plugin_box(&mut self, name: &str, runner: Runner<A, R>)
Same as .register_plugin()
, but takes a prepared runner in a Box
.