pub struct LuaEnv { /* private fields */ }Expand description
Unified Lua environment configuration.
Creates Lua VMs with consistent sandbox, orcs.* functions,
and a unified require() that resolves modules from
configured search paths (filesystem, sandbox-validated).
Implementations§
Source§impl LuaEnv
impl LuaEnv
Sourcepub fn new(sandbox: Arc<dyn SandboxPolicy>) -> Self
pub fn new(sandbox: Arc<dyn SandboxPolicy>) -> Self
Creates a new LuaEnv with the given sandbox policy.
Sourcepub fn with_search_path(self, path: impl AsRef<Path>) -> Self
pub fn with_search_path(self, path: impl AsRef<Path>) -> Self
Adds a search path for require() resolution.
Paths are searched in the order they are added. Each path is validated against the sandbox at require-time.
Sourcepub fn with_search_paths(
self,
paths: impl IntoIterator<Item = impl AsRef<Path>>,
) -> Self
pub fn with_search_paths( self, paths: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Self
Adds multiple search paths.
Sourcepub fn search_paths(&self) -> &[PathBuf]
pub fn search_paths(&self) -> &[PathBuf]
Returns configured search paths.
Sourcepub fn create_lua(&self) -> Result<Lua, LuaError>
pub fn create_lua(&self) -> Result<Lua, LuaError>
Creates a new sandboxed Lua VM.
The returned Lua VM has:
orcs.*functions registered (log, exec, read, write, grep, glob, etc.)- Dangerous Lua stdlib functions disabled
- Custom
require()with sandbox-aware module resolution package.loadedcache for loaded modules
§Errors
Returns error if VM setup fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LuaEnv
impl !RefUnwindSafe for LuaEnv
impl Send for LuaEnv
impl Sync for LuaEnv
impl Unpin for LuaEnv
impl UnsafeUnpin for LuaEnv
impl !UnwindSafe for LuaEnv
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more