Skip to main content

Crate brainwires_code_interpreters

Crate brainwires_code_interpreters 

Source
Expand description

§Code Interpreters

Sandboxed code execution for multiple programming languages. Designed to work both natively and compiled to WASM for browser execution.

§Supported Languages

LanguageFeatureSpeedPowerNotes
Rhairhai⚡⚡⚡⚡⭐⭐Native Rust, fastest startup
Lualua⚡⚡⚡⭐⭐⭐Small runtime, good stdlib
JavaScriptjavascript⚡⚡⭐⭐⭐⭐ECMAScript compliant (Boa)
Pythonpython⭐⭐⭐⭐⭐CPython 3.12 compatible

§Example

use brainwires_code_interpreters::{Executor, ExecutionRequest, Language};

let executor = Executor::new();
let result = executor.execute(ExecutionRequest {
    language: Language::Rhai,
    code: "let x = 1 + 2; x".to_string(),
    ..Default::default()
});

assert!(result.success);
assert_eq!(result.stdout, "3");

Modules§

lang
Re-exports of language-specific executors for advanced use.

Structs§

ExecutionLimits
Execution limits for sandboxing
ExecutionRequest
Request to execute code
ExecutionResult
Result of code execution
Executor
Main code executor that dispatches to language-specific implementations

Enums§

ExecutionError
Error types for code execution
Language
Supported programming languages
SandboxProfile
Sandbox profile presets

Functions§

is_language_supported
Check if a language is supported
supported_languages
Get a list of supported languages based on enabled features