Skip to main content

Module raw_segment

Module raw_segment 

Source
Expand description

Raw segment implementation without type safety. Registers owned captures and executes an explicitly typed raw frame.

Registration records no dynamic operand types. The caller establishes the complete types and padding before entering the unsafe execution boundary.

use cel_runtime::RawSegment;
let mut body = RawSegment::new();
body.push_op0(|| String::from("left"));
body.push_op1(|value: String| value + "/right", false);
assert_eq!(unsafe { body.call0::<String>() }?, "left/right");

let mut checked = RawSegment::new();
checked.raw0(|_| Ok(3f64));
checked.raw1(|_, value: f64| Ok(value.abs()), false);
checked.raw0(|_| Ok(2f64));
checked.raw2(|_, first: f64, second: f64| Ok(first - second), false, false);
checked.raw0(|_| Ok(4f64));
checked.raw0(|_| Ok(7f64));
checked.raw3(|_, first: f64, second: f64, third: f64| Ok((first, second, third)),
    false, false, false);
assert_eq!(unsafe { checked.call0::<(f64, f64, f64)>() }?, (1.0, 4.0, 7.0));

Structsยง

RawSegment
A segment represents a sequence of operations that can be executed.