pub trait Require {
// Required methods
fn is_require_allowed(&self, chunk_name: &str) -> bool;
fn reset(&mut self, chunk_name: &str) -> StdResult<(), NavigateError>;
fn jump_to_alias(&mut self, path: &str) -> StdResult<(), NavigateError>;
fn to_parent(&mut self) -> StdResult<(), NavigateError>;
fn to_child(&mut self, name: &str) -> StdResult<(), NavigateError>;
fn has_module(&self) -> bool;
fn cache_key(&self) -> String;
fn has_config(&self) -> bool;
fn config(&self) -> IoResult<Vec<u8>>;
fn loader(&self, lua: &Lua) -> Result<Function>;
}
Available on crate feature
luau
only.Expand description
A trait for handling modules loading and navigation in the Luau require-by-string
system.
Required Methods§
Sourcefn is_require_allowed(&self, chunk_name: &str) -> bool
fn is_require_allowed(&self, chunk_name: &str) -> bool
Returns true
if “require” is permitted for the given chunk name.
Sourcefn reset(&mut self, chunk_name: &str) -> StdResult<(), NavigateError>
fn reset(&mut self, chunk_name: &str) -> StdResult<(), NavigateError>
Resets the internal state to point at the requirer module.
Sourcefn jump_to_alias(&mut self, path: &str) -> StdResult<(), NavigateError>
fn jump_to_alias(&mut self, path: &str) -> StdResult<(), NavigateError>
Resets the internal state to point at an aliased module.
This function received an exact path from a configuration file. It’s only called when an alias’s path cannot be resolved relative to its configuration file.
fn to_parent(&mut self) -> StdResult<(), NavigateError>
Sourcefn to_child(&mut self, name: &str) -> StdResult<(), NavigateError>
fn to_child(&mut self, name: &str) -> StdResult<(), NavigateError>
Navigate to the given child directory.
Sourcefn has_module(&self) -> bool
fn has_module(&self) -> bool
Returns whether the context is currently pointing at a module
Sourcefn cache_key(&self) -> String
fn cache_key(&self) -> String
Provides a cache key representing the current module.
This function is only called if has_module
returns true.
Sourcefn has_config(&self) -> bool
fn has_config(&self) -> bool
Returns whether a configuration is present in the current context.