Skip to main content

ValueSlot

Struct ValueSlot 

Source
pub struct ValueSlot(/* private fields */);
Expand description

A raw 8-byte value slot for TypedObject field storage.

Implementations§

Source§

impl ValueSlot

Source

pub fn from_typed_scalar(ts: TypedScalar) -> (Self, bool)

Create a ValueSlot from a TypedScalar.

Returns (slot, is_heap)is_heap is always false for scalars since all scalar values fit in 8 bytes without heap allocation.

Source§

impl ValueSlot

Source

pub fn from_number(n: f64) -> Self

Store a f64 as raw IEEE 754 bits.

Source

pub fn from_int(i: i64) -> Self

Store an i64 as raw two’s complement bits. Full 64-bit range, no precision loss.

Source

pub fn from_u64(v: u64) -> Self

Store a u64 directly. Only meaningful when the FieldType is known to be U64.

Source

pub fn as_u64(&self) -> u64

Read as u64 (caller must know this slot is u64 type).

Source

pub fn from_bool(b: bool) -> Self

Store a bool as 1/0.

Source

pub fn none() -> Self

Store None as zero bits.

Source

pub fn from_heap(value: HeapValue) -> Self

Store any HeapValue on the heap. The caller MUST set the corresponding bit in heap_mask so Drop knows to free this.

Without gc feature: allocates via Box (freed by drop_heap). With gc feature: allocates via GcHeap (freed by garbage collector).

Source

pub fn as_f64(&self) -> f64

Read as f64 (caller must know this slot is f64 type).

Source

pub fn as_i64(&self) -> i64

Read as i64 (caller must know this slot is i64 type).

Source

pub fn as_bool(&self) -> bool

Read as bool (caller must know this slot is bool type).

Source

pub fn as_heap_value(&self) -> &HeapValue

Read as heap HeapValue reference (caller must know this slot is a heap pointer). Returns a reference to the pointed-to HeapValue.

Source

pub fn as_heap_nb(&self) -> ValueWord

Create a ValueWord directly from this heap slot (no intermediate conversion). Caller must know this slot is a heap pointer.

Source

pub fn from_value_word(nb: &ValueWord) -> (Self, bool)

Store a ValueWord losslessly. For inline types (f64, i48, bool, none, unit, function, module_function), stores the raw NaN-boxed tag bits directly. For heap-tagged values, clones the HeapValue into a new Box. Returns (slot, is_heap) — caller must set the heap_mask bit if is_heap.

Source

pub fn from_nanboxed(nb: &ValueWord) -> (Self, bool)

Backward-compatibility alias.

Source

pub fn as_value_word(&self, is_heap: bool) -> ValueWord

Reconstruct a ValueWord from this slot. is_heap must match the value returned by from_value_word (i.e., whether heap_mask bit is set).

Source

pub fn as_nanboxed(&self, is_heap: bool) -> ValueWord

Backward-compatibility alias.

Source

pub fn raw(&self) -> u64

Raw bits for simple copy.

Source

pub fn from_raw(bits: u64) -> Self

Construct from raw bits.

Source

pub unsafe fn drop_heap(&mut self)

Drop the heap value. MUST only be called on heap slots.

Without gc feature: frees via Box deallocation. With gc feature: no-op (GC handles deallocation).

§Safety

Caller must ensure this slot actually contains a valid heap pointer.

Source

pub unsafe fn clone_heap(&self) -> Self

Clone a heap slot by cloning the pointed-to HeapValue into a new Box.

Without gc feature: deep clones into a new Box allocation. With gc feature: bitwise copy (GC tracks all references).

§Safety

Caller must ensure this slot actually contains a valid heap pointer.

Trait Implementations§

Source§

impl Clone for ValueSlot

Source§

fn clone(&self) -> ValueSlot

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ValueSlot

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Copy for ValueSlot

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,