Skip to main content

PluginDeclaration

Struct PluginDeclaration 

Source
#[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: u32

Must equal super::PLUGIN_API_VERSION for the plugin to load.

§name_ptr: *const u8

Pointer to the plugin name string (UTF-8, not necessarily null-terminated).

§name_len: usize

Length of the plugin name string in bytes.

§version_ptr: *const u8

Pointer to the plugin version string (semver, UTF-8).

§version_len: usize

Length of the plugin version string in bytes.

§min_protocol_ptr: *const u8

Pointer to the minimum room-protocol version string (semver, UTF-8).

§min_protocol_len: usize

Length of the minimum protocol version string in bytes.

Implementations§

Source§

impl PluginDeclaration

Source

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.

Source

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.

Source

pub unsafe fn version(&self) -> Result<&str, Utf8Error>

Reconstruct the plugin version string.

Returns Err if the bytes are not valid UTF-8.

§Safety

Same as name.

Source

pub unsafe fn min_protocol(&self) -> Result<&str, Utf8Error>

Reconstruct the minimum protocol version string.

Returns Err if the bytes are not valid UTF-8.

§Safety

Same as name.

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, 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.