From 0ec6d5d3f6b0f4ccb30bd29b80ee37acb5b4164b Mon Sep 17 00:00:00 2001 From: ppom Date: Fri, 26 Sep 2025 12:00:00 +0200 Subject: [PATCH] Fix compilation error The lifetime compilation error disappears when the filter methods are async, so let's just do that for now --- reaction-plugin/src/lib.rs | 30 +++++++++++++++++------------- reaction-plugin/src/value.rs | 1 + 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/reaction-plugin/src/lib.rs b/reaction-plugin/src/lib.rs index 93ec74d..a1a51f7 100644 --- a/reaction-plugin/src/lib.rs +++ b/reaction-plugin/src/lib.rs @@ -7,6 +7,14 @@ /// To implement a plugin, one has to provide an implementation of [`PluginInfo`], that provides /// the entrypoint for a plugin. /// It permits to define 0 to n (stream, filter, action) custom types. +/// +/// It must also export a function that returns an impl of the trait: +/// ```rust +/// #[stabby::export(checked)] +/// extern "C" fn reaction_plugin() -> BoxedPluginInfo { +/// ... +/// } +/// ``` use stabby::{ boxed::Box, future::DynFuture, option::Option, result::Result, string::String, vec::Vec, }; @@ -26,7 +34,7 @@ pub trait PluginInfo { stream_name: String, stream_type: String, config: Value, - ) -> Result; + ) -> Result; /// Return all filter types that should be made available to reaction users extern "C" fn filter_impls(&self) -> Vec; @@ -37,7 +45,7 @@ pub trait PluginInfo { filter_name: String, filter_type: String, config: Value, - ) -> Result; + ) -> Result; /// Return all action types that should be made available to reaction users extern "C" fn action_impls(&self) -> Vec; @@ -49,21 +57,17 @@ pub trait PluginInfo { action_name: String, action_type: String, config: Value, - ) -> Result; + ) -> Result; /// Notify the plugin that setup is finished, permitting a last occasion to report an error /// (For example if a stream wants a companion action but it hasn't been initialized) extern "C" fn finish_setup(&mut self) -> Result<(), String>; } -pub enum PluginError { - InexistantType, - InitialisationError(String), -} - -type BoxedStreamImpl = stabby::dynptr!(Box); -type BoxedFilterImpl = stabby::dynptr!(Box); -type BoxedActionImpl = stabby::dynptr!(Box); +pub type BoxedPluginInfo = stabby::dynptr!(Box); +pub type BoxedStreamImpl = stabby::dynptr!(Box); +pub type BoxedFilterImpl = stabby::dynptr!(Box); +pub type BoxedActionImpl = stabby::dynptr!(Box); #[stabby::stabby(checked)] pub trait StreamImpl { @@ -73,8 +77,8 @@ pub trait StreamImpl { #[stabby::stabby(checked)] pub trait FilterImpl { - extern "C" fn matches(&mut self, line: String) -> bool; - extern "C" fn close(&mut self) -> Result<(), String>; + extern "C" fn matches<'a>(&'a mut self, line: String) -> DynFuture<'a, bool>; + extern "C" fn close<'a>(&'a mut self) -> DynFuture<'a, Result<(), String>>; } #[stabby::stabby(checked)] diff --git a/reaction-plugin/src/value.rs b/reaction-plugin/src/value.rs index 34322b0..18c5a38 100644 --- a/reaction-plugin/src/value.rs +++ b/reaction-plugin/src/value.rs @@ -3,6 +3,7 @@ use stabby::{string::String, tuple::Tuple2, vec::Vec}; /// Represents a configuration value. /// This is not meant as an efficient type, but as a very flexible one. #[stabby::stabby] +#[repr(C, u8)] pub enum Value { Null, Bool(bool),