virtual_exec

Crates.iovirtual_exec
lib.rsvirtual_exec
version0.1.0
created_at2025-12-08 00:48:40.894808+00
updated_at2025-12-08 00:48:40.894808+00
descriptionA sandbox execution environment which allowed limited execution of expression safely (WIP)
homepage
repositoryhttps://github.com/i-am-unknown-81514525/virtual_exec
max_upload_size
id1972570
size51,798
(i-am-unknown-81514525)

documentation

README

VirtualExec

A rust library to perform sandboxed safe expression evaluation, in a similar syntax to rust

use virtual_exec::exec;
use virtual_exec_type::exec_ctx::RsValue;

#[test]
fn test_simple_assignment() {
    let code = "a = 1; b = 2; c = 3; if a != b {d = 2;} d;";
    let result = exec(code, 100).unwrap();
    assert_eq!(result.get("a"), Some(&RsValue::Int(1)));
}

An example if the execution. In particular, the 100 there define the lifetime of the calculation, which this allowed up to 100 operation, and would raise TimeoutError if it take longer than that to execute.

The current supported operation is expression calculation, assignment and if-statement.

WIP Feature list:

  • Variable assignment
  • Attribute assignment
  • Subscript assignment (i.e. x[a])
  • Expression evaluation
  • A parser and type system
  • Attribute system
  • Function call
  • while loop
  • for loop
  • FFI function (Calling rust function from sandbox code with custom lifetime consumption) The planned behaviour is it would terminate after the function call if it is dynamic lifetime, while terminate before the function call if it is static lifetime
  • Function definition
  • if statement
  • Custom object definition
  • Use await in rust to allow context switching to other part of program to make it not blocking

Sub-crate List:

Commit count: 0

cargo fmt