pub trait LibraryAPI<'interface> {
Show 17 methods
// Required methods
fn register_loader<'loader, LT, L>(
&mut self,
loader: &'loader LT,
lib_type: &impl AsRef<str>,
) -> Result<Loader<'interface, Owned>, Error>
where L: LibraryLoaderAPI<'static>,
LibraryLoader<L, Owned>: From<&'loader LT>;
fn unregister_loader(
&mut self,
loader: Loader<'_, Owned>,
) -> Result<(), Error>;
fn get_loader_interface<'loader, O, L>(
&mut self,
loader: &Loader<'loader, O>,
) -> Result<LibraryLoader<L, O>, Error>
where O: ImmutableAccessIdentifier,
L: LibraryLoaderAPI<'loader> + LibraryLoaderABICompat;
fn get_loader_handle_from_type(
&self,
lib_type: &impl AsRef<str>,
) -> Result<Loader<'interface, BorrowMutable<'_>>, Error>;
fn get_loader_handle_from_library<'library, O>(
&self,
library: &Library<'library, O>,
) -> Result<Loader<'library, BorrowMutable<'_>>, Error>
where O: ImmutableAccessIdentifier;
fn get_num_loaders(&self) -> usize;
fn library_exists<'library, O>(
&self,
library: &Library<'library, O>,
) -> bool
where O: ImmutableAccessIdentifier;
fn type_exists(&self, lib_type: &impl AsRef<str>) -> Result<bool, Error>;
fn get_library_types(
&self,
buffer: impl AsMut<[LibraryType]>,
) -> Result<usize, Error>;
unsafe fn create_library_handle(&mut self) -> Library<'interface, Owned>;
unsafe fn remove_library_handle(
&mut self,
library: Library<'_, Owned>,
) -> Result<(), Error>;
unsafe fn link_library<'library, 'loader, O, LO, IO>(
&mut self,
library: &Library<'library, O>,
loader: &Loader<'loader, LO>,
internal: &InternalLibrary<IO>,
) -> Result<(), Error>
where O: MutableAccessIdentifier,
LO: ImmutableAccessIdentifier,
IO: ImmutableAccessIdentifier,
'loader: 'library;
fn get_internal_library_handle<'library, O>(
&self,
library: &Library<'library, O>,
) -> Result<InternalLibrary<O>, Error>
where O: ImmutableAccessIdentifier;
fn load<O>(
&mut self,
loader: &Loader<'interface, O>,
path: &impl AsRef<Path>,
) -> Result<Library<'interface, Owned>, Error>
where O: MutableAccessIdentifier;
fn unload(&mut self, library: Library<'_, Owned>) -> Result<(), Error>;
fn get_data_symbol<'library, 'handle, O, U>(
&self,
library: &'handle Library<'library, O>,
symbol: &impl AsRef<CStr>,
caster: impl FnOnce(NonNullConst<c_void>) -> &'library U,
) -> Result<Symbol<'handle, &'library U>, Error>
where O: ImmutableAccessIdentifier;
fn get_function_symbol<'library, 'handle, O, U>(
&self,
library: &'handle Library<'library, O>,
symbol: &impl AsRef<CStr>,
caster: impl FnOnce(CBaseFn) -> U,
) -> Result<Symbol<'handle, U>, Error>
where O: ImmutableAccessIdentifier;
}
Expand description
Idiomatic library api.
Required Methods§
Sourcefn register_loader<'loader, LT, L>(
&mut self,
loader: &'loader LT,
lib_type: &impl AsRef<str>,
) -> Result<Loader<'interface, Owned>, Error>
fn register_loader<'loader, LT, L>( &mut self, loader: &'loader LT, lib_type: &impl AsRef<str>, ) -> Result<Loader<'interface, Owned>, Error>
Sourcefn get_loader_interface<'loader, O, L>(
&mut self,
loader: &Loader<'loader, O>,
) -> Result<LibraryLoader<L, O>, Error>
fn get_loader_interface<'loader, O, L>( &mut self, loader: &Loader<'loader, O>, ) -> Result<LibraryLoader<L, O>, Error>
Sourcefn get_loader_handle_from_type(
&self,
lib_type: &impl AsRef<str>,
) -> Result<Loader<'interface, BorrowMutable<'_>>, Error>
fn get_loader_handle_from_type( &self, lib_type: &impl AsRef<str>, ) -> Result<Loader<'interface, BorrowMutable<'_>>, Error>
Sourcefn get_loader_handle_from_library<'library, O>(
&self,
library: &Library<'library, O>,
) -> Result<Loader<'library, BorrowMutable<'_>>, Error>where
O: ImmutableAccessIdentifier,
fn get_loader_handle_from_library<'library, O>(
&self,
library: &Library<'library, O>,
) -> Result<Loader<'library, BorrowMutable<'_>>, Error>where
O: ImmutableAccessIdentifier,
Sourcefn get_num_loaders(&self) -> usize
fn get_num_loaders(&self) -> usize
Sourcefn library_exists<'library, O>(&self, library: &Library<'library, O>) -> boolwhere
O: ImmutableAccessIdentifier,
fn library_exists<'library, O>(&self, library: &Library<'library, O>) -> boolwhere
O: ImmutableAccessIdentifier,
Sourcefn get_library_types(
&self,
buffer: impl AsMut<[LibraryType]>,
) -> Result<usize, Error>
fn get_library_types( &self, buffer: impl AsMut<[LibraryType]>, ) -> Result<usize, Error>
Sourceunsafe fn create_library_handle(&mut self) -> Library<'interface, Owned>
unsafe fn create_library_handle(&mut self) -> Library<'interface, Owned>
Sourceunsafe fn remove_library_handle(
&mut self,
library: Library<'_, Owned>,
) -> Result<(), Error>
unsafe fn remove_library_handle( &mut self, library: Library<'_, Owned>, ) -> Result<(), Error>
Sourceunsafe fn link_library<'library, 'loader, O, LO, IO>(
&mut self,
library: &Library<'library, O>,
loader: &Loader<'loader, LO>,
internal: &InternalLibrary<IO>,
) -> Result<(), Error>where
O: MutableAccessIdentifier,
LO: ImmutableAccessIdentifier,
IO: ImmutableAccessIdentifier,
'loader: 'library,
unsafe fn link_library<'library, 'loader, O, LO, IO>(
&mut self,
library: &Library<'library, O>,
loader: &Loader<'loader, LO>,
internal: &InternalLibrary<IO>,
) -> Result<(), Error>where
O: MutableAccessIdentifier,
LO: ImmutableAccessIdentifier,
IO: ImmutableAccessIdentifier,
'loader: 'library,
Links a library handle to an internal library handle.
Overrides the internal link of the library handle by setting it to the new library loader and internal handle.
§Failure
The function fails if library
or loader
are invalid.
§Return
Error on failure.
§Safety
Incorrect usage can lead to dangling handles or use-after-free errors.
Sourcefn get_internal_library_handle<'library, O>(
&self,
library: &Library<'library, O>,
) -> Result<InternalLibrary<O>, Error>where
O: ImmutableAccessIdentifier,
fn get_internal_library_handle<'library, O>(
&self,
library: &Library<'library, O>,
) -> Result<InternalLibrary<O>, Error>where
O: ImmutableAccessIdentifier,
Sourcefn load<O>(
&mut self,
loader: &Loader<'interface, O>,
path: &impl AsRef<Path>,
) -> Result<Library<'interface, Owned>, Error>where
O: MutableAccessIdentifier,
fn load<O>(
&mut self,
loader: &Loader<'interface, O>,
path: &impl AsRef<Path>,
) -> Result<Library<'interface, Owned>, Error>where
O: MutableAccessIdentifier,
Sourcefn get_data_symbol<'library, 'handle, O, U>(
&self,
library: &'handle Library<'library, O>,
symbol: &impl AsRef<CStr>,
caster: impl FnOnce(NonNullConst<c_void>) -> &'library U,
) -> Result<Symbol<'handle, &'library U>, Error>where
O: ImmutableAccessIdentifier,
fn get_data_symbol<'library, 'handle, O, U>(
&self,
library: &'handle Library<'library, O>,
symbol: &impl AsRef<CStr>,
caster: impl FnOnce(NonNullConst<c_void>) -> &'library U,
) -> Result<Symbol<'handle, &'library U>, Error>where
O: ImmutableAccessIdentifier,
Fetches a data symbol from a library.
§Failure
The function fails if library
is invalid or library does not contain symbol
.
§Note
Some platforms may differentiate between a function-pointer
and a data-pointer
.
See LibraryAPI::get_function_symbol() for fetching a function.
§Return
Symbol on success, error otherwise.
Sourcefn get_function_symbol<'library, 'handle, O, U>(
&self,
library: &'handle Library<'library, O>,
symbol: &impl AsRef<CStr>,
caster: impl FnOnce(CBaseFn) -> U,
) -> Result<Symbol<'handle, U>, Error>where
O: ImmutableAccessIdentifier,
fn get_function_symbol<'library, 'handle, O, U>(
&self,
library: &'handle Library<'library, O>,
symbol: &impl AsRef<CStr>,
caster: impl FnOnce(CBaseFn) -> U,
) -> Result<Symbol<'handle, U>, Error>where
O: ImmutableAccessIdentifier,
Fetches a function symbol from a library.
§Failure
The function fails if library
is invalid or library does not contain symbol
.
§Note
Some platforms may differentiate between a function-pointer
and a data-pointer
.
See LibraryAPI::get_data_symbol() for fetching some data.
§Return
Symbol on success, error otherwise.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.