kvarn::ctl

Type Alias Plugin

source
pub type Plugin = Box<dyn for<'a> Fn(Arguments, &'a Vec<PortDescriptor>, &'a Manager, &'a Plugins) -> RetSyncFut<'a, PluginResponse> + Send + Sync>;
Available on crate feature handover only.
Expand description

A plugin, similar to the extensions. One can easily be constructed using the plugin! macro.

§Examples

let mut config = RunConfig::new();
let plugin: ctl::Plugin = Box::new(|args, _port_descriptors, _shutdown_manager, _plugins| {
    Box::pin(async move {
        let mut s = args.name().to_owned();
        for arg in args.iter() {
            s.push(' ');
            s.push_str(arg);
        }
        ctl::PluginResponse::ok(s)
    }) as extensions::RetSyncFut<'_, _>
});
config = config.add_plugin("my-plugin", plugin);

Aliased Type§

struct Plugin(/* private fields */);