Skip to content

Writing a Container

This example is a Container that holds one integer, and a ContainerProcess that adds its argument to that value.

use juiz_sdk::prelude::*;
#[repr(Rust)]
pub struct ExampleContainer {
pub value: i64
}
#[juiz_container]
fn example_container(initial_value: i64) -> JuizResult<Box<ExampleContainer>> {
Ok(Box::new(ExampleContainer { value: initial_value }))
}

A ContainerProcess is a Process that receives the Container as its first argument. container_type gives the type name of the Container it is bound to.

use example_container::ExampleContainer;
use juiz_sdk::prelude::*;
#[juiz_container_process(container_type = "example_container")]
fn increment_function(container: &mut ContainerImpl<ExampleContainer>, arg1: i64) -> JuizResult<Capsule> {
container.value = container.value + arg1;
return Ok(jvalue!(container.value).into());
}
Terminal window
juiz --container ./target/debug/libexample_container.so \
--container_process ./target/debug/libexample_container_increment.so \
-l rust -e -1 -d