[][src]Struct abi_stable::library::LibHeader

#[repr(C)]
pub struct LibHeader { /* fields omitted */ }

Used to check the layout of modules returned by module-loading functions exported by dynamic libraries.

Methods

impl LibHeader[src]

pub const unsafe fn from_constructor<M>(
    constructor: Constructor<&'static ErasedObject>,
    root_mod_consts: RootModuleConsts<M>
) -> Self
[src]

Constructs a LibHeader from the root module loader.

pub fn from_module<T>(value: &'static T) -> Self where
    T: RootModule
[src]

Constructs a LibHeader from the module.

pub fn root_mod_consts(&self) -> &ErasedRootModuleConsts[src]

All the important constants of a RootModule for some erased type.

pub fn version_strings(&self) -> VersionStrings[src]

The version string of the library the module is being loaded from.

pub fn layout(&self) -> Option<&'static TypeLayout>[src]

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.

pub fn init_root_module<M>(&self) -> Result<&'static M, LibraryError> where
    M: RootModule
[src]

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 will return 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.

pub unsafe fn init_root_module_with_unchecked_layout<M>(
    &self
) -> Result<&'static M, LibraryError> where
    M: RootModule
[src]

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 will return 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.

pub fn check_layout<M>(&self) -> Result<&'static M, LibraryError> where
    M: RootModule
[src]

Gets the root module,first checking that the layout of the M from the dynamic library is compatible with the expected layout.

pub unsafe fn unchecked_layout<M>(&self) -> &'static M[src]

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.

Trait Implementations

impl GetStaticEquivalent_ for LibHeader[src]

type StaticEquivalent = _static_LibHeader

impl SharedStableAbi for LibHeader[src]

type IsNonZeroType = False

Whether this type has a single invalid bit-pattern. Read more

type Kind = __ValueKind

The kind of abi stability of this type,there are 2: Read more

Auto Trait Implementations

Blanket Implementations

impl<This> StableAbi for This where
    This: SharedStableAbi<Kind = ValueKind>, 
[src]

impl<This> TransmuteElement for This where
    This: ?Sized
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> TypeIdentity for T where
    T: ?Sized
[src]

type Type = T

The same type as Self. Read more

impl<T> SelfOps for T where
    T: ?Sized
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The error type returned when the conversion fails.