Skip to main content

Module raw_stack

Module raw_stack 

Source
Expand description

Raw stack implementation for low-level stack operations. Owns aligned heterogeneous values and supports explicit raw ownership transfer.

Push typed values and pop them with their matching type and padding flag. Before raw movement, release affected owners with RawStack::release_top and separately manage the released values. Ownership release is unsafe: restore the retained physical frame before owner-based operations or any possible unwinding.

use cel_runtime::RawStack;
let mut stack = RawStack::with_base_alignment(align_of::<String>());
let padding = stack.push(String::from("owned"));
let value = unsafe { stack.pop::<String>(padding) };
assert_eq!(value, "owned");
assert_eq!(stack.len(), 0);

Structsยง

RawStack
A simple raw stack that stores values as raw bytes. Each value is naturally aligned given the base alignment of the stack, which is the maximum alignment of any value stored in the stack. Live values are owned until popped, explicitly released, or destroyed in reverse push order.