Skip to content

Writing a Process

This example is a Process that just adds 1 to its argument and returns it. The name of the function (or manifest) becomes the Process’s type name.

use juiz_sdk::prelude::*;
#[juiz_process]
fn increment_process(arg1: i64) -> JuizResult<Capsule> {
log::trace!("increment_process({:?}) called", arg1);
return Ok(jvalue!(arg1 + 1).into());
}

A function marked with the #[juiz_process] macro becomes the body of the Process. It can take several arguments, of types such as i64, f64, bool, String, Value and Vec<Value>. Parameter names become the argument names as is.

Give the built file with --process, and instantiate and run it with -e.

Terminal window
juiz --process target/debug/libincrement_process.so -l rust -e -1 -d
  • -l is the language (rust / cpp / python, default rust)
  • -e instantiates one loaded Process and runs it with its default arguments
  • -1 creates one instance per loaded module
  • -d starts the HTTP broker after running and keeps waiting