Skip to main content

Vm

Struct Vm 

Source
pub struct Vm {
    pub state: ShellState,
    pub steps: u64,
    pub limits: ExecutionLimits,
    pub output_bytes: u64,
    pub budget: BudgetTracker,
    pub diagnostics: Vec<DiagnosticEvent>,
    pub stdout: Vec<u8>,
    pub stderr: Vec<u8>,
    /* private fields */
}
Expand description

The shell virtual machine.

Fields§

§state: ShellState

Shell state (variables, params, cwd, etc.).

§steps: u64

Number of steps executed so far.

§limits: ExecutionLimits

Execution limits.

§output_bytes: u64

Bytes of output produced so far.

§budget: BudgetTracker

Shared budget accounting and stable stop reasons.

§diagnostics: Vec<DiagnosticEvent>

Collected diagnostic events.

§stdout: Vec<u8>

Collected stdout output from command execution.

§stderr: Vec<u8>

Collected stderr output from command execution.

Implementations§

Source§

impl Vm

Source

pub fn new(state: ShellState, step_budget: u64) -> Self

Create a new VM with the given state and limits.

Source

pub fn with_limits(state: ShellState, limits: ExecutionLimits) -> Self

Create a VM with full execution limits.

Source

pub fn emit_diagnostic( &mut self, level: DiagLevel, category: DiagCategory, message: String, )

Emit a diagnostic event.

Source

pub fn stop_reason(&self) -> Option<&StopReason>

Source

pub fn track_output(&mut self, bytes: u64) -> bool

Track output bytes and check the limit. Returns true if within limits.

Source

pub fn write_stdout(&mut self, data: &[u8])

Append stdout bytes and update output accounting.

Source

pub fn write_stderr(&mut self, data: &[u8])

Append stderr bytes and update output accounting.

Source

pub fn write_streams(&mut self, stdout: &[u8], stderr: &[u8])

Append both stdout and stderr bytes and update output accounting once.

Source

pub fn check_output_limit(&mut self) -> Result<(), StepResult>

Check whether the accumulated output has exceeded the configured limit.

Source

pub fn begin_step(&mut self) -> Result<(), StepResult>

Consume one execution step using the VM’s shared budget/cancel semantics.

Source

pub fn cancellation_token(&self) -> CancellationToken

Get the cancellation token (can be cloned and shared).

Source

pub fn run(&mut self, program: &IrProgram) -> StepResult

Execute an IR program to completion (or until yield/cancel).

Source

pub fn run_with_executor<E: VmExecutor>( &mut self, program: &IrProgram, executor: &mut E, ) -> StepResult

Trait Implementations§

Source§

impl Default for Vm

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for Vm

§

impl !RefUnwindSafe for Vm

§

impl Send for Vm

§

impl !Sync for Vm

§

impl Unpin for Vm

§

impl UnsafeUnpin for Vm

§

impl UnwindSafe for Vm

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.