Trait ModuleLoaderAPI

Source
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§

Source

type InternalLoader

Type of the internal loader.

Required Methods§

Source

fn to_interface(&self) -> NonNullConst<ModuleLoaderInterface>

Fetches a pointer that can be used with the interface.

Source

unsafe fn from_interface(handler: NonNullConst<ModuleLoaderInterface>) -> Self

Construct a new instance from a pointer.

§Safety

This function should not be used directly.

Source

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

Construct a new instance from a void pointer.

§Safety

This function should not be used directly.

Source

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.

Source

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.

Source

unsafe fn load<O>( &mut self, module: &mut InternalModule<O>, ) -> Result<(), Error>

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.

Source

unsafe fn unload<O>( &mut self, module: &mut InternalModule<O>, ) -> Result<(), Error>

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.

Source

unsafe fn initialize<O>( &mut self, module: &mut InternalModule<O>, ) -> Result<(), Error>

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.

Source

unsafe fn terminate<O>( &mut self, module: &mut InternalModule<O>, ) -> Result<(), Error>

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.

Source

unsafe fn fetch_status<O>( &self, module: &InternalModule<O>, ) -> Result<ModuleStatus, Error>

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.

Source

unsafe fn get_interface<'module, O, T>( &self, module: &'module InternalModule<O>, interface: &InterfaceDescriptor, caster: impl FnOnce(Interface) -> T, ) -> Result<Interface<'module, T>, Error>

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.

Source

unsafe fn get_module_info<'module, O>( &self, module: &'module InternalModule<O>, ) -> Result<&'module ModuleInfo, Error>

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.

Source

unsafe fn get_module_path<'module, O>( &self, module: &'module InternalModule<O>, ) -> Result<&'module [OSPathChar], Error>

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.

Source

unsafe fn get_load_dependencies<'module, O>( &self, module: &'module InternalModule<O>, ) -> Result<&'module [InterfaceDescriptor], Error>

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.

Source

unsafe fn get_runtime_dependencies<'module, O>( &self, module: &'module InternalModule<O>, ) -> Result<&'module [InterfaceDescriptor], Error>

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.

Source

unsafe fn get_exportable_interfaces<'module, O>( &self, module: &'module InternalModule<O>, ) -> Result<&'module [InterfaceDescriptor], Error>

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.

Source

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.

Implementors§