[−][src]Struct abi_stable::library::LibHeader
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
impl LibHeader
[src]
pub const unsafe fn from_constructor<M>(
constructor: Constructor<RootModuleResult>,
root_mod_consts: RootModuleConsts<M>
) -> Self
[src]
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>
.
pub fn from_module<T>(value: T) -> Self where
T: RootModule,
[src]
T: RootModule,
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<M, LibraryError> where
M: RootModule,
[src]
M: RootModule,
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,
[src]
&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.
pub fn check_layout<M>(&self) -> Result<M, LibraryError> where
M: RootModule,
[src]
M: RootModule,
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,
[src]
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
impl GetStaticEquivalent_ for LibHeader
[src]
type StaticEquivalent = _static_LibHeader
impl StableAbi for LibHeader
[src]
type IsNonZeroType = False
Whether this type has a single invalid bit-pattern. Read more
pub const LAYOUT: &'static TypeLayout
[src]
pub const ABI_CONSTS: AbiConsts
[src]
Auto Trait Implementations
impl RefUnwindSafe for LibHeader
[src]
impl Send for LibHeader
[src]
impl Sync for LibHeader
[src]
impl Unpin for LibHeader
[src]
impl UnwindSafe for LibHeader
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> GetWithMetadata for T
[src]
type ForSelf = WithMetadata_<T, T>
This is always WithMetadata_<Self, Self>
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SelfOps for T where
T: ?Sized,
[src]
T: ?Sized,
pub const T: PhantomData<fn() -> Self>
[src]
pub const T_D: PhantomData<Self>
[src]
pub fn assert_ty(self, _other: PhantomData<fn() -> Self>) -> Self
[src]
pub fn assert_ty_ref(&self, _other: PhantomData<fn() -> Self>) -> &Self
[src]
pub fn assert_ty_mut(&mut self, _other: PhantomData<fn() -> Self>) -> &mut Self
[src]
pub fn ty_(&self) -> PhantomData<fn() -> Self>
[src]
pub fn ty_d(&self) -> PhantomData<Self>
[src]
pub fn ty_inv(&self) -> PhantomData<fn(Self) -> Self>
[src]
pub fn ty_inv_ref(&self) -> PhantomData<Cell<&Self>>
[src]
pub fn eq_id(&self, other: &Self) -> bool
[src]
pub fn piped<F, U>(self, f: F) -> U where
F: FnOnce(Self) -> U,
[src]
F: FnOnce(Self) -> U,
pub fn piped_ref<'a, F, U>(&'a self, f: F) -> U where
F: FnOnce(&'a Self) -> U,
[src]
F: FnOnce(&'a Self) -> U,
pub fn piped_mut<'a, F, U>(&'a mut self, f: F) -> U where
F: FnOnce(&'a mut Self) -> U,
[src]
F: FnOnce(&'a mut Self) -> U,
pub fn mutated<F>(self, f: F) -> Self where
F: FnOnce(&mut Self),
[src]
F: FnOnce(&mut Self),
pub fn observe<F>(self, f: F) -> Self where
F: FnOnce(&Self),
[src]
F: FnOnce(&Self),
pub fn into_<T>(self, PhantomData<fn() -> T>) -> T where
Self: Into<T>,
[src]
Self: Into<T>,
pub fn as_ref_<T>(&self) -> &T where
Self: AsRef<T>,
T: ?Sized,
[src]
Self: AsRef<T>,
T: ?Sized,
pub fn as_mut_<T>(&mut self) -> &mut T where
Self: AsMut<T>,
T: ?Sized,
[src]
Self: AsMut<T>,
T: ?Sized,
pub fn drop_(self)
[src]
impl<This> TransmuteElement for This where
This: ?Sized,
[src]
This: ?Sized,
pub unsafe fn transmute_element<T>(self) -> Self::TransmutedPtr where
Self: CanTransmuteElement<T>,
Self::Target: Sized,
[src]
Self: CanTransmuteElement<T>,
Self::Target: Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The error type returned when the conversion fails.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> TypeIdentity for T where
T: ?Sized,
[src]
T: ?Sized,
type Type = T
The same type as Self. Read more
pub fn into_type_val(self) -> Self::Type where
Self::Type: Sized,
[src]
Self::Type: Sized,
pub fn into_type_ref(&self) -> &Self::Type
[src]
pub fn into_type_mut(&mut self) -> &mut Self::Type
[src]
pub fn into_type_box(self: Box<Self, Global>) -> Box<Self::Type, Global>
[src]
pub fn into_type_arc(this: Arc<Self>) -> Arc<Self::Type>
[src]
pub fn into_type_rc(this: Rc<Self>) -> Rc<Self::Type>
[src]
pub fn from_type_val(this: Self::Type) -> Self where
Self::Type: Sized,
[src]
Self::Type: Sized,