#![allow(
clippy::used_underscore_binding,
clippy::needless_lifetimes,
clippy::expl_impl_clone_on_copy,
clippy::must_use_candidate,
clippy::cast_ptr_alignment
)]
use abi_stable::{
StableAbi, declare_root_module_statics,
library::RootModule,
package_version_strings, sabi_trait,
sabi_types::VersionStrings,
std_types::{RBox, RBoxError, ROption, RResult, RStr, RString, RVec},
};
use crate::types::{Diagnostic, PluginContext, ProcessingResult, SpoeMessage};
pub type PluginBox = SpoePlugin_TO<'static, RBox<()>>;
#[sabi_trait]
pub trait SpoePlugin: Send + Sync + core::fmt::Debug {
fn init(&mut self, context: &PluginContext) -> RResult<(), RBoxError>;
fn process(&self, message: &SpoeMessage) -> RResult<ProcessingResult, RBoxError>;
fn name(&self) -> RStr<'_>;
fn version(&self) -> RStr<'_>;
#[sabi(last_prefix_field)]
fn shutdown(&self);
fn config_schema(&self) -> ROption<RString> {
ROption::RNone
}
fn validate(&self, _: &PluginContext) -> RVec<Diagnostic> {
RVec::new()
}
}
#[repr(C)]
#[derive(StableAbi)]
#[sabi(kind(Prefix(prefix_ref = PluginMod_Ref)))]
#[sabi(missing_field(panic))]
pub struct PluginMod {
#[sabi(last_prefix_field)]
pub new: extern "C" fn() -> RResult<PluginBox, RBoxError>,
}
impl RootModule for PluginMod_Ref {
declare_root_module_statics! {PluginMod_Ref}
const BASE_NAME: &'static str = "spoa_plugin";
const NAME: &'static str = "spoa_plugin";
const VERSION_STRINGS: VersionStrings = package_version_strings!();
}