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
| Language | Feature | Speed | Power | Notes |
|---|---|---|---|---|
| Rhai | rhai | ⚡⚡⚡⚡ | ⭐⭐ | Native Rust, fastest startup |
| Lua | lua | ⚡⚡⚡ | ⭐⭐⭐ | Small runtime, good stdlib |
| JavaScript | javascript | ⚡⚡ | ⭐⭐⭐⭐ | ECMAScript compliant (Boa) |
| Python | python | ⚡ | ⭐⭐⭐⭐⭐ | 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§
- Execution
Limits - Execution limits for sandboxing
- Execution
Request - Request to execute code
- Execution
Result - Result of code execution
- Executor
- Main code executor that dispatches to language-specific implementations
Enums§
- Execution
Error - Error types for code execution
- Language
- Supported programming languages
- Sandbox
Profile - 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