gc_plugin_abi 0.1.0

Gridcore Plugin API
Documentation
use gc_plugin_abi::*;
#[gc_plugin]
pub struct RestSomethingPlugin {}
impl Default for RestSomethingPlugin {
    fn default() -> Self {
        Self::new()
    }
}

impl RestSomethingPlugin {
    pub fn new() -> Self {
        Self {}
    }
}

impl<'a> GCPluginInstance<'a> for RestSomethingPlugin {
    fn get_plugin_info() -> GCPluginInfo {
        GCPluginInfo::new("RestSomethingPlugin", "0.1.0", "0", 0)
    }

    fn receive_datapoint(&self, _data_value: GCBorrowedDatapointValue) -> bool {
        // Handle incoming datapoint
        true
    }

    fn init(_plugin_interface: &'a GCPluginInterface) -> Box<Self> {
        Box::new(RestSomethingPlugin::new())
    }
}

#[cfg(test)]
mod tests {
    use gc_plugin_abi::raw::{self, GCInfoPluginExport, GCInitPluginExport, GCReceiveDatapointPluginExport, GCShutdownPluginExport};

    /// Ensure this test breaks if any of the function signatures change
    /// If this test fails, the Rust safe ABI will have to be updated
    /// Requires the plugin to be defined above, otherwise linking will fail
    #[test]
    fn test_function_signatures() {
        let _gc_plugin_init_check: GCInitPluginExport = raw::gc_plugin_init;
        let _gc_plugin_shutdown_check: GCShutdownPluginExport = raw::gc_plugin_shutdown;
        let _gc_plugin_receive_datapoint_check: GCReceiveDatapointPluginExport = raw::gc_plugin_receive_datapoint;
        let _gc_plugin_get_info_check: GCInfoPluginExport = raw::gc_plugin_get_info;
    }
}