Struct PluginDLL
pub(crate) struct PluginDLL(Arc<PluginDLLInner>);Expand description
PluginDLL is a reference counted wrapper around libloading::Library that can be safely shared between threads. It is the lowest level of abstraction to interact with the plugin exported functions. Two PluginDLL instances are considered equal if they were provided with the same path on creation.
§Unloading
Once all references are dropped, the library gets unloaded.
Tuple Fields§
§0: Arc<PluginDLLInner>Implementations§
§impl PluginDLL
impl PluginDLL
pub fn new(lib_path: PathBuf) -> Result<Self, GCPluginManagerError>
pub fn new(lib_path: PathBuf) -> Result<Self, GCPluginManagerError>
Loads a plugin from a shared object file
pub unsafe fn gc_plugin_init(
&self,
interface: *const GCPluginInterface,
) -> GCInstanceHandle
pub unsafe fn gc_plugin_init( &self, interface: *const GCPluginInterface, ) -> GCInstanceHandle
Initializes the plugin
§Safety
The caller is responsible for ensuring the following conditions:
- The interface is a valid pointer to a GCPluginInterface
- The plugin must check if the returned handle is valid the plugin might return a null handle if the initialization fails
pub unsafe fn gc_plugin_receive_datapoint(
&self,
plugin_ctx: GCInstanceHandle,
datapoint_value: *const GCDatapointValue,
) -> bool
pub unsafe fn gc_plugin_receive_datapoint( &self, plugin_ctx: GCInstanceHandle, datapoint_value: *const GCDatapointValue, ) -> bool
Receives a datapoint value
§Safety
The caller is responsible for ensuring the following conditions:
- The plugin_ctx is a valid pointer to the plugin’s context
- The datapoint_value is a valid pointer to a GCDatapointValue
- The datapoint_value must live until the plugin calls the release_datapoint_value callback
pub fn gc_plugin_get_info(&self) -> GCPluginInfo
pub fn gc_plugin_get_info(&self) -> GCPluginInfo
Returns the plugin info
This functions assumes that the plugin always returns a valid pointer to the plugin info, which should part of the contract anyway.
pub unsafe fn gc_plugin_shutdown<T>(&self, plugin_ctx: *mut T)
pub unsafe fn gc_plugin_shutdown<T>(&self, plugin_ctx: *mut T)
Shutdown the plugin
§Safety
The caller is responsible for ensuring the following conditions:
- The plugin_ctx is a valid pointer to the plugin’s context
- This function is called only once after each gc_plugin_init call
pub fn get_plugin_name(&self) -> &OsStr
pub fn get_plugin_name(&self) -> &OsStr
Return the logical plugin name (stem without extension, e.g. “echo_plugin” from “echo_plugin.gc”)
pub fn get_num_references(&self) -> usize
pub fn get_num_references(&self) -> usize
Returns the number of references to the plugin