pub struct Lock<'a> { /* private fields */ }module only.Expand description
A structure that represents a lock to the application’s ModuleLoader.
Implementations§
Source§impl<'a> Lock<'a>
impl<'a> Lock<'a>
Sourcepub unsafe fn load_builtin(
&mut self,
name: &str,
) -> Result<impl ModuleHandle + '_>
pub unsafe fn load_builtin( &mut self, name: &str, ) -> Result<impl ModuleHandle + '_>
Sourcepub unsafe fn load_self(&mut self, name: &str) -> Result<impl ModuleHandle + '_>
pub unsafe fn load_self(&mut self, name: &str) -> Result<impl ModuleHandle + '_>
Attempts to load a module from the specified name which is dynamically linked in the current running software.
§Arguments
name: the name of the module to be loaded.
returns: Result<&Module, Error>
§Safety
This function assumes the module to be loaded, if it exists has the correct format otherwise this function is UB.
Sourcepub unsafe fn load(&mut self, name: &str) -> Result<impl ModuleHandle + '_>
pub unsafe fn load(&mut self, name: &str) -> Result<impl ModuleHandle + '_>
Attempts to load a module from the specified name.
This function already does check for the version of rustc and dependencies for Rust based modules to ensure maximum ABI compatibility.
This function assumes the code to be loaded is trusted and delegates this operation to the underlying OS.
§Arguments
name: the name of the module to be loaded.
returns: ()
§Safety
It is assumed that the module is intended to be used with this instance of ModuleLoader; if not, this function is UB. Additionally, if some dependency used in public facing APIs for the module are not added with add_public_dependency, this is also UB.
Sourcepub fn add_search_path(&mut self, path: impl AsRef<Path>)
pub fn add_search_path(&mut self, path: impl AsRef<Path>)
Sourcepub fn remove_search_path(&mut self, path: impl AsRef<Path>)
pub fn remove_search_path(&mut self, path: impl AsRef<Path>)
Sourcepub fn add_public_dependency<'b>(
&mut self,
name: &str,
version: &str,
features: impl IntoIterator<Item = &'b str>,
)
pub fn add_public_dependency<'b>( &mut self, name: &str, version: &str, features: impl IntoIterator<Item = &'b str>, )
Adds a public facing API dependency to the list of dependency for version checks.
This is used to check if there are any ABI incompatibilities between dependency versions when loading a Rust based module.
§Arguments
name: the name of the dependency.version: the version of the dependency.
returns: ()
Sourcepub fn get_builtin(&self, name: &str) -> Option<impl ModuleHandle + '_>
pub fn get_builtin(&self, name: &str) -> Option<impl ModuleHandle + '_>
Returns the builtin module identified by the name name, returns None if the module is
not loaded.
Sourcepub fn get_module(&self, name: &str) -> Option<impl ModuleHandle + '_>
pub fn get_module(&self, name: &str) -> Option<impl ModuleHandle + '_>
Returns the module identified by the name name, returns None if the module is
not loaded.