dynamic_plugin/lib.rs
#![deny(missing_docs)]
#![warn(clippy::pedantic)]
#![doc = include_str!("../README.md")]
// Re-export macros
pub use dynamic_plugin_macros::*;
pub use static_assertions::const_assert_eq;
// Re-export libloading library
pub use libloading::Library as PluginDynamicLibrary;
pub use libloading::Symbol as PluginLibrarySymbol;
/// Re-exported libc types for convenience.
pub use libc;
/// The result type returned by dynamic plugin functions.
pub type Result<T> = std::result::Result<T, Error>;
/// Errors returned from dynamic plugin functions.
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// An error returned from libloading when trying to communicate with the dynamic library.
#[error("An error while calling the plugin library: {0}")]
DynamicLibrary(#[from] libloading::Error),
/// The discovered library is not a plugin, as in it does not expose the `_dynamic_plugin_signature` function.
#[error("The discoverd library is not a plugin.")]
NotAPlugin,
/// The plugin's signature (i.e. name, function names, function arguments and function return types) does not match the expected value.
#[error("The plugin's signature does not match.")]
InvalidPluginSignature,
}