Trait emf_core_base_rs::library::library_loader::LibraryLoaderAPI[][src]

pub trait LibraryLoaderAPI<'a> {
    type InternalLoader;
    fn to_interface(&self) -> NonNullConst<LibraryLoaderInterface>;
unsafe fn from_interface(
        handler: NonNullConst<LibraryLoaderInterface>
    ) -> Self;
unsafe fn from_void_ptr(handler: NonNullConst<c_void>) -> Self;
unsafe fn load(
        &mut self,
        path: &impl AsRef<Path>
    ) -> Result<InternalLibrary<Owned>, Error>;
unsafe fn unload(
        &mut self,
        internal: InternalLibrary<Owned>
    ) -> Result<(), Error>;
unsafe fn get_data_symbol<O, U>(
        &self,
        internal: &InternalLibrary<O>,
        symbol: &impl AsRef<CStr>,
        caster: impl FnOnce(NonNullConst<c_void>) -> &'a U
    ) -> Result<Symbol<'a, &'a U>, Error>
    where
        O: ImmutableAccessIdentifier
;
unsafe fn get_function_symbol<O, U>(
        &self,
        internal: &InternalLibrary<O>,
        symbol: &impl AsRef<CStr>,
        caster: impl FnOnce(CBaseFn) -> U
    ) -> Result<Symbol<'a, U>, Error>
    where
        O: ImmutableAccessIdentifier
;
unsafe fn get_internal_interface(&self) -> Self::InternalLoader; }

The API of a library loader.

Associated Types

type InternalLoader[src]

Type of the internal loader.

Loading content...

Required methods

fn to_interface(&self) -> NonNullConst<LibraryLoaderInterface>[src]

Fetches a pointer that can be used with the interface.

unsafe fn from_interface(handler: NonNullConst<LibraryLoaderInterface>) -> Self[src]

Construct a new instance from a pointer.

Safety

This function should not be used directly.

unsafe fn from_void_ptr(handler: NonNullConst<c_void>) -> Self[src]

Construct a new instance from a void pointer.

Safety

This function should not be used directly.

unsafe fn load(
    &mut self,
    path: &impl AsRef<Path>
) -> Result<InternalLibrary<Owned>, Error>
[src]

Loads a library. The resulting handle is unique.

Failure

The function fails if loader or path is invalid or the type of the library can not be loaded with the loader.

Return

Handle on success, error otherwise.

Safety

The function crosses the ffi boundary. Direct usage of a LibraryLoaderAPI may break some invariants of the library api, if not handled with care.

unsafe fn unload(
    &mut self,
    internal: InternalLibrary<Owned>
) -> Result<(), Error>
[src]

Unloads a library.

Failure

The function fails if internal is invalid.

Return

Error on failure.

Safety

The function crosses the ffi boundary. Direct usage of a LibraryLoaderAPI may break some invariants of the library api, if not handled with care.

unsafe fn get_data_symbol<O, U>(
    &self,
    internal: &InternalLibrary<O>,
    symbol: &impl AsRef<CStr>,
    caster: impl FnOnce(NonNullConst<c_void>) -> &'a U
) -> Result<Symbol<'a, &'a U>, Error> where
    O: ImmutableAccessIdentifier
[src]

Fetches a data symbol from a library.

Failure

The function fails if internal is invalid or library does not contain symbol.

Note

Some platforms may differentiate between a function-pointer and a data-pointer. See LibraryLoaderAPI::get_function_symbol() for fetching a function.

Return

Symbol on success, error otherwise.

Safety

The function crosses the ffi boundary. Direct usage of a LibraryLoaderAPI may break some invariants of the library api, if not handled with care.

unsafe fn get_function_symbol<O, U>(
    &self,
    internal: &InternalLibrary<O>,
    symbol: &impl AsRef<CStr>,
    caster: impl FnOnce(CBaseFn) -> U
) -> Result<Symbol<'a, U>, Error> where
    O: ImmutableAccessIdentifier
[src]

Fetches a function symbol from a library.

Failure

The function fails if internal is invalid or library does not contain symbol.

Note

Some platforms may differentiate between a function-pointer and a data-pointer. See LibraryLoaderAPI::get_data_symbol() for fetching some data.

Return

Symbol on success, error otherwise.

Safety

The function crosses the ffi boundary. Direct usage of a LibraryLoaderAPI may break some invariants of the library api, if not handled with care.

unsafe fn get_internal_interface(&self) -> Self::InternalLoader[src]

Fetches a pointer to the internal interface.

Return

Pointer to the interface.

Safety

The function crosses the ffi boundary. Direct usage of a LibraryLoaderAPI may break some invariants of the library api, if not handled with care.

Loading content...

Implementors

impl<'a> LibraryLoaderAPI<'a> for NativeLoader<'a>[src]

type InternalLoader = NativeLoaderInternal<'a>

impl<'a> LibraryLoaderAPI<'a> for NativeLoaderInternal<'a>[src]

type InternalLoader = Self

impl<'a> LibraryLoaderAPI<'a> for UnknownLoader<'a>[src]

type InternalLoader = InvalidLoader

Loading content...