Expand description
Traits and types related to loading an abi_stable dynamic library, as well as functions/modules within.
§Loading the root module
When you use the RootModule
::load_from*
associated functions,
the root module of a library is loaded in this order:
- A
RawLibrary
is loaded (The library is leaked so that the root module loader can do anything incompatible with library unloading.) - An
AbiHeaderRef
handle to the static that contains the root module is obtained. - The
AbiHeaderRef
checks that the abi_stable version used by that library is compatible with the loader’s, upgrading to a&'static LibHeader
on success. - The
LibHeader
checks that the layout of the types in the root module (and everything it references) are compatible with the loader’s - The root module
is loaded using the function from the loaded library
that was annotated with
#[export_root_module]
. RootModule::initialize
is called on the root module.
All steps can return errors.
Re-exports§
pub use self::c_abi_testing::CAbiTestingFns;
pub use self::c_abi_testing::C_ABI_TESTING_FNS;
Modules§
- c_
abi_ testing - This module runs tests on the C abi as defined by Rust, to detect whether Rust changed how it deals with zero-sized types.
- development_
utils - Utilities for use while developing dynamic libraries.
Structs§
- AbiHeader
- Represents the abi_stable version used by a compiled dynamic library,
which if incompatible would produce a
LibraryError::InvalidAbiHeader
- AbiHeader
Ref - A handle to the
AbiHeader
of a library. - LibHeader
- Used to check the layout of modules returned by module-loading functions exported by dynamic libraries.
- RawLibrary
- A handle to any dynamically loaded library, not necessarily ones that export abi_stable compatible modules.
- Root
Module Consts - All the constants of the
RootModule
trait for some erased type.
Enums§
- Check
Type Layout - Tells
LibHeader::from_constructor
whether to include the layout of the root module for checking it when loaded. - IsLayout
Checked - Whether the ABI of a root module is checked.
- Library
Error - All the possible errors that could happen when loading a library, or a module.
- Library
Path - The path a library is loaded from.
- Library
Suffix - What naming convention to expect when loading a library from a directory.
- Root
Module Error - The errors that a
#[export_root_module]
function can return.
Constants§
- ROOT_
MODULE_ LOADER_ NAME - The name of the
static
that contains theLibHeader
of an abi_stable library. - ROOT_
MODULE_ LOADER_ NAME_ NULSTR - A
NulStr
equivalent ofROOT_MODULE_LOADER_NAME
. - ROOT_
MODULE_ LOADER_ NAME_ WITH_ NUL - A nul-terminated equivalent of
ROOT_MODULE_LOADER_NAME
.
Traits§
- Into
Root Module Result - For converting the return value of a
#[export_root_module]
function to aResult<_, RootModuleError>
. - Root
Module - The root module of a dynamic library, which may contain other modules,function pointers,and static references.
Functions§
- abi_
header_ from_ path - Gets the AbiHeaderRef of the library at the path.
- abi_
header_ ⚠from_ raw_ library - Gets the AbiHeaderRef of a library.
- lib_
header_ from_ path - Gets the LibHeader of the library at the path.
- lib_
header_ ⚠from_ raw_ library - Gets the LibHeader of a library.
Type Aliases§
- Root
Module Result - The return type of the function that the
#[export_root_module]
attribute outputs.