postscriptum 0.1.1

Multi-interpreted-language scripting engine for Rust with Rhai and Python backends
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
//! Minimal example: evaluate a Python script and call a Rust function
//! registered through a `FunctionBundle` (native, via pyo3).

use postscriptum::{EngineType, FunctionBundle, get_engine_with_bundle};

fn main() -> postscriptum::Result<()> {
    let mut bundle = FunctionBundle::new(EngineType::Python);
    bundle.add_python_fn1::<fn(i64) -> i64, i64, i64>("double", |x: i64| x * 2);

    let mut engine = get_engine_with_bundle(EngineType::Python, &bundle);
    println!("double(21) = {}", engine.eval("double(21)")?);
    Ok(())
}