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>;
// Provided methods
fn to_alias_override(
&mut self,
_alias: &str,
) -> StdResult<(), NavigateError> { ... }
fn to_alias_fallback(
&mut self,
_alias: &str,
) -> StdResult<(), NavigateError> { ... }
}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 receives an exact path from a configuration file. It’s only called when an alias’s path cannot be resolved relative to its configuration file.
Sourcefn to_parent(&mut self) -> StdResult<(), NavigateError>
fn to_parent(&mut self) -> StdResult<(), NavigateError>
Navigates to the parent directory of the current requirer.
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.
Provided Methods§
Sourcefn to_alias_override(&mut self, _alias: &str) -> StdResult<(), NavigateError>
fn to_alias_override(&mut self, _alias: &str) -> StdResult<(), NavigateError>
Provides an initial alias override opportunity prior to searching for configuration files.
If Ok(()) is returned, alias resolution stops here and the internal state
must point at the aliased location.
Sourcefn to_alias_fallback(&mut self, _alias: &str) -> StdResult<(), NavigateError>
fn to_alias_fallback(&mut self, _alias: &str) -> StdResult<(), NavigateError>
Provides a final opportunity to resolve an alias if it cannot be found in configuration files.
If Ok(()) is returned, alias resolution stops here and the internal state
must point at the aliased location.
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".