pub struct ValueWord(/* private fields */);Expand description
An 8-byte value word for the VM stack (NaN-boxed encoding).
This is NOT Copy because heap-tagged values reference an Arc<HeapValue>.
Clone is implemented manually to bump the Arc refcount (no allocation).
Drop is implemented to decrement the Arc refcount.
Implementations§
Source§impl ValueWord
impl ValueWord
Sourcepub fn to_typed_scalar(&self) -> Option<TypedScalar>
pub fn to_typed_scalar(&self) -> Option<TypedScalar>
Convert this ValueWord to a TypedScalar, preserving type identity.
Returns None for heap-allocated values (strings, arrays, objects, etc.)
which are not representable as scalars.
Sourcepub fn from_typed_scalar(ts: TypedScalar) -> Self
pub fn from_typed_scalar(ts: TypedScalar) -> Self
Create a ValueWord from a TypedScalar.
Integer kinds are stored as I48 (clamped to the 48-bit range; values
outside [-2^47, 2^47-1] are heap-boxed as BigInt via from_i64).
Float kinds are stored as plain f64. Bool/None/Unit use their direct
ValueWord constructors.
Source§impl ValueWord
impl ValueWord
Sourcepub fn from_f64(v: f64) -> Self
pub fn from_f64(v: f64) -> Self
Create a ValueWord from an f64 value.
Normal f64 values are stored directly. NaN values are canonicalized to a single canonical NaN to avoid collisions with our tagged range.
Sourcepub fn from_i64(v: i64) -> Self
pub fn from_i64(v: i64) -> Self
Create a ValueWord from an i64 value.
Values in the range [-2^47, 2^47-1] are stored inline as i48.
Values outside that range are heap-boxed as HeapValue::BigInt.
Sourcepub fn from_native_scalar(value: NativeScalar) -> Self
pub fn from_native_scalar(value: NativeScalar) -> Self
Create a ValueWord from a width-aware native scalar.
pub fn from_native_i8(v: i8) -> Self
pub fn from_native_u8(v: u8) -> Self
pub fn from_native_i16(v: i16) -> Self
pub fn from_native_u16(v: u16) -> Self
pub fn from_native_i32(v: i32) -> Self
pub fn from_native_u32(v: u32) -> Self
pub fn from_native_u64(v: u64) -> Self
pub fn from_native_isize(v: isize) -> Self
pub fn from_native_usize(v: usize) -> Self
pub fn from_native_ptr(v: usize) -> Self
pub fn from_native_f32(v: f32) -> Self
Sourcepub fn from_c_view(ptr: usize, layout: Arc<NativeTypeLayout>) -> Self
pub fn from_c_view(ptr: usize, layout: Arc<NativeTypeLayout>) -> Self
Create a pointer-backed C view.
Sourcepub fn from_c_mut(ptr: usize, layout: Arc<NativeTypeLayout>) -> Self
pub fn from_c_mut(ptr: usize, layout: Arc<NativeTypeLayout>) -> Self
Create a pointer-backed mutable C view.
Sourcepub fn from_function(id: u16) -> Self
pub fn from_function(id: u16) -> Self
Construct a ValueWord from raw u64 bits, bumping the Arc refcount for
heap-tagged values. This is equivalent to Clone::clone but works from
raw bits (e.g. read via pointer arithmetic) instead of a &ValueWord.
Create a ValueWord from a function ID.
Sourcepub fn from_module_function(index: u32) -> Self
pub fn from_module_function(index: u32) -> Self
Create a ValueWord from a module function index.
Sourcepub fn from_ref(absolute_slot: usize) -> Self
pub fn from_ref(absolute_slot: usize) -> Self
Create a ValueWord reference to an absolute stack slot.
References are inline (no heap allocation) — Clone is bitwise copy, Drop is no-op. Used for pass-by-reference semantics: the payload is the absolute stack index of the value being referenced.
Sourcepub fn from_string(s: Arc<String>) -> Self
pub fn from_string(s: Arc<String>) -> Self
Create a ValueWord from an Arc
Sourcepub fn from_array(a: VMArray) -> Self
pub fn from_array(a: VMArray) -> Self
Create a ValueWord from a VMArray directly (no intermediate conversion).
Sourcepub fn from_decimal(d: Decimal) -> Self
pub fn from_decimal(d: Decimal) -> Self
Create a ValueWord from Decimal directly (no intermediate conversion).
Sourcepub fn from_heap_value(v: HeapValue) -> Self
pub fn from_heap_value(v: HeapValue) -> Self
Create a ValueWord from any HeapValue directly (no intermediate conversion).
BigInt that fits i48 is unwrapped to its native ValueWord inline tag instead of being heap-allocated. All other variants are heap-boxed.
Sourcepub fn from_datatable(dt: Arc<DataTable>) -> Self
pub fn from_datatable(dt: Arc<DataTable>) -> Self
Create a ValueWord from a DataTable directly.
Sourcepub fn from_typed_table(schema_id: u64, table: Arc<DataTable>) -> Self
pub fn from_typed_table(schema_id: u64, table: Arc<DataTable>) -> Self
Create a ValueWord TypedTable directly.
Sourcepub fn from_row_view(
schema_id: u64,
table: Arc<DataTable>,
row_idx: usize,
) -> Self
pub fn from_row_view( schema_id: u64, table: Arc<DataTable>, row_idx: usize, ) -> Self
Create a ValueWord RowView directly.
Sourcepub fn from_column_ref(
schema_id: u64,
table: Arc<DataTable>,
col_id: u32,
) -> Self
pub fn from_column_ref( schema_id: u64, table: Arc<DataTable>, col_id: u32, ) -> Self
Create a ValueWord ColumnRef directly.
Sourcepub fn from_indexed_table(
schema_id: u64,
table: Arc<DataTable>,
index_col: u32,
) -> Self
pub fn from_indexed_table( schema_id: u64, table: Arc<DataTable>, index_col: u32, ) -> Self
Create a ValueWord IndexedTable directly.
Sourcepub fn from_range(
start: Option<ValueWord>,
end: Option<ValueWord>,
inclusive: bool,
) -> Self
pub fn from_range( start: Option<ValueWord>, end: Option<ValueWord>, inclusive: bool, ) -> Self
Create a ValueWord Range directly.
Sourcepub fn from_hashmap(
keys: Vec<ValueWord>,
values: Vec<ValueWord>,
index: HashMap<u64, Vec<usize>>,
) -> ValueWord
pub fn from_hashmap( keys: Vec<ValueWord>, values: Vec<ValueWord>, index: HashMap<u64, Vec<usize>>, ) -> ValueWord
Create a ValueWord HashMap from keys, values, and index.
Sourcepub fn empty_hashmap() -> ValueWord
pub fn empty_hashmap() -> ValueWord
Create an empty ValueWord HashMap.
Sourcepub fn from_hashmap_pairs(
keys: Vec<ValueWord>,
values: Vec<ValueWord>,
) -> ValueWord
pub fn from_hashmap_pairs( keys: Vec<ValueWord>, values: Vec<ValueWord>, ) -> ValueWord
Create a ValueWord HashMap from keys and values, auto-building the bucket index and computing a shape for O(1) property access when all keys are strings.
Sourcepub fn from_set(items: Vec<ValueWord>) -> ValueWord
pub fn from_set(items: Vec<ValueWord>) -> ValueWord
Create a ValueWord Set from items (deduplicating).
Sourcepub fn from_deque(items: Vec<ValueWord>) -> ValueWord
pub fn from_deque(items: Vec<ValueWord>) -> ValueWord
Create a ValueWord Deque from items.
Sourcepub fn empty_deque() -> ValueWord
pub fn empty_deque() -> ValueWord
Create an empty ValueWord Deque.
Sourcepub fn from_priority_queue(items: Vec<ValueWord>) -> ValueWord
pub fn from_priority_queue(items: Vec<ValueWord>) -> ValueWord
Create a ValueWord PriorityQueue from items (heapified).
Sourcepub fn empty_priority_queue() -> ValueWord
pub fn empty_priority_queue() -> ValueWord
Create an empty ValueWord PriorityQueue.
Sourcepub fn from_content(node: ContentNode) -> ValueWord
pub fn from_content(node: ContentNode) -> ValueWord
Create a ValueWord from a ContentNode directly.
Sourcepub fn from_int_array(a: Arc<TypedBuffer<i64>>) -> Self
pub fn from_int_array(a: Arc<TypedBuffer<i64>>) -> Self
Create a ValueWord IntArray from an Arc<TypedBuffer
Sourcepub fn from_float_array(a: Arc<AlignedTypedBuffer>) -> Self
pub fn from_float_array(a: Arc<AlignedTypedBuffer>) -> Self
Create a ValueWord FloatArray from an Arc
Sourcepub fn from_bool_array(a: Arc<TypedBuffer<u8>>) -> Self
pub fn from_bool_array(a: Arc<TypedBuffer<u8>>) -> Self
Create a ValueWord BoolArray from an Arc<TypedBuffer
Sourcepub fn from_i8_array(a: Arc<TypedBuffer<i8>>) -> Self
pub fn from_i8_array(a: Arc<TypedBuffer<i8>>) -> Self
Create a ValueWord I8Array.
Sourcepub fn from_i16_array(a: Arc<TypedBuffer<i16>>) -> Self
pub fn from_i16_array(a: Arc<TypedBuffer<i16>>) -> Self
Create a ValueWord I16Array.
Sourcepub fn from_i32_array(a: Arc<TypedBuffer<i32>>) -> Self
pub fn from_i32_array(a: Arc<TypedBuffer<i32>>) -> Self
Create a ValueWord I32Array.
Sourcepub fn from_u8_array(a: Arc<TypedBuffer<u8>>) -> Self
pub fn from_u8_array(a: Arc<TypedBuffer<u8>>) -> Self
Create a ValueWord U8Array.
Sourcepub fn from_u16_array(a: Arc<TypedBuffer<u16>>) -> Self
pub fn from_u16_array(a: Arc<TypedBuffer<u16>>) -> Self
Create a ValueWord U16Array.
Sourcepub fn from_u32_array(a: Arc<TypedBuffer<u32>>) -> Self
pub fn from_u32_array(a: Arc<TypedBuffer<u32>>) -> Self
Create a ValueWord U32Array.
Sourcepub fn from_u64_array(a: Arc<TypedBuffer<u64>>) -> Self
pub fn from_u64_array(a: Arc<TypedBuffer<u64>>) -> Self
Create a ValueWord U64Array.
Sourcepub fn from_f32_array(a: Arc<TypedBuffer<f32>>) -> Self
pub fn from_f32_array(a: Arc<TypedBuffer<f32>>) -> Self
Create a ValueWord F32Array.
Sourcepub fn from_matrix(m: Box<MatrixData>) -> Self
pub fn from_matrix(m: Box<MatrixData>) -> Self
Create a ValueWord Matrix from MatrixData.
Sourcepub fn from_iterator(state: Box<IteratorState>) -> Self
pub fn from_iterator(state: Box<IteratorState>) -> Self
Create a ValueWord Iterator from IteratorState.
Sourcepub fn from_generator(state: Box<GeneratorState>) -> Self
pub fn from_generator(state: Box<GeneratorState>) -> Self
Create a ValueWord Generator from GeneratorState.
Sourcepub fn from_future(id: u64) -> Self
pub fn from_future(id: u64) -> Self
Create a ValueWord Future directly.
Sourcepub fn from_task_group(kind: u8, task_ids: Vec<u64>) -> Self
pub fn from_task_group(kind: u8, task_ids: Vec<u64>) -> Self
Create a ValueWord TaskGroup directly.
Sourcepub fn from_mutex(value: ValueWord) -> Self
pub fn from_mutex(value: ValueWord) -> Self
Create a ValueWord Mutex wrapping a value.
Sourcepub fn from_atomic(value: i64) -> Self
pub fn from_atomic(value: i64) -> Self
Create a ValueWord Atomic with an initial integer value.
Sourcepub fn from_lazy(initializer: ValueWord) -> Self
pub fn from_lazy(initializer: ValueWord) -> Self
Create a ValueWord Lazy with an initializer closure.
Sourcepub fn from_channel(data: ChannelData) -> Self
pub fn from_channel(data: ChannelData) -> Self
Create a ValueWord Channel endpoint.
Sourcepub fn from_trait_object(value: ValueWord, vtable: Arc<VTable>) -> Self
pub fn from_trait_object(value: ValueWord, vtable: Arc<VTable>) -> Self
Create a ValueWord TraitObject directly.
Sourcepub fn from_expr_proxy(col_name: Arc<String>) -> Self
pub fn from_expr_proxy(col_name: Arc<String>) -> Self
Create a ValueWord ExprProxy directly.
Sourcepub fn from_filter_expr(node: Arc<FilterNode>) -> Self
pub fn from_filter_expr(node: Arc<FilterNode>) -> Self
Create a ValueWord FilterExpr directly.
Sourcepub fn from_instant(t: Instant) -> Self
pub fn from_instant(t: Instant) -> Self
Create a ValueWord Instant directly.
Sourcepub fn from_io_handle(data: IoHandleData) -> Self
pub fn from_io_handle(data: IoHandleData) -> Self
Create a ValueWord IoHandle.
Sourcepub fn from_time(t: DateTime<FixedOffset>) -> Self
pub fn from_time(t: DateTime<FixedOffset>) -> Self
Create a ValueWord Time directly from a DateTime
Sourcepub fn from_time_utc(t: DateTime<Utc>) -> Self
pub fn from_time_utc(t: DateTime<Utc>) -> Self
Create a ValueWord Time from a DateTime
Sourcepub fn from_duration(d: Duration) -> Self
pub fn from_duration(d: Duration) -> Self
Create a ValueWord Duration directly.
Sourcepub fn from_timespan(ts: Duration) -> Self
pub fn from_timespan(ts: Duration) -> Self
Create a ValueWord TimeSpan directly.
Sourcepub fn from_timeframe(tf: Timeframe) -> Self
pub fn from_timeframe(tf: Timeframe) -> Self
Create a ValueWord Timeframe directly.
Sourcepub fn from_host_closure(nc: HostCallable) -> Self
pub fn from_host_closure(nc: HostCallable) -> Self
Create a ValueWord HostClosure directly.
Sourcepub fn from_print_result(pr: PrintResult) -> Self
pub fn from_print_result(pr: PrintResult) -> Self
Create a ValueWord PrintResult directly.
Sourcepub fn from_simulation_call(
name: String,
params: HashMap<String, ValueWord>,
) -> Self
pub fn from_simulation_call( name: String, params: HashMap<String, ValueWord>, ) -> Self
Create a ValueWord SimulationCall directly.
Sourcepub fn from_function_ref(name: String, closure: Option<ValueWord>) -> Self
pub fn from_function_ref(name: String, closure: Option<ValueWord>) -> Self
Create a ValueWord FunctionRef directly.
Sourcepub fn from_data_reference(
datetime: DateTime<FixedOffset>,
id: String,
timeframe: Timeframe,
) -> Self
pub fn from_data_reference( datetime: DateTime<FixedOffset>, id: String, timeframe: Timeframe, ) -> Self
Create a ValueWord DataReference directly.
Sourcepub fn from_time_reference(tr: TimeReference) -> Self
pub fn from_time_reference(tr: TimeReference) -> Self
Create a ValueWord TimeReference directly.
Sourcepub fn from_datetime_expr(de: DateTimeExpr) -> Self
pub fn from_datetime_expr(de: DateTimeExpr) -> Self
Create a ValueWord DateTimeExpr directly.
Sourcepub fn from_data_datetime_ref(dr: DataDateTimeRef) -> Self
pub fn from_data_datetime_ref(dr: DataDateTimeRef) -> Self
Create a ValueWord DataDateTimeRef directly.
Sourcepub fn from_type_annotation(ta: TypeAnnotation) -> Self
pub fn from_type_annotation(ta: TypeAnnotation) -> Self
Create a ValueWord TypeAnnotation directly.
Sourcepub fn from_type_annotated_value(type_name: String, value: ValueWord) -> Self
pub fn from_type_annotated_value(type_name: String, value: ValueWord) -> Self
Create a ValueWord TypeAnnotatedValue directly.
Sourcepub unsafe fn clone_from_bits(bits: u64) -> Self
pub unsafe fn clone_from_bits(bits: u64) -> Self
Create a ValueWord by “cloning” from raw bits read from a stack slot.
For inline values (f64, i48, bool, none, unit, function), this simply
wraps the bits. For heap values (without gc), it bumps the Arc refcount.
With gc, it’s a pure bitwise copy (GC handles liveness).
§Safety
bits must be a valid ValueWord representation (either an inline value
or a heap-tagged value with a valid Arc
Sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Returns true if this value is a function reference.
Sourcepub fn as_ref_slot(&self) -> Option<usize>
pub fn as_ref_slot(&self) -> Option<usize>
Extract the absolute stack slot index from a reference. Returns None if this is not a reference.
Sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
Extract as f64, returning None if this is not an inline f64.
Sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
Extract as i64, returning None if this is not an exact signed integer.
Accepts inline i48 values, heap BigInt, and signed-compatible native scalars.
Sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
Extract as u64 when the value is an exact non-negative integer.
Sourcepub fn as_i128_exact(&self) -> Option<i128>
pub fn as_i128_exact(&self) -> Option<i128>
Extract exact integer domain as i128 (used for width-aware arithmetic/comparison).
Sourcepub fn as_number_strict(&self) -> Option<f64>
pub fn as_number_strict(&self) -> Option<f64>
Extract numeric values as f64, including lossless i48→f64 coercion.
Sourcepub fn as_function(&self) -> Option<u16>
pub fn as_function(&self) -> Option<u16>
Extract as function ID, returning None if this is not a function.
Sourcepub unsafe fn as_f64_unchecked(&self) -> f64
pub unsafe fn as_f64_unchecked(&self) -> f64
Extract f64 without type checking. Safely handles inline i48 ints via lossless coercion.
§Safety
Caller must ensure the value is numeric (f64 or i48).
Sourcepub unsafe fn as_i64_unchecked(&self) -> i64
pub unsafe fn as_i64_unchecked(&self) -> i64
Extract i64 without type checking. Safely handles f64 values via truncation.
§Safety
Caller must ensure the value is numeric (i48 or f64).
Sourcepub unsafe fn as_bool_unchecked(&self) -> bool
pub unsafe fn as_bool_unchecked(&self) -> bool
Sourcepub unsafe fn as_function_unchecked(&self) -> u16
pub unsafe fn as_function_unchecked(&self) -> u16
Sourcepub fn as_heap_ref(&self) -> Option<&HeapValue>
pub fn as_heap_ref(&self) -> Option<&HeapValue>
Get a reference to the heap-boxed HeapValue without cloning. Returns None if this is not a heap value.
Sourcepub fn as_heap_mut(&mut self) -> Option<&mut HeapValue>
pub fn as_heap_mut(&mut self) -> Option<&mut HeapValue>
Get a mutable reference to the heap-boxed HeapValue, cloning if shared. Returns None if this is not a heap value.
Without gc: Uses Arc::make_mut semantics (clones if refcount > 1).
With gc: Direct mutable access (GC objects are not refcounted).
Sourcepub fn as_number_coerce(&self) -> Option<f64>
pub fn as_number_coerce(&self) -> Option<f64>
Extract as f64 using safe coercion.
This accepts:
- explicit floating-point values (
number,f32) - inline
intvalues (i48)
It intentionally does not coerce BigInt, i64, or u64
native scalars into f64 to avoid lossy conversion.
Sourcepub fn is_module_function(&self) -> bool
pub fn is_module_function(&self) -> bool
Check if this ValueWord is a module function tag.
Sourcepub fn as_module_function(&self) -> Option<usize>
pub fn as_module_function(&self) -> Option<usize>
Extract module function index.
Sourcepub fn heap_kind(&self) -> Option<HeapKind>
pub fn heap_kind(&self) -> Option<HeapKind>
Get the HeapKind discriminator without cloning. Returns None if this is not a heap value.
Sourcepub fn tag(&self) -> NanTag
pub fn tag(&self) -> NanTag
Tag discriminator for ValueWord values. Used for fast dispatch without materializing HeapValue.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Get a reference to a heap String without cloning. Returns None if this is not a heap-boxed String.
Sourcepub fn as_decimal(&self) -> Option<Decimal>
pub fn as_decimal(&self) -> Option<Decimal>
Extract a Decimal from a heap-boxed Decimal value. Returns None if this is not a heap-boxed Decimal.
Sourcepub unsafe fn as_decimal_unchecked(&self) -> Decimal
pub unsafe fn as_decimal_unchecked(&self) -> Decimal
Extract a Decimal without type checking.
§Safety
Caller must ensure this is a heap-boxed Decimal value.
Sourcepub fn as_array(&self) -> Option<&VMArray>
👎Deprecated: Use as_any_array() instead for unified typed array dispatch
pub fn as_array(&self) -> Option<&VMArray>
Get a reference to a heap Array without cloning. Returns None if this is not a heap-boxed Array.
Sourcepub fn as_any_array(&self) -> Option<ArrayView<'_>>
pub fn as_any_array(&self) -> Option<ArrayView<'_>>
Get a unified read-only view over any array variant (Generic, Int, Float, Bool, width-specific).
Sourcepub fn as_any_array_mut(&mut self) -> Option<ArrayViewMut<'_>>
pub fn as_any_array_mut(&mut self) -> Option<ArrayViewMut<'_>>
Get a unified mutable view over any array variant. Uses Arc::make_mut for COW.
Sourcepub fn as_datatable(&self) -> Option<&Arc<DataTable>>
pub fn as_datatable(&self) -> Option<&Arc<DataTable>>
Extract a reference to a DataTable.
Sourcepub fn as_indexed_table(&self) -> Option<(u64, &Arc<DataTable>, u32)>
pub fn as_indexed_table(&self) -> Option<(u64, &Arc<DataTable>, u32)>
Extract IndexedTable fields.
Sourcepub fn as_typed_object(&self) -> Option<(u64, &[ValueSlot], u64)>
pub fn as_typed_object(&self) -> Option<(u64, &[ValueSlot], u64)>
Extract TypedObject fields (schema_id, slots, heap_mask).
Sourcepub fn as_closure(&self) -> Option<(u16, &[Upvalue])>
pub fn as_closure(&self) -> Option<(u16, &[Upvalue])>
Extract Closure fields (function_id, upvalues).
Sourcepub fn as_some_inner(&self) -> Option<&ValueWord>
pub fn as_some_inner(&self) -> Option<&ValueWord>
Extract the inner value from a Some variant.
Sourcepub fn as_ok_inner(&self) -> Option<&ValueWord>
pub fn as_ok_inner(&self) -> Option<&ValueWord>
Extract the inner value from an Ok variant.
Sourcepub fn as_err_inner(&self) -> Option<&ValueWord>
pub fn as_err_inner(&self) -> Option<&ValueWord>
Extract the inner value from an Err variant.
Sourcepub fn as_err_payload(&self) -> Option<ValueWord>
pub fn as_err_payload(&self) -> Option<ValueWord>
Extract the original payload from an Err variant, unwrapping AnyError normalization if present.
When Err(x) is constructed at runtime, x is wrapped in an AnyError
TypedObject (slot layout: [category, payload, cause, trace, message, code]).
This method detects that wrapper and returns the original payload from
slot 1 rather than the full AnyError struct.
Sourcepub fn as_trait_object(&self) -> Option<(&ValueWord, &Arc<VTable>)>
pub fn as_trait_object(&self) -> Option<(&ValueWord, &Arc<VTable>)>
Extract TraitObject fields.
Sourcepub fn as_expr_proxy(&self) -> Option<&Arc<String>>
pub fn as_expr_proxy(&self) -> Option<&Arc<String>>
Extract ExprProxy column name.
Sourcepub fn as_filter_expr(&self) -> Option<&Arc<FilterNode>>
pub fn as_filter_expr(&self) -> Option<&Arc<FilterNode>>
Extract FilterExpr node.
Sourcepub fn as_host_closure(&self) -> Option<&HostCallable>
pub fn as_host_closure(&self) -> Option<&HostCallable>
Extract a HostClosure reference.
Sourcepub fn as_duration(&self) -> Option<&Duration>
pub fn as_duration(&self) -> Option<&Duration>
Extract a Duration reference.
Sourcepub fn as_range(&self) -> Option<(Option<&ValueWord>, Option<&ValueWord>, bool)>
pub fn as_range(&self) -> Option<(Option<&ValueWord>, Option<&ValueWord>, bool)>
Extract a Range (start, end, inclusive).
Sourcepub fn as_timespan(&self) -> Option<Duration>
pub fn as_timespan(&self) -> Option<Duration>
Extract a TimeSpan (chrono::Duration).
Sourcepub fn as_timeframe(&self) -> Option<&Timeframe>
pub fn as_timeframe(&self) -> Option<&Timeframe>
Extract a Timeframe reference.
Sourcepub fn as_hashmap(
&self,
) -> Option<(&Vec<ValueWord>, &Vec<ValueWord>, &HashMap<u64, Vec<usize>>)>
pub fn as_hashmap( &self, ) -> Option<(&Vec<ValueWord>, &Vec<ValueWord>, &HashMap<u64, Vec<usize>>)>
Get the HashMap contents if this is a HashMap.
Sourcepub fn as_hashmap_data(&self) -> Option<&HashMapData>
pub fn as_hashmap_data(&self) -> Option<&HashMapData>
Get read-only access to the full HashMapData (includes shape_id).
Sourcepub fn as_hashmap_mut(&mut self) -> Option<&mut HashMapData>
pub fn as_hashmap_mut(&mut self) -> Option<&mut HashMapData>
Get mutable access to the HashMapData.
Uses copy-on-write via as_heap_mut() (clones if Arc refcount > 1).
Sourcepub fn as_set_mut(&mut self) -> Option<&mut SetData>
pub fn as_set_mut(&mut self) -> Option<&mut SetData>
Get mutable access to the SetData.
Sourcepub fn as_deque_mut(&mut self) -> Option<&mut DequeData>
pub fn as_deque_mut(&mut self) -> Option<&mut DequeData>
Get mutable access to the DequeData.
Sourcepub fn as_priority_queue(&self) -> Option<&PriorityQueueData>
pub fn as_priority_queue(&self) -> Option<&PriorityQueueData>
Get the PriorityQueue data if this is a PriorityQueue.
Sourcepub fn as_priority_queue_mut(&mut self) -> Option<&mut PriorityQueueData>
pub fn as_priority_queue_mut(&mut self) -> Option<&mut PriorityQueueData>
Get mutable access to the PriorityQueueData.
Sourcepub fn as_content(&self) -> Option<&ContentNode>
pub fn as_content(&self) -> Option<&ContentNode>
Extract a ContentNode reference.
Sourcepub fn as_time(&self) -> Option<DateTime<FixedOffset>>
pub fn as_time(&self) -> Option<DateTime<FixedOffset>>
Extract a DateTime
Sourcepub fn as_instant(&self) -> Option<&Instant>
pub fn as_instant(&self) -> Option<&Instant>
Extract a reference to the Instant.
Sourcepub fn as_io_handle(&self) -> Option<&IoHandleData>
pub fn as_io_handle(&self) -> Option<&IoHandleData>
Extract a reference to the IoHandleData.
Sourcepub fn as_native_scalar(&self) -> Option<NativeScalar>
pub fn as_native_scalar(&self) -> Option<NativeScalar>
Extract a width-aware native scalar value.
Sourcepub fn as_native_view(&self) -> Option<&NativeViewData>
pub fn as_native_view(&self) -> Option<&NativeViewData>
Extract a pointer-backed native view.
Sourcepub fn as_datetime(&self) -> Option<&DateTime<FixedOffset>>
pub fn as_datetime(&self) -> Option<&DateTime<FixedOffset>>
Extract a reference to the DateTime
Sourcepub fn as_arc_string(&self) -> Option<&Arc<String>>
pub fn as_arc_string(&self) -> Option<&Arc<String>>
Extract an Arc
Sourcepub fn as_int_array(&self) -> Option<&Arc<TypedBuffer<i64>>>
pub fn as_int_array(&self) -> Option<&Arc<TypedBuffer<i64>>>
Extract a reference to an IntArray.
Sourcepub fn as_float_array(&self) -> Option<&Arc<AlignedTypedBuffer>>
pub fn as_float_array(&self) -> Option<&Arc<AlignedTypedBuffer>>
Extract a reference to a FloatArray.
Sourcepub fn as_bool_array(&self) -> Option<&Arc<TypedBuffer<u8>>>
pub fn as_bool_array(&self) -> Option<&Arc<TypedBuffer<u8>>>
Extract a reference to a BoolArray.
Sourcepub fn as_matrix(&self) -> Option<&MatrixData>
pub fn as_matrix(&self) -> Option<&MatrixData>
Extract a reference to MatrixData.
Sourcepub fn as_iterator(&self) -> Option<&IteratorState>
pub fn as_iterator(&self) -> Option<&IteratorState>
Extract a reference to IteratorState.
Sourcepub fn as_generator(&self) -> Option<&GeneratorState>
pub fn as_generator(&self) -> Option<&GeneratorState>
Extract a reference to GeneratorState.
Sourcepub fn typed_array_len(&self) -> Option<usize>
pub fn typed_array_len(&self) -> Option<usize>
Get the length of a typed array (IntArray, FloatArray, BoolArray, width-specific). Returns None for non-typed-array values.
Sourcepub fn coerce_to_float_array(&self) -> Option<Arc<AlignedTypedBuffer>>
pub fn coerce_to_float_array(&self) -> Option<Arc<AlignedTypedBuffer>>
Coerce a typed array to a FloatArray (zero-copy for FloatArray, convert for IntArray).
Sourcepub fn to_generic_array(&self) -> Option<VMArray>
pub fn to_generic_array(&self) -> Option<VMArray>
Convert a typed array to a generic Array of ValueWord values.
Sourcepub fn vw_equals(&self, other: &ValueWord) -> bool
pub fn vw_equals(&self, other: &ValueWord) -> bool
Fast equality comparison without materializing HeapValue. For inline types (f64, i48, bool, none, unit, function), compares bits directly. For heap types, falls back to HeapValue equality.
Sourcepub fn vw_hash(&self) -> u64
pub fn vw_hash(&self) -> u64
Compute a hash for a ValueWord value, suitable for HashMap key usage. Uses the existing tag dispatch for O(1) inline types.
Sourcepub unsafe fn add_i64(a: &Self, b: &Self) -> Self
pub unsafe fn add_i64(a: &Self, b: &Self) -> Self
Add two inline i48 values with overflow promotion to f64.
§Safety
Both a and b must be inline i48 values (is_i64() is true).
Sourcepub unsafe fn sub_i64(a: &Self, b: &Self) -> Self
pub unsafe fn sub_i64(a: &Self, b: &Self) -> Self
Subtract two inline i48 values with overflow promotion to f64.
§Safety
Both a and b must be inline i48 values.
Sourcepub unsafe fn mul_i64(a: &Self, b: &Self) -> Self
pub unsafe fn mul_i64(a: &Self, b: &Self) -> Self
Multiply two inline i48 values with overflow promotion to f64.
§Safety
Both a and b must be inline i48 values.
Sourcepub fn binary_int_preserving(
a: &Self,
b: &Self,
a_num: f64,
b_num: f64,
int_op: impl FnOnce(i64, i64) -> Option<i64>,
float_op: impl FnOnce(f64, f64) -> f64,
) -> Self
pub fn binary_int_preserving( a: &Self, b: &Self, a_num: f64, b_num: f64, int_op: impl FnOnce(i64, i64) -> Option<i64>, float_op: impl FnOnce(f64, f64) -> f64, ) -> Self
Binary arithmetic with integer-preserving semantics and overflow promotion.
If both operands are inline I48, applies int_op (checked) to the i64 values.
On overflow (None), falls back to float_op with the f64 coercions.
If either operand is f64, applies float_op directly.
Callers must ensure a_num and b_num are the as_number_coerce() results
from the same a/b operands.
Sourcepub unsafe fn gt_i64(a: &Self, b: &Self) -> Self
pub unsafe fn gt_i64(a: &Self, b: &Self) -> Self
Compare two inline i48 values (greater than), returning a ValueWord bool.
§Safety
Both a and b must be inline i48 values.
Sourcepub unsafe fn lt_i64(a: &Self, b: &Self) -> Self
pub unsafe fn lt_i64(a: &Self, b: &Self) -> Self
Compare two inline i48 values (less than), returning a ValueWord bool.
§Safety
Both a and b must be inline i48 values.
Sourcepub fn to_number(&self) -> Option<f64>
pub fn to_number(&self) -> Option<f64>
Extract as f64, coercing i48 to f64 if needed.
Alias for as_number_coerce() — convenience method.
Sourcepub fn to_bool(&self) -> Option<bool>
pub fn to_bool(&self) -> Option<bool>
Extract as bool.
Alias for as_bool() — convenience method.
Sourcepub fn as_usize(&self) -> Option<usize>
pub fn as_usize(&self) -> Option<usize>
Convert Int or Number to usize (for indexing operations).
Sourcepub fn to_json_value(&self) -> Value
pub fn to_json_value(&self) -> Value
Convert this value to a JSON value for serialization.