コンテンツにスキップ

Container を書く

整数の値を一つ持つ Container と、その値に引数を足す ContainerProcess を例にします。

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 }))
}

ContainerProcess は、最初の引数に Container を受け取る Process です。container_type で結びつける Container の型名を指定します。

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());
}
ターミナルウィンドウ
juiz --container ./target/debug/libexample_container.so \
--container_process ./target/debug/libexample_container_increment.so \
-l rust -e -1 -d