#[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_nameandplugin_namemust point to valid, null-terminated, UTF-8 C strings with'staticlifetime.vtablemust point to a valid#[repr(C)]vtable struct matching the interface identified byinterface_nameandinterface_hash.- When
buffer_strategy == PluginAllocated,free_buffermust beSome. - All pointed-to data must outlive any
PluginHandlederived from this descriptor.
Fields§
§abi_version: u32Descriptor struct layout version. Must equal ABI_VERSION.
interface_name: *const c_charNull-terminated name of the trait this plugin implements (e.g., "ImageFilter").
interface_hash: u64FNV-1a hash of the required method signatures. Detects ABI drift.
interface_version: u32User-specified interface version from #[plugin_interface(version = N)].
capabilities: u64Bitfield where bit N indicates optional method N is implemented. Supports up to 64 optional methods per interface.
wire_format: u8Wire serialization format this plugin was compiled with.
buffer_strategy: u8Buffer management strategy this plugin’s vtable expects.
plugin_name: *const c_charNull-terminated human-readable name for this plugin implementation.
vtable: *const c_voidOpaque 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: u32Total number of methods in the vtable (required + optional).
Used for bounds checking in call_method.
Implementations§
Source§impl PluginDescriptor
impl PluginDescriptor
Sourcepub unsafe fn interface_name_str(&self) -> &str
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.
Sourcepub unsafe fn plugin_name_str(&self) -> &str
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.
Sourcepub fn buffer_strategy_kind(&self) -> Result<BufferStrategyKind, u8>
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.
Sourcepub fn wire_format_kind(&self) -> Result<WireFormat, u8>
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.
Sourcepub fn has_capability(&self, bit: u32) -> bool
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.