Struct abi_stable::library::LibHeader [−][src]
#[repr(C)]pub struct LibHeader { /* fields omitted */ }
Expand description
Used to check the layout of modules returned by module-loading functions exported by dynamic libraries.
Module-loading functions are declared with the export_root_module
attribute.
Implementations
pub const unsafe fn from_constructor<M>(
constructor: Constructor<RootModuleResult>,
root_mod_consts: RootModuleConsts<M>
) -> Self
pub const unsafe fn from_constructor<M>(
constructor: Constructor<RootModuleResult>,
root_mod_consts: RootModuleConsts<M>
) -> Self
Constructs a LibHeader from the root module loader.
Safety
The PrefixRef<ErasedPrefix>
returned by the function that
constructor
wraps must be have been transmuted from a PrefixRef<M>
.
Constructs a LibHeader from the module.
All the important constants of a RootModule
for some erased type.
The version string of the library the module is being loaded from.
Gets the layout of the root module.
This returns a None if the root module layout is not included
because the #[unsafe_no_layout_constant]
helper attribute was used on the function exporting the root module.
Checks that the library is compatible, returning the root module on success.
It checks that these are compatible:
-
The version number of the library
-
The layout of the root module.
Warning
If this function is called within a dynamic library, it must be called at or after the function that exports its root module is called.
DO NOT call this in the static initializer of a dynamic library, since this library relies on setting up its global state before calling the root module loader.
Errors
This returns these errors:
-
LibraryError::ParseVersionError
: If the version strings in the library can’t be parsed as version numbers, this can only happen if the version strings are manually constructed. -
LibraryError::IncompatibleVersionNumber
: If the version number of the library is incompatible. -
LibraryError::AbiInstability
: If the layout of the root module is not the expected one. -
LibraryError::RootModule
: If the root module initializer returned an error or panicked.
pub unsafe fn init_root_module_with_unchecked_layout<M>(
&self
) -> Result<M, LibraryError> where
M: RootModule,
pub unsafe fn init_root_module_with_unchecked_layout<M>(
&self
) -> Result<M, LibraryError> where
M: RootModule,
Checks that the version number of the library is compatible, returning the root module on success.
This function transmutes the root module type, without checking that the layout is compatible first.
Warning
If this function is called within a dynamic library, it must be called at or after the function that exports its root module is called.
DO NOT call this in the static initializer of a dynamic library, since this library relies on setting up its global state before calling the root module loader.
Safety
The caller must ensure that M
has the expected layout.
Errors
This returns these errors:
-
LibraryError::ParseVersionError
: If the version strings in the library can’t be parsed as version numbers, this can only happen if the version strings are manually constructed. -
LibraryError::IncompatibleVersionNumber
: If the version number of the library is incompatible. -
LibraryError::RootModule
: If the root module initializer returned an error or panicked.
Checks that the layout of the M
root module from the dynamic library is
compatible with the expected layout.
Errors
This returns these errors:
-
LibraryError::AbiInstability
: If the layout of the root module is not the expected one. -
LibraryError::RootModule
: If the root module initializer returned an error or panicked.
Gets the root module,first
checking that the layout of the M
from the dynamic library is
compatible with the expected layout.
Errors
This returns these errors:
-
LibraryError::AbiInstability
: If the layout of the root module is not the expected one. -
LibraryError::RootModule
: If the root module initializer returned an error or panicked.
pub unsafe fn unchecked_layout<M>(&self) -> Result<M, RootModuleError> where
M: PrefixRefTrait,
pub unsafe fn unchecked_layout<M>(&self) -> Result<M, RootModuleError> where
M: PrefixRefTrait,
Gets the root module without checking that the layout of M
is the expected one.
This is effectively a transmute.
This is useful if a user keeps a cache of which dynamic libraries have been checked for layout compatibility.
Safety
The caller must ensure that M
has the expected layout.
Errors
This function can return a RootModuleError
because the root module failed to initialize.
Trait Implementations
type StaticEquivalent = _static_LibHeader
type IsNonZeroType = False
type IsNonZeroType = False
Whether this type has a single invalid bit-pattern. Read more
The layout of the type provided by implementors.
const
-equivalents of the associated types.
Auto Trait Implementations
impl RefUnwindSafe for LibHeader
impl UnwindSafe for LibHeader
Blanket Implementations
Mutably borrows from an owned value. Read more
type ForSelf = WithMetadata_<T, T>
type ForSelf = WithMetadata_<T, T>
This is always WithMetadata_<Self, Self>
Compares the address of self
with the address of other
. Read more
Emulates the pipeline operator, allowing method syntax in more places. Read more
The same as piped
except that the function takes &Self
Useful for functions that take &Self
instead of Self
. Read more
The same as piped
, except that the function takes &mut Self
.
Useful for functions that take &mut Self
instead of Self
. Read more
Mutates self using a closure taking self by mutable reference, passing it along the method chain. Read more
Observes the value of self, passing it along unmodified. Useful in long method chains. Read more
Performs a conversion with Into
.
using the turbofish .into_::<_>()
syntax. Read more
Performs a reference to reference conversion with AsRef
,
using the turbofish .as_ref_::<_>()
syntax. Read more
Performs a mutable reference to mutable reference conversion with AsMut
,
using the turbofish .as_mut_::<_>()
syntax. Read more
unsafe fn transmute_element<T>(
self
) -> <Self as CanTransmuteElement<T>>::TransmutedPtr where
Self: CanTransmuteElement<T>,
unsafe fn transmute_element<T>(
self
) -> <Self as CanTransmuteElement<T>>::TransmutedPtr where
Self: CanTransmuteElement<T>,
Transmutes the element type of this pointer.. Read more
type Type = T
type Type = T
This is always Self
.
Converts a value back to the original type.
Converts a mutable reference back to the original type.
alloc
only.Converts a box back to the original type.
Converts a value back to the original type.
Converts a reference back to the original type.
Converts a mutable reference back to the original type.
alloc
only.Converts a box back to the original type.
alloc
only.Converts an Arc back to the original type.
alloc
only.Converts an Rc back to the original type.