Trait Require

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

Source

fn is_require_allowed(&self, chunk_name: &str) -> bool

Returns true if “require” is permitted for the given chunk name.

Source

fn reset(&mut self, chunk_name: &str) -> StdResult<(), NavigateError>

Resets the internal state to point at the requirer module.

Source

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.

Source

fn to_parent(&mut self) -> StdResult<(), NavigateError>

Source

fn to_child(&mut self, name: &str) -> StdResult<(), NavigateError>

Navigate to the given child directory.

Source

fn has_module(&self) -> bool

Returns whether the context is currently pointing at a module

Source

fn cache_key(&self) -> String

Provides a cache key representing the current module.

This function is only called if has_module returns true.

Source

fn has_config(&self) -> bool

Returns whether a configuration is present in the current context.

Source

fn config(&self) -> IoResult<Vec<u8>>

Returns the contents of the configuration file in the current context.

This function is only called if has_config returns true.

Source

fn loader(&self, lua: &Lua) -> Result<Function>

Returns a loader function for the current module, that when called, loads the module and returns the result.

Loader can be sync or async. This function is only called if has_module returns true.

Trait Implementations§

Source§

impl Debug for dyn Require

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementors§