pub struct Guarded {
pub value: JsValue,
pub guard: Option<Guard<JsObject>>,
}Expand description
A JsValue bundled with a Guard that keeps it alive.
IMPORTANT: Access the value through destructuring ONLY to ensure the guard stays alive for the correct duration. See CLAUDE.md for rules.
The fields are public to allow struct destructuring pattern, which is the ONLY approved way to access the contents.
Fields§
§value: JsValue§guard: Option<Guard<JsObject>>Implementations§
Source§impl Guarded
impl Guarded
Sourcepub fn with_guard(value: JsValue, guard: Guard<JsObject>) -> Self
pub fn with_guard(value: JsValue, guard: Guard<JsObject>) -> Self
Create a guarded value with a guard.
If the value is a primitive, the guard is dropped and guard will be None.
NOTE: You must call value.guard_by(&guard) before this if the value is an object.
Sourcepub fn unguarded(value: JsValue) -> Self
pub fn unguarded(value: JsValue) -> Self
Create an unguarded value (for primitives or already-owned objects)
Sourcepub fn from_value(value: JsValue, heap: &Heap<JsObject>) -> Self
pub fn from_value(value: JsValue, heap: &Heap<JsObject>) -> Self
Create a guarded value for returning from the VM. Creates a new guard from the heap if the value is an object. For primitives, returns an unguarded value.
Sourcepub fn with_value(self, value: JsValue) -> Self
pub fn with_value(self, value: JsValue) -> Self
Return a new value with the same guard (for derived values)
Use this when you derive a value from a guarded input and want to propagate the guard to keep the original object alive.