rssn 0.2.9

A comprehensive scientific computing library for Rust, aiming for feature parity with NumPy and SymPy.
Documentation
#![allow(unsafe_code)]
#![allow(clippy::indexing_slicing)]
#![allow(clippy::no_mangle_with_rust_abi)]
#![allow(non_local_definitions)]
#![allow(clippy::cast_ptr_alignment)]
#![allow(clippy::used_underscore_binding)]
#![allow(clippy::elidable_lifetime_names)]
#![allow(clippy::expl_impl_clone_on_copy)]

use abi_stable::StableAbi;
use abi_stable::sabi_trait;
use abi_stable::std_types::RBox;
use abi_stable::std_types::RResult;
use abi_stable::std_types::RString;
use abi_stable::std_types::RVec;

use crate::plugins::plugin_c::PluginHealth;

/// This trait defines the stable ABI for plugins.
#[allow(non_local_definitions)]
#[sabi_trait]
pub trait StablePlugin: Send + Sync {
    /// Returns the name of the plugin.
    fn name(&self) -> RString;

    /// Returns the API version of the plugin.
    fn api_version(&self) -> RString;

    /// Called when the plugin is loaded.
    fn on_load(&self) -> RResult<(), RString>;

    /// Executes a command on the plugin.
    fn execute(
        &self,
        command: RString,
        args: RVec<u8>,
    ) -> RResult<RVec<u8>, RString>;

    /// Performs a health check on the plugin.
    fn health_check(&self) -> RResult<PluginHealth, RString>;
}

/// This struct defines the stable ABI for a plugin module.
#[repr(C)]
#[derive(StableAbi)]
#[sabi(kind(Prefix(prefix_ref = RoVtable)))]
#[sabi(missing_field(panic))]
pub struct StablePluginModule {
    /// Returns the name of the plugin.
    //#[must_use]
    pub name: extern "C" fn() -> RString,
    /// Returns the version of the plugin.
    //#[must_use]
    pub version: extern "C" fn() -> RString,
    /// Creates a new instance of the plugin.
    //#[must_use]
    pub new: extern "C" fn() -> StablePlugin_TO<'static, RBox<()>>,
}