pub trait AddSearcher {
// Required methods
fn add_searcher(
&self,
modules: HashMap<Cow<'static, str>, Cow<'static, str>>,
) -> Result<()>;
fn add_path_searcher<P>(
&self,
modules: HashMap<Cow<'static, str>, P>,
) -> Result<()>
where P: 'static + AsRef<Path> + Send;
fn add_path_searcher_poly<P>(
&self,
modules: HashMap<Cow<'static, str>, P>,
transform: Box<dyn Fn(PathBuf) -> Result<String> + Send>,
) -> Result<()>
where P: 'static + AsRef<Path> + Send;
fn add_closure_searcher(
&self,
modules: HashMap<Cow<'static, str>, Box<dyn for<'ctx> Fn(Context<'ctx>, Table<'ctx>, &str) -> Result<Function<'ctx>> + Send>>,
) -> Result<()>;
fn add_function_searcher(
&self,
modules: HashMap<Cow<'static, str>, for<'ctx> fn(Context<'ctx>, Table<'ctx>, &str) -> Result<Function<'ctx>>>,
) -> Result<()>;
fn add_cat_searcher(
&self,
modules: HashMap<Cow<'static, str>, Box<dyn Cat + Send + Sync>>,
) -> Result<()>;
}
Expand description
Extend rlua::Context
to support require
ing Lua modules by name.
Required Methods§
Sourcefn add_searcher(
&self,
modules: HashMap<Cow<'static, str>, Cow<'static, str>>,
) -> Result<()>
fn add_searcher( &self, modules: HashMap<Cow<'static, str>, Cow<'static, str>>, ) -> Result<()>
Add a HashMap
of Lua modules indexed by module name to Lua’s package.searchers
table in an rlua::Context
, with lookup functionality provided by the
rlua_searcher::Searcher
struct.
Sourcefn add_path_searcher<P>(
&self,
modules: HashMap<Cow<'static, str>, P>,
) -> Result<()>
fn add_path_searcher<P>( &self, modules: HashMap<Cow<'static, str>, P>, ) -> Result<()>
Like add_searcher
, but with modules
values given as paths to files containing
Lua source code to facilitate module reloading.
Sourcefn add_path_searcher_poly<P>(
&self,
modules: HashMap<Cow<'static, str>, P>,
transform: Box<dyn Fn(PathBuf) -> Result<String> + Send>,
) -> Result<()>
fn add_path_searcher_poly<P>( &self, modules: HashMap<Cow<'static, str>, P>, transform: Box<dyn Fn(PathBuf) -> Result<String> + Send>, ) -> Result<()>
Like add_path_searcher
, but with user-provided closure for transforming source
code to Lua.
Sourcefn add_closure_searcher(
&self,
modules: HashMap<Cow<'static, str>, Box<dyn for<'ctx> Fn(Context<'ctx>, Table<'ctx>, &str) -> Result<Function<'ctx>> + Send>>,
) -> Result<()>
fn add_closure_searcher( &self, modules: HashMap<Cow<'static, str>, Box<dyn for<'ctx> Fn(Context<'ctx>, Table<'ctx>, &str) -> Result<Function<'ctx>> + Send>>, ) -> Result<()>
Like add_searcher
, but with user-provided closure for rlua::Context
setup.
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.