Guarded

Struct Guarded 

Source
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

Source

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.

Source

pub fn unguarded(value: JsValue) -> Self

Create an unguarded value (for primitives or already-owned objects)

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Guarded

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Guarded

§

impl !RefUnwindSafe for Guarded

§

impl !Send for Guarded

§

impl !Sync for Guarded

§

impl Unpin for Guarded

§

impl !UnwindSafe for Guarded

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.