pub struct ScriptEngine { /* private fields */ }Expand description
Script engine for executing VibeLang scripts.
The ScriptEngine:
- Creates a Rhai engine with all VibeLang API registered
- Executes scripts that call the API functions
- Collects the resulting ScriptState
§Example
ⓘ
let mut engine = ScriptEngine::new();
let state = engine.execute_file("song.vibe")?;
// Apply state to runtime via reload systemImplementations§
Source§impl ScriptEngine
impl ScriptEngine
Sourcepub fn add_import_path(&mut self, path: impl Into<PathBuf>)
pub fn add_import_path(&mut self, path: impl Into<PathBuf>)
Add import paths for module resolution (native only).
Sourcepub fn execute(&mut self, script: &str) -> Result<ScriptState>
pub fn execute(&mut self, script: &str) -> Result<ScriptState>
Execute a script from a string.
Returns the collected ScriptState that can be applied to a runtime.
Sourcepub fn execute_file(&mut self, path: impl AsRef<Path>) -> Result<ScriptState>
pub fn execute_file(&mut self, path: impl AsRef<Path>) -> Result<ScriptState>
Execute a script from a file (native only).
Returns the collected ScriptState that can be applied to a runtime.
Sourcepub fn execute_ast(&mut self, ast: &AST) -> Result<ScriptState>
pub fn execute_ast(&mut self, ast: &AST) -> Result<ScriptState>
Execute an AST (pre-compiled script).
Sourcepub fn compile(&self, script: &str) -> Result<AST>
pub fn compile(&self, script: &str) -> Result<AST>
Compile a script to AST for repeated execution.
Sourcepub fn compile_file(&self, path: impl AsRef<Path>) -> Result<AST>
pub fn compile_file(&self, path: impl AsRef<Path>) -> Result<AST>
Compile a script file to AST (native only).
Sourcepub fn engine_mut(&mut self) -> &mut Engine
pub fn engine_mut(&mut self) -> &mut Engine
Get a mutable reference to the underlying Rhai engine.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ScriptEngine
impl !RefUnwindSafe for ScriptEngine
impl Send for ScriptEngine
impl Sync for ScriptEngine
impl Unpin for ScriptEngine
impl UnsafeUnpin for ScriptEngine
impl !UnwindSafe for ScriptEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more