Skip to main content

ValueBox

Struct ValueBox 

Source
pub struct ValueBox { /* private fields */ }
Expand description

One engine Value in a block whose payload pointer is also a JSValue.

The layout is load-bearing: header.ref_count sits at +4 and value at +8, so JS_VALUE_GET_PTR(v) - 4 addresses the count, and free_value recovers the Value from the payload pointer alone. Both offsets are asserted at compile time by the offset_of! lines above, and again from the C side of the arithmetic in tests/abi.rs.

Implementations§

Source§

impl ValueBox

Source

pub unsafe fn ref_count(payload: *mut ()) -> i32

ref_count as C’s __js_rc reads it: an int four bytes before the payload.

Public because the test that proves the arrangement has to do C’s arithmetic, and doing it from Rust is the point — the alternative is trusting the comment.

§Safety

payload must be a live payload from box_value.

Source

pub unsafe fn set_ref_count(payload: *mut (), count: i32)

Set the count the way C’s inline JS_DupValue / JS_FreeValue do.

§Safety

payload must be a live payload from box_value.

Auto Trait Implementations§

§

impl !RefUnwindSafe for ValueBox

§

impl !Send for ValueBox

§

impl !Sync for ValueBox

§

impl !UnwindSafe for ValueBox

§

impl Forget for ValueBox

§

impl Freeze for ValueBox
where *const GcBox<JsString> is !null: Freeze, *const GcBox<JsObject> is !null: Freeze, *const GcBox<JsSymbol> is !null: Freeze, *const GcBox<BigInt> is !null: Freeze,

§

impl Move for ValueBox

§

impl Unpin for ValueBox
where *const GcBox<JsString> is !null: Unpin, *const GcBox<JsObject> is !null: Unpin, *const GcBox<JsSymbol> is !null: Unpin, *const GcBox<BigInt> is !null: Unpin,

§

impl UnsafeUnpin for ValueBox
where *const GcBox<JsString> is !null: UnsafeUnpin, *const GcBox<JsObject> is !null: UnsafeUnpin, *const GcBox<JsSymbol> is !null: UnsafeUnpin, *const GcBox<BigInt> is !null: UnsafeUnpin,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.