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

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.

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.

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

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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

This is always WithMetadata_<Self, Self>

Performs the conversion.

Gets a reference to a field, determined by offset. Read more

Gets a muatble reference to a field, determined by offset. Read more

Gets a const pointer to a field, the field is determined by offset. Read more

Gets a mutable pointer to a field, determined by offset. Read more

Replaces a field (determined by offset) with value, returning the previous value of the field. Read more

Swaps a field (determined by offset) with the same field in right. Read more

Gets a copy of a field (determined by offset). The field is determined by offset. Read more

Replaces a field (determined by offset) with value, returning the previous value of the field. Read more

Swaps a field (determined by offset) with the same field in right. Read more

Gets a copy of a field (determined by offset). The field is determined by offset. Read more

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

Drops self using method notation. Alternative to std::mem::drop. Read more

Transmutes the element type of this pointer.. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

This is always Self.

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.

This is supported on crate feature alloc only.

Converts a box back to the original type.

This is supported on crate feature alloc only.

Converts an Arc back to the original type. Read more

This is supported on crate feature alloc only.

Converts an Rc back to the original type. Read more

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.

This is supported on crate feature alloc only.

Converts a box back to the original type.

This is supported on crate feature alloc only.

Converts an Arc back to the original type.

This is supported on crate feature alloc only.

Converts an Rc back to the original type.