[−][src]Struct rhai::module_resolvers::FileModuleResolver
Module resolution service that loads module script files from the file system.
Script files are cached so they are are not reloaded and recompiled in subsequent requests.
The new_with_path
and new_with_path_and_extension
constructor functions
allow specification of a base directory with module path used as a relative path offset
to the base directory. The script file is then forced to be in a specified extension
(default .rhai
).
Examples
use rhai::Engine; use rhai::module_resolvers::FileModuleResolver; // Create a new 'FileModuleResolver' loading scripts from the 'scripts' subdirectory // with file extension '.x'. let resolver = FileModuleResolver::new_with_path_and_extension("./scripts", "x"); let mut engine = Engine::new(); engine.set_module_resolver(Some(resolver));
Implementations
impl FileModuleResolver
[src]
pub fn new_with_path<P: Into<PathBuf>>(path: P) -> Self
[src]
Create a new FileModuleResolver
with a specific base path.
Examples
use rhai::Engine; use rhai::module_resolvers::FileModuleResolver; // Create a new 'FileModuleResolver' loading scripts from the 'scripts' subdirectory // with file extension '.rhai' (the default). let resolver = FileModuleResolver::new_with_path("./scripts"); let mut engine = Engine::new(); engine.set_module_resolver(Some(resolver));
pub fn new_with_path_and_extension<P: Into<PathBuf>, E: Into<String>>(
path: P,
extension: E
) -> Self
[src]
path: P,
extension: E
) -> Self
Create a new FileModuleResolver
with a specific base path and file extension.
The default extension is .rhai
.
Examples
use rhai::Engine; use rhai::module_resolvers::FileModuleResolver; // Create a new 'FileModuleResolver' loading scripts from the 'scripts' subdirectory // with file extension '.x'. let resolver = FileModuleResolver::new_with_path_and_extension("./scripts", "x"); let mut engine = Engine::new(); engine.set_module_resolver(Some(resolver));
pub fn new() -> Self
[src]
Create a new FileModuleResolver
with the current directory as base path.
Examples
use rhai::Engine; use rhai::module_resolvers::FileModuleResolver; // Create a new 'FileModuleResolver' loading scripts from the current directory // with file extension '.rhai' (the default). let resolver = FileModuleResolver::new(); let mut engine = Engine::new(); engine.set_module_resolver(Some(resolver));
pub fn create_module<P: Into<PathBuf>>(
&self,
engine: &Engine,
path: &str
) -> Result<Module, Box<EvalAltResult>>
[src]
&self,
engine: &Engine,
path: &str
) -> Result<Module, Box<EvalAltResult>>
Create a Module
from a file path.
Trait Implementations
impl Debug for FileModuleResolver
[src]
impl Default for FileModuleResolver
[src]
impl ModuleResolver for FileModuleResolver
[src]
Auto Trait Implementations
impl !RefUnwindSafe for FileModuleResolver
impl !Send for FileModuleResolver
impl !Sync for FileModuleResolver
impl Unpin for FileModuleResolver
impl !UnwindSafe for FileModuleResolver
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow(&self) -> &TⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut TⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,