Trait Plugin

View as Markdown

Generated from cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-ffi.

pub trait Plugin:
    Send
    + Sync
    + 'static {
    // Required methods
    fn plugin_kind(&self) -> &str;
    fn validate(
        &self,
        plugin_config: &Map<String, Json>,
    ) -> Vec<ConfigDiagnostic>;
    fn register<'a>(
        &'a self,
        plugin_config: &Map<String, Json>,
        ctx: &'a mut PluginRegistrationContext,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;
​
    // Provided method
    fn allows_multiple_components(&self) -> bool { ... }
}

Implemented by custom plugins that register runtime middleware.

Required Methods

plugin_kind

fn plugin_kind(&self) -> &str

Returns the unique plugin kind string.

validate

fn validate(&self, plugin_config: &Map<String, Json>) -> Vec<ConfigDiagnostic>

Validates one plugin component config.

Returning error-level diagnostics prevents initialize_plugins(...) from activating the configuration.

register

fn register<'a>(
    &'a self,
    plugin_config: &Map<String, Json>,
    ctx: &'a mut PluginRegistrationContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>

Registers runtime middleware/subscribers for one plugin component.

The provided PluginRegistrationContext is component-scoped. Any error aborts the current initialization and triggers rollback of registrations created during the failed activation attempt.

Provided Methods

allows_multiple_components

fn allows_multiple_components(&self) -> bool

Returns whether the plugin kind can appear multiple times in the config.

Return false for singleton components such as the built-in adaptive component.

Implementors