Skip to main content

PluginHandle

Struct PluginHandle 

Source
pub struct PluginHandle { /* private fields */ }
Expand description

A handle to a loaded plugin, ready for calling methods.

Holds an Arc<Library> to keep the dylib loaded as long as any handle exists. Call methods via call_method() which handles serialization, FFI, and cleanup.

PluginHandle is Send + Sync. Plugin methods take &self (enforced by the macro), so concurrent calls from multiple threads are safe as long as the plugin implementation is thread-safe internally.

Implementations§

Source§

impl PluginHandle

Source

pub fn from_loaded(plugin: LoadedPlugin) -> Self

Create a PluginHandle from a LoadedPlugin.

Source

pub fn call_method<I: Serialize, O: DeserializeOwned>( &self, index: usize, input: &I, ) -> Result<O, CallError>

Call a plugin method by vtable index.

Serializes the input, calls the FFI function pointer at the given index, checks the status code, deserializes the output, and frees the plugin-allocated buffer.

§Arguments
  • index - The method index in the vtable (0-based, in declaration order)
  • input - The input argument to serialize and pass to the plugin
Source

pub fn has_capability(&self, bit: u32) -> bool

Check if an optional method is supported (capability bit is set).

Returns false for bit indices >= 64 rather than panicking.

Source

pub fn info(&self) -> &PluginInfo

Access the plugin’s owned metadata.

Trait Implementations§

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.