Plugin

Trait Plugin 

Source
pub trait Plugin: 'static {
    // Required method
    fn plug(self, plugins: &Plugins);
}
Expand description

A plugin for Duat

Plugins should mostly follow the builder pattern, but you can use fields if you wish to. When calling Plugin::plug, the plugin’s settings should be taken into account, and all of its setup should be done:

// It's not a supertrait of Plugin, but you must implement
// Default in order to use the plugin.
#[derive(Default)]
struct MyPlugin(bool);

impl Plugin for MyPlugin {
    // With the Plugins struct, you can require other plugins
    // within your plugin
    fn plug(self, plugins: &Plugins) {
        //..
    }
}

impl MyPlugin {
    /// Returns a new instance of the [`MyPlugin`] plugin
    pub fn new() -> Self {
        Self(false)
    }

    /// Modifies [`MyPlugin`]
    pub fn modify(self) -> Self {
        //..
    }
}

Required Methods§

Source

fn plug(self, plugins: &Plugins)

Sets up the Plugin

Implementors§