Skip to main content

PluginDLL

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

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

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

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

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)

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_path(&self) -> &Path

Returns the name of the plugin

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

Returns the number of references to the plugin

Trait Implementations§

§

impl Clone for PluginDLL

§

fn clone(&self) -> PluginDLL

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for PluginDLL

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Hash for PluginDLL

§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl PartialEq for PluginDLL

§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Eq for PluginDLL

§

impl Send for PluginDLL

§

impl Sync for PluginDLL

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.