Skip to main content

PluginDescriptor

Struct PluginDescriptor 

Source
#[repr(C)]
pub struct PluginDescriptor { pub abi_version: u32, pub interface_name: *const c_char, pub interface_hash: u64, pub interface_version: u32, pub capabilities: u64, pub wire_format: u8, pub buffer_strategy: u8, pub plugin_name: *const c_char, pub vtable: *const c_void, pub free_buffer: Option<unsafe extern "C" fn(*mut u8, usize)>, pub method_count: u32, }
Expand description

Metadata descriptor for a single plugin within a dylib.

Contains all information the host needs to validate and call the plugin without executing any plugin code. All string fields are pointers to static, null-terminated C strings embedded in the dylib.

§Safety

  • interface_name and plugin_name must point to valid, null-terminated, UTF-8 C strings with 'static lifetime.
  • vtable must point to a valid #[repr(C)] vtable struct matching the interface identified by interface_name and interface_hash.
  • When buffer_strategy == PluginAllocated, free_buffer must be Some.
  • All pointed-to data must outlive any PluginHandle derived from this descriptor.

Fields§

§abi_version: u32

Descriptor struct layout version. Must equal ABI_VERSION.

§interface_name: *const c_char

Null-terminated name of the trait this plugin implements (e.g., "ImageFilter").

§interface_hash: u64

FNV-1a hash of the required method signatures. Detects ABI drift.

§interface_version: u32

User-specified interface version from #[plugin_interface(version = N)].

§capabilities: u64

Bitfield where bit N indicates optional method N is implemented. Supports up to 64 optional methods per interface.

§wire_format: u8

Wire serialization format this plugin was compiled with.

§buffer_strategy: u8

Buffer management strategy this plugin’s vtable expects.

§plugin_name: *const c_char

Null-terminated human-readable name for this plugin implementation.

§vtable: *const c_void

Opaque pointer to the interface-specific #[repr(C)] vtable struct.

§free_buffer: Option<unsafe extern "C" fn(*mut u8, usize)>

Deallocation function for plugin-allocated buffers. Must be Some when buffer_strategy == PluginAllocated. The host calls this after reading output data to free the plugin’s allocation.

§method_count: u32

Total number of methods in the vtable (required + optional). Used for bounds checking in call_method.

Implementations§

Source§

impl PluginDescriptor

Source

pub unsafe fn interface_name_str(&self) -> &str

Read the interface_name field as a Rust &str.

§Safety

interface_name must point to a valid, null-terminated, UTF-8 C string that outlives the returned reference.

Source

pub unsafe fn plugin_name_str(&self) -> &str

Read the plugin_name field as a Rust &str.

§Safety

plugin_name must point to a valid, null-terminated, UTF-8 C string that outlives the returned reference.

Source

pub fn buffer_strategy_kind(&self) -> Result<BufferStrategyKind, u8>

Returns the buffer_strategy field as a BufferStrategyKind.

Returns Err(value) if the discriminant is unknown. This can happen with malformed plugins — callers should reject rather than panic.

Source

pub fn wire_format_kind(&self) -> Result<WireFormat, u8>

Returns the wire_format field as a WireFormat.

Returns Err(value) if the discriminant is unknown.

Source

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

Check if the given optional method capability bit is set.

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

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.