pub trait ModuleLoaderAPI<'a> {
type InternalLoader;
Show 17 methods
// Required methods
fn to_interface(&self) -> NonNullConst<ModuleLoaderInterface>;
unsafe fn from_interface(
handler: NonNullConst<ModuleLoaderInterface>,
) -> Self;
unsafe fn from_void_ptr(handler: NonNullConst<c_void>) -> Self;
unsafe fn add_module(
&mut self,
path: &impl AsRef<Path>,
) -> Result<InternalModule<Owned>, Error>;
unsafe fn remove_module(
&mut self,
module: InternalModule<Owned>,
) -> Result<(), Error>;
unsafe fn load<O>(
&mut self,
module: &mut InternalModule<O>,
) -> Result<(), Error>
where O: MutableAccessIdentifier;
unsafe fn unload<O>(
&mut self,
module: &mut InternalModule<O>,
) -> Result<(), Error>
where O: MutableAccessIdentifier;
unsafe fn initialize<O>(
&mut self,
module: &mut InternalModule<O>,
) -> Result<(), Error>
where O: MutableAccessIdentifier;
unsafe fn terminate<O>(
&mut self,
module: &mut InternalModule<O>,
) -> Result<(), Error>
where O: MutableAccessIdentifier;
unsafe fn fetch_status<O>(
&self,
module: &InternalModule<O>,
) -> Result<ModuleStatus, Error>
where O: ImmutableAccessIdentifier;
unsafe fn get_interface<'module, O, T>(
&self,
module: &'module InternalModule<O>,
interface: &InterfaceDescriptor,
caster: impl FnOnce(Interface) -> T,
) -> Result<Interface<'module, T>, Error>
where O: ImmutableAccessIdentifier;
unsafe fn get_module_info<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module ModuleInfo, Error>
where O: ImmutableAccessIdentifier;
unsafe fn get_module_path<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module [OSPathChar], Error>
where O: ImmutableAccessIdentifier;
unsafe fn get_load_dependencies<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module [InterfaceDescriptor], Error>
where O: ImmutableAccessIdentifier;
unsafe fn get_runtime_dependencies<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module [InterfaceDescriptor], Error>
where O: ImmutableAccessIdentifier;
unsafe fn get_exportable_interfaces<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module [InterfaceDescriptor], Error>
where O: ImmutableAccessIdentifier;
unsafe fn get_internal_interface(&self) -> Self::InternalLoader;
}
Expand description
The API of a module loader.
Required Associated Types§
Sourcetype InternalLoader
type InternalLoader
Type of the internal loader.
Required Methods§
Sourcefn to_interface(&self) -> NonNullConst<ModuleLoaderInterface>
fn to_interface(&self) -> NonNullConst<ModuleLoaderInterface>
Fetches a pointer that can be used with the interface.
Sourceunsafe fn from_interface(handler: NonNullConst<ModuleLoaderInterface>) -> Self
unsafe fn from_interface(handler: NonNullConst<ModuleLoaderInterface>) -> Self
Sourceunsafe fn from_void_ptr(handler: NonNullConst<c_void>) -> Self
unsafe fn from_void_ptr(handler: NonNullConst<c_void>) -> Self
Sourceunsafe fn add_module(
&mut self,
path: &impl AsRef<Path>,
) -> Result<InternalModule<Owned>, Error>
unsafe fn add_module( &mut self, path: &impl AsRef<Path>, ) -> Result<InternalModule<Owned>, Error>
Adds a new module.
§Failure
Fails if path
is invalid or the type of the
module can not be loaded with the loader.
§Return
Module handle on success, error otherwise.
§Safety
The function crosses the ffi boundary. Direct usage of a ModuleLoaderAPI may break some invariants of the module api, if not handled with care.
Sourceunsafe fn remove_module(
&mut self,
module: InternalModule<Owned>,
) -> Result<(), Error>
unsafe fn remove_module( &mut self, module: InternalModule<Owned>, ) -> Result<(), Error>
Removes a module.
§Failure
Fails if handle
is invalid or the module is not in an unloaded state.
§Return
Error on failure.
§Safety
The function crosses the ffi boundary. Direct usage of a ModuleLoaderAPI may break some invariants of the module api, if not handled with care.
Sourceunsafe fn load<O>(
&mut self,
module: &mut InternalModule<O>,
) -> Result<(), Error>where
O: MutableAccessIdentifier,
unsafe fn load<O>(
&mut self,
module: &mut InternalModule<O>,
) -> Result<(), Error>where
O: MutableAccessIdentifier,
Loads a module.
§Failure
Fails if handle
is invalid, the load dependencies of the module are
not exported or the module is not in an unloaded state.
§Return
Error on failure.
§Safety
The function crosses the ffi boundary. Direct usage of a ModuleLoaderAPI may break some invariants of the module api, if not handled with care.
Sourceunsafe fn unload<O>(
&mut self,
module: &mut InternalModule<O>,
) -> Result<(), Error>where
O: MutableAccessIdentifier,
unsafe fn unload<O>(
&mut self,
module: &mut InternalModule<O>,
) -> Result<(), Error>where
O: MutableAccessIdentifier,
Unloads a module.
§Failure
Fails if handle
is invalid or the module is in an unloaded or ready state.
§Return
Error on failure.
§Safety
The function crosses the ffi boundary. Direct usage of a ModuleLoaderAPI may break some invariants of the module api, if not handled with care.
Sourceunsafe fn initialize<O>(
&mut self,
module: &mut InternalModule<O>,
) -> Result<(), Error>where
O: MutableAccessIdentifier,
unsafe fn initialize<O>(
&mut self,
module: &mut InternalModule<O>,
) -> Result<(), Error>where
O: MutableAccessIdentifier,
Initializes a module.
§Failure
Fails if handle
is invalid, the runtime dependencies of the
module are not exported or the module is not in a loaded state.
§Return
Error on failure.
§Safety
The function crosses the ffi boundary. Direct usage of a ModuleLoaderAPI may break some invariants of the module api, if not handled with care.
Sourceunsafe fn terminate<O>(
&mut self,
module: &mut InternalModule<O>,
) -> Result<(), Error>where
O: MutableAccessIdentifier,
unsafe fn terminate<O>(
&mut self,
module: &mut InternalModule<O>,
) -> Result<(), Error>where
O: MutableAccessIdentifier,
Terminates a module.
§Failure
Fails if handle
is invalid or the module is not in a ready state.
§Return
Error on failure.
§Safety
The function crosses the ffi boundary. Direct usage of a ModuleLoaderAPI may break some invariants of the module api, if not handled with care.
Sourceunsafe fn fetch_status<O>(
&self,
module: &InternalModule<O>,
) -> Result<ModuleStatus, Error>where
O: ImmutableAccessIdentifier,
unsafe fn fetch_status<O>(
&self,
module: &InternalModule<O>,
) -> Result<ModuleStatus, Error>where
O: ImmutableAccessIdentifier,
Fetches the load status of a module.
§Failure
Fails if handle
is invalid.
§Return
Module status on success, error otherwise.
§Safety
The function crosses the ffi boundary. Direct usage of a ModuleLoaderAPI may break some invariants of the module api, if not handled with care.
Sourceunsafe fn get_interface<'module, O, T>(
&self,
module: &'module InternalModule<O>,
interface: &InterfaceDescriptor,
caster: impl FnOnce(Interface) -> T,
) -> Result<Interface<'module, T>, Error>where
O: ImmutableAccessIdentifier,
unsafe fn get_interface<'module, O, T>(
&self,
module: &'module InternalModule<O>,
interface: &InterfaceDescriptor,
caster: impl FnOnce(Interface) -> T,
) -> Result<Interface<'module, T>, Error>where
O: ImmutableAccessIdentifier,
Fetches an interface from a module.
§Failure
Fails if handle
is invalid, the module is not in a ready
state or the interface is not contained in the module.
§Return
Interface on success, error otherwise.
§Safety
The function crosses the ffi boundary. Direct usage of a ModuleLoaderAPI may break some invariants of the module api, if not handled with care.
Sourceunsafe fn get_module_info<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module ModuleInfo, Error>where
O: ImmutableAccessIdentifier,
unsafe fn get_module_info<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module ModuleInfo, Error>where
O: ImmutableAccessIdentifier,
Fetches the module info from a module.
§Failure
Fails if handle
is invalid or the module is not yet loaded.
§Return
Module info on success, error otherwise.
§Safety
The function crosses the ffi boundary. Direct usage of a ModuleLoaderAPI may break some invariants of the module api, if not handled with care.
Sourceunsafe fn get_module_path<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module [OSPathChar], Error>where
O: ImmutableAccessIdentifier,
unsafe fn get_module_path<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module [OSPathChar], Error>where
O: ImmutableAccessIdentifier,
Fetches the path a module was loaded from.
The resulting slice is terminated with a \0
character.
§Failure
Fails if handle
is invalid or the module is not yet loaded.
§Return
Module path on success, error otherwise.
§Safety
The function crosses the ffi boundary. Direct usage of a ModuleLoaderAPI may break some invariants of the module api, if not handled with care.
Sourceunsafe fn get_load_dependencies<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module [InterfaceDescriptor], Error>where
O: ImmutableAccessIdentifier,
unsafe fn get_load_dependencies<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module [InterfaceDescriptor], Error>where
O: ImmutableAccessIdentifier,
Fetches the load dependencies of a module.
§Failure
Fails if handle
is invalid.
§Return
Load dependencies on success, error otherwise.
§Safety
The function crosses the ffi boundary. Direct usage of a ModuleLoaderAPI may break some invariants of the module api, if not handled with care.
Sourceunsafe fn get_runtime_dependencies<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module [InterfaceDescriptor], Error>where
O: ImmutableAccessIdentifier,
unsafe fn get_runtime_dependencies<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module [InterfaceDescriptor], Error>where
O: ImmutableAccessIdentifier,
Fetches the runtime dependencies of a module.
§Failure
Fails if handle
is invalid or the module is not yet loaded.
§Return
Runtime dependencies on success, error otherwise.
§Safety
The function crosses the ffi boundary. Direct usage of a ModuleLoaderAPI may break some invariants of the module api, if not handled with care.
Sourceunsafe fn get_exportable_interfaces<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module [InterfaceDescriptor], Error>where
O: ImmutableAccessIdentifier,
unsafe fn get_exportable_interfaces<'module, O>(
&self,
module: &'module InternalModule<O>,
) -> Result<&'module [InterfaceDescriptor], Error>where
O: ImmutableAccessIdentifier,
Fetches the exportable interfaces of a module.
§Failure
Fails if handle
is invalid or the module is not yet loaded.
§Return
Exportable interfaces on success, error otherwise.
§Safety
The function crosses the ffi boundary. Direct usage of a ModuleLoaderAPI may break some invariants of the module api, if not handled with care.
Sourceunsafe fn get_internal_interface(&self) -> Self::InternalLoader
unsafe fn get_internal_interface(&self) -> Self::InternalLoader
Fetches a pointer to the internal loader interface.
§Return
Pointer to the loader interface.
§Safety
The function crosses the ffi boundary. Direct usage of a ModuleLoaderAPI may break some invariants of the module api, if not handled with care.
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.