macro_rules! export_plugin {
($plugin_type:ty) => { ... };
}
Expand description
Export a plugin with boilerplate
This macro generates the necessary WASM exports for your plugin.
ยงExample
use mockforge_plugin_sdk::{export_plugin, prelude::*, Result as PluginCoreResult};
use std::collections::HashMap;
#[derive(Debug, Default)]
pub struct MyPlugin;
#[async_trait]
impl AuthPlugin for MyPlugin {
fn capabilities(&self) -> PluginCapabilities {
PluginCapabilities::default()
}
async fn initialize(&self, _config: &AuthPluginConfig) -> PluginCoreResult<()> {
Ok(())
}
async fn authenticate(
&self,
_context: &PluginContext,
_request: &AuthRequest,
_config: &AuthPluginConfig,
) -> PluginCoreResult<PluginResult<AuthResponse>> {
let identity = UserIdentity::new("user123");
let response = AuthResponse::success(identity, HashMap::new());
Ok(PluginResult::success(response, 0))
}
fn validate_config(&self, _config: &AuthPluginConfig) -> PluginCoreResult<()> {
Ok(())
}
fn supported_schemes(&self) -> Vec<String> {
vec!["basic".to_string()]
}
async fn cleanup(&self) -> PluginCoreResult<()> {
Ok(())
}
}
export_plugin!(MyPlugin);