Macro abi_stable::declare_root_module_statics

source ·
macro_rules! declare_root_module_statics {
    ( ( $($stuff:tt)* ) ) => { ... };
    ( Self ) => { ... };
    ( $this:ty ) => { ... };
}
Expand description

Implements the RootModule::root_module_statics associated function.

To define the associated function use: abi_stable::declare_root_module_statics!{TypeOfSelf}. Passing Self instead of TypeOfSelf won’t work.

§Example

use abi_stable::{
    library::RootModule,
    sabi_types::VersionStrings,
    StableAbi,
};

#[repr(C)]
#[derive(StableAbi)]
#[sabi(kind(Prefix(prefix_ref = Module_Ref, prefix_fields = Module_Prefix)))]
pub struct Module{
    pub first: u8,
    #[sabi(last_prefix_field)]
    pub second: u16,
    pub third: u32,
}
impl RootModule for Module_Ref {
    abi_stable::declare_root_module_statics!{Module_Ref}
    const BASE_NAME: &'static str = "example_root_module";
    const NAME: &'static str = "example_root_module";
    const VERSION_STRINGS: VersionStrings = abi_stable::package_version_strings!();
}