pub struct LuaRuntime { /* private fields */ }Expand description
Manages the Lua state for extensions.
Implementations§
Source§impl LuaRuntime
impl LuaRuntime
Sourcepub fn tools(&self) -> Arc<Mutex<Vec<LuaToolHandle>>>
pub fn tools(&self) -> Arc<Mutex<Vec<LuaToolHandle>>>
Get a clone of the tools handle for external access.
Sourcepub fn hooks(&self) -> Arc<Mutex<Vec<LuaHookHandle>>>
pub fn hooks(&self) -> Arc<Mutex<Vec<LuaHookHandle>>>
Get a clone of the hooks handle for external access.
Sourcepub fn commands(&self) -> Arc<Mutex<Vec<LuaCommandHandle>>>
pub fn commands(&self) -> Arc<Mutex<Vec<LuaCommandHandle>>>
Get a clone of the commands handle for external access.
Sourcepub fn native_tools(&self) -> Arc<Mutex<HashMap<String, Arc<dyn Tool>>>>
pub fn native_tools(&self) -> Arc<Mutex<HashMap<String, Arc<dyn Tool>>>>
Get a clone of the native tools map.
Sourcepub fn call_context(&self) -> Arc<Mutex<Option<LuaCallContext>>>
pub fn call_context(&self) -> Arc<Mutex<Option<LuaCallContext>>>
Get a clone of the call context handle.
Sourcepub fn allowed_env(&self) -> Arc<Mutex<HashSet<String>>>
pub fn allowed_env(&self) -> Arc<Mutex<HashSet<String>>>
Get a clone of the allowed-env handle.
Sourcepub fn allow_shell_exec(&self) -> Arc<AtomicBool>
pub fn allow_shell_exec(&self) -> Arc<AtomicBool>
Get whether imp.exec() calls are currently permitted.
Sourcepub fn allow_http(&self) -> Arc<AtomicBool>
pub fn allow_http(&self) -> Arc<AtomicBool>
Get whether imp.http.* calls are currently permitted.
Sourcepub fn allow_secrets(&self) -> Arc<AtomicBool>
pub fn allow_secrets(&self) -> Arc<AtomicBool>
Get whether secret access is currently permitted.
Sourcepub fn allow_native_tool_calls(&self) -> Arc<AtomicBool>
pub fn allow_native_tool_calls(&self) -> Arc<AtomicBool>
Get whether imp.tool() calls are currently permitted.
Sourcepub fn set_native_tools(&self, tools: HashMap<String, Arc<dyn Tool>>)
pub fn set_native_tools(&self, tools: HashMap<String, Arc<dyn Tool>>)
Populate the native tool registry (called once after tools are registered).
Sourcepub fn set_call_context(&self, ctx: LuaCallContext)
pub fn set_call_context(&self, ctx: LuaCallContext)
Set the call context before executing a Lua tool function.
Sourcepub fn clear_call_context(&self)
pub fn clear_call_context(&self)
Clear the call context after execution.
Sourcepub fn set_allowed_env(&self, vars: HashSet<String>)
pub fn set_allowed_env(&self, vars: HashSet<String>)
Set the allowed env vars for this extension.
Sourcepub fn set_allow_shell_exec(&self, allowed: bool)
pub fn set_allow_shell_exec(&self, allowed: bool)
Set whether imp.exec() calls are permitted for the current runtime.
Sourcepub fn set_allow_http(&self, allowed: bool)
pub fn set_allow_http(&self, allowed: bool)
Set whether imp.http.* calls are permitted for the current runtime.
Sourcepub fn set_allow_secrets(&self, allowed: bool)
pub fn set_allow_secrets(&self, allowed: bool)
Set whether secret access is permitted for the current runtime.
Sourcepub fn set_allow_native_tool_calls(&self, allowed: bool)
pub fn set_allow_native_tool_calls(&self, allowed: bool)
Set whether imp.tool() calls are permitted for the current runtime.
Sourcepub fn apply_capability_policy(&self, policy: &LuaCapabilityPolicy)
pub fn apply_capability_policy(&self, policy: &LuaCapabilityPolicy)
Apply a shipped-runtime capability policy.
Sourcepub fn register_tool(&self, handle: LuaToolHandle)
pub fn register_tool(&self, handle: LuaToolHandle)
Register a tool handle (called from bridge).
Sourcepub fn register_hook(&self, handle: LuaHookHandle)
pub fn register_hook(&self, handle: LuaHookHandle)
Register a hook handle (called from bridge).
Sourcepub fn register_command(&self, handle: LuaCommandHandle)
pub fn register_command(&self, handle: LuaCommandHandle)
Register a command handle (called from bridge).
Sourcepub fn clear_registrations(&self)
pub fn clear_registrations(&self)
Clear all registered tools, hooks, and commands.
Sourcepub fn tool_count(&self) -> usize
pub fn tool_count(&self) -> usize
Number of registered tools.
Sourcepub fn hook_count(&self) -> usize
pub fn hook_count(&self) -> usize
Number of registered hooks.
Sourcepub fn command_count(&self) -> usize
pub fn command_count(&self) -> usize
Number of registered commands.
Sourcepub fn tool_names(&self) -> Vec<String>
pub fn tool_names(&self) -> Vec<String>
Get tool names.
Sourcepub fn hook_events(&self) -> Vec<String>
pub fn hook_events(&self) -> Vec<String>
Get hook event names.
Sourcepub fn execute_command(
&self,
name: &str,
args: &str,
) -> Result<Option<String>, LuaError>
pub fn execute_command( &self, name: &str, args: &str, ) -> Result<Option<String>, LuaError>
Execute a registered command by name, returning its string output.
Returns Ok(None) if the command returned nil (silent success).
Returns Ok(Some(text)) if the command returned a string or value.
Returns Err if the command handler or name wasn’t found.
Sourcepub fn execute_command_with_context(
&self,
name: &str,
args: &str,
call_ctx: Option<LuaCallContext>,
) -> Result<Option<String>, LuaError>
pub fn execute_command_with_context( &self, name: &str, args: &str, call_ctx: Option<LuaCallContext>, ) -> Result<Option<String>, LuaError>
Execute a registered command with an optional host call context.
Sourcepub fn command_names(&self) -> Vec<String>
pub fn command_names(&self) -> Vec<String>
Get command names.
Sourcepub fn command_summaries(&self) -> Vec<(String, String)>
pub fn command_summaries(&self) -> Vec<(String, String)>
Get command names with descriptions for menus and discovery.
Sourcepub fn has_command(&self, name: &str) -> bool
pub fn has_command(&self, name: &str) -> bool
Check if a command with the given name exists.
Auto Trait Implementations§
impl Freeze for LuaRuntime
impl !RefUnwindSafe for LuaRuntime
impl Send for LuaRuntime
impl Sync for LuaRuntime
impl Unpin for LuaRuntime
impl UnsafeUnpin for LuaRuntime
impl !UnwindSafe for LuaRuntime
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
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>
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>
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