Skip to main content

Crate ewwii_plugin_api

Crate ewwii_plugin_api 

Source
Expand description

§ewwii_plugin_api

ewwii_plugin_api provides the core traits, types, and abstractions that bridge the ewwii host and its plugins.

This crate provides a safe and easy plugin development API through a simple and flexible interface for cross-boundary communication.

§Usage

There are two ways to define a plugin: the Recommended Macro for standard plugins, and the Manual Implementation for full control.

For most use cases, the macro handles the boilerplate of exporting symbols and implementing traits.

use ewwii_plugin_api::{auto_plugin, PluginInfo};

auto_plugin!(
    DummyStructure,
    PluginInfo::new("com.app.example", "1.0.0"),
    host,
    {
        host.log("Plugin says Hello!");
    }
);

§2. Advanced: Manual Implementation

Use this approach if your plugin needs to maintain internal state, implement additional traits, or manage complex lifetimes.

use ewwii_plugin_api::{EwwiiAPI, Plugin, PluginInfo, export_plugin};

#[derive(Default)]
pub struct MyPlugin {
    count: std::sync::atomic::AtomicUsize,
}

impl Plugin for MyPlugin {
    fn metadata(&self) -> PluginInfo {
        PluginInfo::new("com.app.example", "1.0.0")
    }

    fn init(&self, host: &dyn EwwiiAPI) {
        host.log("Manual plugin initialized.");
    }
}

// This macro exports the C-compatible symbols required by the host loader
export_plugin!(MyPlugin);

Re-exports§

pub use ewwii_shared_utils as shared_utils;

Modules§

example
This module provides examples of plugin implementation
proxy
This module provides plugin requests and host proxy that are used to redirect API calls to host after serialization

Macros§

auto_plugin
Macro to implement and export a plugin in a single step. With this macro, users can write their plugin code directly without having to manually implement each trait.
export_plugin
Exports the required FFI symbols for the plugin to load

Structs§

ConfigInfo
PluginInfo
PluginInfoBuilder

Enums§

PluginError
This enumrate provides improved error support for plugins
PluginValue
Used for Plugin and host communication

Constants§

API_VERSION

Traits§

EwwiiAPI
The shared trait defining the Ewwii plugin API
NativeFnExt
ParseFnExt
Plugin
The API format that the plugin should follow. This trait should be implemented for a structure and that structure should be exported via FFI.

Type Aliases§

NativeFn
Handler for handling Native Function registeration in rhai
ParseFn