Skip to main content

runmat_runtime/native/
value.rs

1/// Opaque, generation-checked reference to a runtime-owned RunMat value.
2///
3/// Native code may copy this token but must use runtime helpers to inspect,
4/// materialize, retain, or release the underlying value.
5#[repr(C)]
6#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
7pub struct NativeValueRef {
8    pub handle: u64,
9    pub generation: u64,
10}
11
12impl NativeValueRef {
13    pub const NULL: Self = Self {
14        handle: 0,
15        generation: 0,
16    };
17
18    pub const fn is_null(self) -> bool {
19        self.handle == 0
20    }
21
22    pub const fn is_valid(self) -> bool {
23        (self.handle == 0) == (self.generation == 0)
24    }
25}