Skip to main content

Crate nemo_plugin_api

Crate nemo_plugin_api 

Source
Expand description

Nemo Plugin API - Shared interface for native plugins.

This crate defines the stable API boundary between the Nemo host and native plugins. Plugins link against this crate to register their capabilities.

§Writing a Plugin

A Nemo plugin is a dynamic library (cdylib) that exports two symbols:

  • nemo_plugin_manifest - returns a PluginManifest describing the plugin
  • nemo_plugin_entry - called with a PluginRegistrar to register components, data sources, transforms, actions, and templates

Use the declare_plugin! macro to generate both exports.

§Minimal Example

use nemo_plugin_api::*;
use semver::Version;

fn init(registrar: &mut dyn PluginRegistrar) {
    // Register a custom component
    registrar.register_component(
        "my_counter",
        ComponentSchema::new("my_counter")
            .with_description("A counter component")
            .with_property("initial", PropertySchema::integer())
            .require("initial"),
    );

    // Access host data
    if let Some(value) = registrar.context().get_data("app.settings.theme") {
        registrar.context().log(LogLevel::Info, &format!("Theme: {:?}", value));
    }
}

declare_plugin!(
    PluginManifest::new("my-plugin", "My Plugin", Version::new(0, 1, 0))
        .with_description("Example Nemo plugin")
        .with_capability(Capability::Component("my_counter".into())),
    init
);

§Registering a Data Source

fn init(registrar: &mut dyn PluginRegistrar) {
    let mut schema = DataSourceSchema::new("my_feed");
    schema.description = "Streams data from a custom feed".into();
    schema.supports_streaming = true;
    schema.properties.insert(
        "url".into(),
        PropertySchema::string().with_description("Feed URL"),
    );
    registrar.register_data_source("my_feed", schema);
}

§Plugin Permissions

Plugins declare required permissions in their manifest via PluginPermissions. The host checks these before granting access to network, filesystem, or subprocess operations.

Macros§

declare_plugin
Macro to declare a plugin entry point.

Structs§

ActionSchema
Schema for an action.
ComponentSchema
Schema for a component.
DataSourceSchema
Schema for a data source.
PluginManifest
Plugin manifest describing capabilities.
PluginPermissions
Permissions requested by a plugin.
PropertySchema
Schema for a property.
TransformSchema
Schema for a transform.

Enums§

Capability
Plugin capability type.
LogLevel
Log level.
PluginError
Error from plugin operations.
PluginValue
A configuration value (simplified for FFI safety).
PropertyType
Property type.

Traits§

PluginContext
Context providing API access to plugins at runtime.
PluginRegistrar
Trait for plugin registration.

Type Aliases§

PluginEntryFn
Plugin entry point function type.