Trait stabby::libloading::StabbyLibrary

source ·
pub trait StabbyLibrary {
    // Required methods
    unsafe fn get_stabbied<'a, T: IStable>(
        &'a self,
        symbol: &[u8],
    ) -> Result<Symbol<'a, T>, Box<dyn Error + Send + Sync>>;
    unsafe fn get_canaried<'a, T>(
        &'a self,
        symbol: &[u8],
    ) -> Result<Symbol<'a, T>, Box<dyn Error + Send + Sync>>;
}
Expand description

An extension trait to load symbols from libraries while checking for ABI-compatibility.

Required Methods§

source

unsafe fn get_stabbied<'a, T: IStable>( &'a self, symbol: &[u8], ) -> Result<Symbol<'a, T>, Box<dyn Error + Send + Sync>>

Gets symbol from the library, using stabby’s reports to check for compatibility.

The library must have a symbol with the appropriate type named the same way, and marked with #[stabby::export].

§Safety

Since this function calls foreign code, it is inherently unsafe.

§Errors

If the symbol is not found OR reflection indicated an ABI-mismatch.

The symbol missing can mean that the library was compiled with a different version of stabby, or that the symbol was not exported with #[stabby::export].

In case of ABI-mismatch, the error will contain a message indicating the expected and found type layouts.

source

unsafe fn get_canaried<'a, T>( &'a self, symbol: &[u8], ) -> Result<Symbol<'a, T>, Box<dyn Error + Send + Sync>>

Gets symbol from the library, using stabby’s canaries to check for compatibility.

The library must have a symbol with the appropriate type named the same way, and marked with #[stabby::export(canaries)].

Note that while canaries greatly improve the chance ABI compatibility, they don’t guarantee it.

§Safety

The symbol on the other side of the FFI boundary cannot be type-checked, and may still have a different ABI than expected (although the canaries should greatly reduce that risk).

§Errors

If the symbol is not found OR the canaries were not found.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl StabbyLibrary for Library

source§

unsafe fn get_stabbied<'a, T: IStable>( &'a self, symbol: &[u8], ) -> Result<Symbol<'a, T>, Box<dyn Error + Send + Sync>>

Gets symbol from the library, using stabby’s reports to check for compatibility.

The library must have a symbol with the appropriate type named the same way, and marked with #[stabby::export].

§Safety

Since this function calls foreign code, it is inherently unsafe.

source§

unsafe fn get_canaried<'a, T>( &'a self, symbol: &[u8], ) -> Result<Symbol<'a, T>, Box<dyn Error + Send + Sync>>

Gets symbol from the library, using stabby’s canaries to check for compatibility.

The library must have a symbol with the appropriate type named the same way, and marked with #[stabby::export(canaries)].

Note that while canaries greatly improve the chance ABI compatibility, they don’t guarantee it.

§Safety

The symbol on the other side of the FFI boundary cannot be type-checked, and may still have a different ABI than expected (although the canaries should greatly reduce that risk).

Implementors§