#[repr(C)]pub struct PluginDeclaration {
pub api_version: u32,
pub name_ptr: *const u8,
pub name_len: usize,
pub version_ptr: *const u8,
pub version_len: usize,
pub min_protocol_ptr: *const u8,
pub min_protocol_len: usize,
}Expand description
C-compatible plugin metadata exported as a #[no_mangle] static from
each cdylib plugin.
The loader reads this before calling CreateFn to verify that the
plugin’s API version and protocol requirements are compatible with the
running broker.
Use PluginDeclaration::new to construct in a static context.
Fields§
§api_version: u32Must equal super::PLUGIN_API_VERSION for the plugin to load.
name_ptr: *const u8Pointer to the plugin name string (UTF-8, not necessarily null-terminated).
name_len: usizeLength of the plugin name string in bytes.
version_ptr: *const u8Pointer to the plugin version string (semver, UTF-8).
version_len: usizeLength of the plugin version string in bytes.
min_protocol_ptr: *const u8Pointer to the minimum room-protocol version string (semver, UTF-8).
min_protocol_len: usizeLength of the minimum protocol version string in bytes.
Implementations§
Source§impl PluginDeclaration
impl PluginDeclaration
Sourcepub const fn new(
api_version: u32,
name: &'static str,
version: &'static str,
min_protocol: &'static str,
) -> Self
pub const fn new( api_version: u32, name: &'static str, version: &'static str, min_protocol: &'static str, ) -> Self
Construct a declaration from static string slices. All arguments must
be 'static — this is enforced by the function signature and is
required because the declaration is stored as a static.
Sourcepub unsafe fn name(&self) -> Result<&str, Utf8Error>
pub unsafe fn name(&self) -> Result<&str, Utf8Error>
Reconstruct the plugin name.
Returns Err if the bytes are not valid UTF-8.
§Safety
The declaration must still be valid — i.e. the shared library that exported it must not have been unloaded, and the pointer/length pair must point to a valid byte slice.