#[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,
) -> PluginDeclaration
pub const fn new( api_version: u32, name: &'static str, version: &'static str, min_protocol: &'static str, ) -> PluginDeclaration
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.
Trait Implementations§
impl Send for PluginDeclaration
impl Sync for PluginDeclaration
Auto Trait Implementations§
impl Freeze for PluginDeclaration
impl RefUnwindSafe for PluginDeclaration
impl Unpin for PluginDeclaration
impl UnsafeUnpin for PluginDeclaration
impl UnwindSafe for PluginDeclaration
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more