pub struct Runtime { /* private fields */ }Expand description
The main runtime structure that executes Lua scripts.
All shared dependencies (scheduler, run context, journal, tokio handle) are captured by the SDK closures during construction; the struct itself only needs to retain the VM and the report sink.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn new(
scheduler: Arc<Scheduler>,
run_ctx: RunContext,
args: Value,
_limits: ExecLimits,
journal: Option<Arc<JournalStore>>,
handle: Handle,
) -> Result<Self, ScriptError>
pub fn new( scheduler: Arc<Scheduler>, run_ctx: RunContext, args: Value, _limits: ExecLimits, journal: Option<Arc<JournalStore>>, handle: Handle, ) -> Result<Self, ScriptError>
Create a new Runtime with sandbox applied.
handle is the tokio runtime handle used by SDK primitives to block on
the async scheduler. It is captured here (in async context) so it can be
used later from the blocking execution thread.
Sourcepub fn execute(&self, script: &str) -> Result<Value, ScriptError>
pub fn execute(&self, script: &str) -> Result<Value, ScriptError>
Execute the script and return the report value (if any).
The script MUST declare a meta = { ... } table at the top level and a
function main() ... end entry point. Execution proceeds in two phases:
- Top-level exec: runs all assignments and function definitions
(
meta = {...}, schema locals,function main() ... end). This is safe — no agent/phase calls happen here. - Extract meta: reads the
metaglobal, emits aAgentEvent::PlanPreview. - Call main(): invokes the
mainfunction which contains the real orchestration logic.
MUST be called from a blocking context (not an async worker thread),
because the SDK primitives call Handle::block_on internally.
Sourcepub fn set_completed_spans(&self, names: &[String]) -> Result<(), ScriptError>
pub fn set_completed_spans(&self, names: &[String]) -> Result<(), ScriptError>
Inject completed phase span names as the completed_spans Lua global,
so resume scripts can skip already-finished structural units.
Auto Trait Implementations§
impl !RefUnwindSafe for Runtime
impl !UnwindSafe for Runtime
impl Freeze for Runtime
impl Send for Runtime
impl Sync for Runtime
impl Unpin for Runtime
impl UnsafeUnpin for Runtime
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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