Skip to main content

KindedSlot

Struct KindedSlot 

Source
#[repr(C)]
pub struct KindedSlot { pub slot: ValueSlot, pub kind: NativeKind, }
Expand description

Caller-side runtime-value carrier: a ValueSlot paired with the NativeKind that interprets it. ADR-006 §2.7.

Not Copy. Drop and clone dispatch on kind to manage heap refcounts; aliasing copies would leak / double-free.

Fields§

§slot: ValueSlot§kind: NativeKind

Implementations§

Source§

impl KindedSlot

Source

pub fn new(slot: ValueSlot, kind: NativeKind) -> Self

Construct from an already-owned slot + its kind. The caller must ensure the slot’s bits are a valid representation of kind (e.g. for heap kinds, one strong-count share owned by this KindedSlot).

Source

pub fn from_int(i: i64) -> Self

Convenience: a numeric Int64-kind slot.

Source

pub fn from_number(n: f64) -> Self

Convenience: a Float64-kind slot.

Source

pub fn from_f32(f: f32) -> Self

Convenience: a Float32-kind slot. ADR-006 §2.7.5 amendment (Round 19 S1.5 W12-nativekind-scalar-additions, 2026-05-14). f32 is a 4-byte scalar; slot bits store the IEEE-754 single-precision pattern zero-extended into the low 32 bits of the 8-byte slot (via f32::to_bits reinterpreted as u64). Drop is a no-op (inline scalar, no Arc<T> payload).

Source

pub fn from_bool(b: bool) -> Self

Convenience: a Bool-kind slot.

Source

pub fn from_string_arc(s: Arc<String>) -> Self

Convenience: a String-kind slot from an Arc<String>.

Source

pub fn from_typed_object(o: Arc<TypedObjectStorage>) -> Self

Convenience: a Ptr(HeapKind::TypedObject)-kind slot from an Arc<TypedObjectStorage>. Wave 2 Agent D1 (2026-05-14): legacy transitional constructor — see ValueSlot::from_typed_object docstring for the Arc-vs-raw-pointer staging. Slot bits are Arc::into_raw(o).

Source

pub fn from_typed_object_raw(ptr: *const TypedObjectStorage) -> Self

Convenience: a Ptr(HeapKind::TypedObject)-kind slot from a raw *const TypedObjectStorage. Wave 2 Agent D1 (2026-05-14): v2-raw raw-pointer constructor. Per ADR-006 §2.3 amendment + audit §4.3 O-3.a resolution. Pairs with TypedObjectStorage::_new allocator; refcount discipline goes through the on-header refcount via v2_retain / v2_release (NOT Rust Arc::increment/decrement_ strong_count). See ValueSlot::from_typed_object_raw docstring for the full call-site migration pattern.

Source

pub fn from_hashmap(h: Arc<HashMapKindedRef>) -> Self

Convenience: a Ptr(HeapKind::HashMap)-kind slot.

Wave 2 Round 3b C2-joint ckpt-2 (2026-05-14): parameter type flipped from Arc<HashMapData> (non-generic) to Arc<HashMapKindedRef> (per-V enum carrier in Arc) per ADR-006 §2.7.24 Q25.B SUPERSEDED.

Source

pub fn from_hashset(h: Arc<HashSetData>) -> Self

Convenience: a Ptr(HeapKind::HashSet)-kind slot. Mirror of from_hashmap per ADR-006 §2.7.15 / Q16 amendment (Wave 13 W13-hashset-rebuild). Set is a HashMap sibling — full HeapValue::HashSet(Arc<HashSetData>) arm, not pure-discriminator.

Source

pub fn from_deque(d: Arc<DequeData>) -> Self

Convenience: a Ptr(HeapKind::Deque)-kind slot. Mirror of from_hashset per ADR-006 §2.7.19 / Q20 amendment (Wave 15 W15-deque). Deque is a HashSet sibling — full HeapValue::Deque(Arc<DequeData>) arm, not pure-discriminator.

Source

pub fn from_channel(c: Arc<ChannelData>) -> Self

Convenience: a Ptr(HeapKind::Channel)-kind slot. Mirror of from_hashset per ADR-006 §2.7.20 / Q21 amendment (Wave 15 W15-channel-rebuild). Channel is the first concurrency primitive to land kinded — full HeapValue::Channel(Arc<ChannelData>) arm, not pure-discriminator. Inner state carries Mutex<ChannelInner>; cloning the outer Arc hands out a fresh endpoint of the same channel.

Source

pub fn from_trait_object(t: Arc<TraitObjectStorage>) -> Self

Convenience: a Ptr(HeapKind::TraitObject)-kind slot. Mirror of from_typed_object per ADR-006 §2.7.24 / Q25.C amendment (Wave 17 W17-trait-object-storage, 2026-05-11). Full HeapValue::TraitObject(Arc<TraitObjectStorage>) arm — TraitObjectStorage is the typed-Arc replacement for the bulldozer-deleted HeapValue::TraitObject { value: Box<u64>, vtable: Arc<VTable> } shape.

Wave 2 Agent E (2026-05-14): legacy transitional constructor. See ValueSlot::from_trait_object docstring for the Arc-vs-raw-pointer staging.

Source

pub fn from_trait_object_raw(ptr: *const TraitObjectStorage) -> Self

Convenience: a Ptr(HeapKind::TraitObject)-kind slot from a raw *const TraitObjectStorage. Wave 2 Agent E (2026-05-14): v2-raw raw-pointer constructor. Per ADR-006 §Q25.C.5 amendment + audit §4.3 O-3.a resolution. Pairs with TraitObjectStorage::_new allocator; refcount discipline goes through the on-header refcount via v2_retain / v2_release (NOT Rust Arc::increment/decrement_ strong_count). See ValueSlot::from_trait_object_raw docstring for the full call-site migration pattern.

Source

pub fn from_mutex(m: Arc<MutexData>) -> Self

Convenience: a Ptr(HeapKind::Mutex)-kind slot. Mirror of from_channel per ADR-006 §2.7.25 amendment (Wave 17 W17-concurrency, 2026-05-11). Full HeapValue::Mutex(Arc<MutexData>) arm.

Source

pub fn from_atomic(a: Arc<AtomicData>) -> Self

Convenience: a Ptr(HeapKind::Atomic)-kind slot. Mirror of from_channel per ADR-006 §2.7.25 amendment (Wave 17 W17-concurrency, 2026-05-11). Full HeapValue::Atomic(Arc<AtomicData>) arm. i64-only at landing.

Source

pub fn from_lazy(l: Arc<LazyData>) -> Self

Convenience: a Ptr(HeapKind::Lazy)-kind slot. Mirror of from_channel per ADR-006 §2.7.25 amendment (Wave 17 W17-concurrency, 2026-05-11). Full HeapValue::Lazy(Arc<LazyData>) arm.

Source

pub fn from_temporal(arc: Arc<TemporalData>) -> Self

Convenience: a Ptr(HeapKind::Temporal)-kind slot. ADR-006 §2.7.6 / Q8 cardinality amendment (Wave 3 W17-from-temporal- instant-constructors, 2026-05-12). Slot bits are Arc::into_raw(Arc<TemporalData>) as u64; recovery goes through the canonical 5-arm receiver-recovery pattern (reconstruct via Arc::<TemporalData>::from_raw, clone, into_raw to restore). Mirror of from_iterator typed-Arc dispatch shape — TemporalData is the consolidated DateTime / Duration / TimeSpan / Timeframe / TimeReference / DateTimeExpr / DataDateTimeRef carrier per heap_value.rs::TemporalData. The Drop / Clone arms for HeapKind::Temporal already dispatch the matching strong-count retain/release; this constructor pairs with them by the §2.7.6 / Q8 bounded carrier-API rule (one constructor per NativeKind heap variant, no new heap-variant cardinality introduced).

Source

pub fn from_instant(arc: Arc<Instant>) -> Self

Convenience: a Ptr(HeapKind::Instant)-kind slot. ADR-006 §2.7.6 / Q8 cardinality amendment (Wave 3 W17-from-temporal- instant-constructors, 2026-05-12). Slot bits are Arc::into_raw(Arc<std::time::Instant>) as u64; recovery goes through the canonical 5-arm receiver-recovery pattern. Mirror of from_temporal for the Instant sibling — Instant rides Arc<std::time::Instant> directly (no InstantData wrapper). The Drop / Clone arms for HeapKind::Instant already dispatch the matching strong-count retain/release; this constructor pairs with them by the §2.7.6 / Q8 bounded carrier-API rule.

Source

pub fn from_iterator(it: Arc<IteratorState>) -> Self

Convenience: a Ptr(HeapKind::Iterator)-kind slot. Stores the Arc::into_raw pointer directly per ADR-006 §2.7.16 / Q17 (W13- iterator-state).

Source

pub fn from_priority_queue(p: Arc<PriorityQueueData>) -> Self

Convenience: a Ptr(HeapKind::PriorityQueue)-kind slot. Mirror of from_hashset per ADR-006 §2.7.18 / Q19 amendment (Wave 15 W15-priority-queue). PriorityQueue is a HashSet sibling — full HeapValue::PriorityQueue(Arc<PriorityQueueData>) arm, not pure-discriminator.

Source

pub fn from_range(r: Arc<RangeData>) -> Self

Convenience: a Ptr(HeapKind::Range)-kind slot. Stores the Arc<RangeData> directly per ADR-006 §2.7.23 / Q24 (W15-range). Slot bits are Arc::into_raw(Arc<RangeData>) as u64; recovery goes through slot.as_heap_value()HeapValue::Range(arc) per ADR-005 §1 single-discriminator.

Source

pub fn from_content(c: Arc<ContentNode>) -> Self

Convenience: a Ptr(HeapKind::Content)-kind slot. Stores the Arc<ContentNode> directly per ADR-006 §2.3 (W18.6 R8 W3 2026-05-24 — supervisor D3+D4 Display.display() → content + ContentNode user-facing type exposure). Slot bits are Arc::into_raw(Arc<ContentNode>) as u64; the Drop / Clone arms for HeapKind::Content already dispatch the matching strong- count retain/release. Used by the Content.text(...) / Content.code(...) / etc. user-facing constructor builtins (ContentTextCtor family) and by user-defined Display impls whose method display() -> content return value is pushed through this carrier.

Source

pub fn from_result(r: Arc<ResultData>) -> Self

Convenience: a Ptr(HeapKind::Result)-kind slot. ADR-006 §2.7.17 / Q18 amendment (Wave 14 W14-variant-codegen). Mirror of from_iterator typed-Arc dispatch shape.

Source

pub fn from_option(o: Arc<OptionData>) -> Self

Convenience: a Ptr(HeapKind::Option)-kind slot. ADR-006 §2.7.17 / Q18 amendment (Wave 14 W14-variant-codegen).

Source

pub fn from_decimal(d: Arc<Decimal>) -> Self

Convenience: a Ptr(HeapKind::Decimal)-kind slot.

Source

pub fn from_string_v2_ptr(ptr: *const StringObj) -> Self

Convenience: a StringV2-kind slot from a v2-raw *const StringObj pointer. ADR-006 §2.7.5 amendment (Wave 2 Agent B W12-StringV2- DecimalV2-NativeKind-additions, 2026-05-14): paired with NativeKind::StringV2 per the audit §H.4 H-c decision. Slot bits = ptr as u64; the KindedSlot owns one refcount share on the underlying StringObj — Drop dispatches the matching v2_release against the HeapHeader at offset 0.

Caller’s construction-side contract: ptr MUST point to a live StringObj whose refcount has been incremented (typically via v2_retain at the producing op_typed_array_get site) to claim the share this KindedSlot now owns. Mirror of from_string_arc’s “slot owns one strong share” contract — but the underlying retain is v2_retain against the repr(C) HeapHeader, not Arc::increment_strong_count against an Arc<String>.

Source

pub fn from_decimal_v2_ptr(ptr: *const DecimalObj) -> Self

Convenience: a DecimalV2-kind slot from a v2-raw *const DecimalObj pointer. ADR-006 §2.7.5 amendment (Wave 2 Agent B W12-StringV2- DecimalV2-NativeKind-additions, 2026-05-14): mirror of from_string_v2_ptr for the DecimalObj sibling. Same construction- side contract.

Source

pub fn from_bigint(b: Arc<i64>) -> Self

Convenience: a Ptr(HeapKind::BigInt)-kind slot.

Source

pub fn from_io_handle(h: Arc<IoHandleData>) -> Self

Convenience: a Ptr(HeapKind::IoHandle)-kind slot from an Arc<IoHandleData>. R8 W6 G.1 W17-marshal-return-arms close (2026-05-24): mirrors the existing 14 typed-Arc constructor precedents (ADR-005 §1 single-discriminator + ADR-006 §2.7.6 / Q8 bounded carrier-API). Slot bits = Arc::into_raw(h) as u64 via ValueSlot::from_io_handle; the Drop / Clone arms for HeapKind::IoHandle (kinded_slot.rs ~line 868 / ~line 1227) already dispatch the matching Arc::increment/decrement_strong_ count::<IoHandleData> retain/release. Used by project_typed_return (vm_impl/modules.rs) to land the ConcreteReturn::IoHandle(Arc<IoHandleData>) arm from transport::tcp() / io::tcp_listen() / file::open() etc. without producer/consumer divergence (pre-fix VM surfaced project_typed_return: W17-marshal-return-arms while JIT returned ec=0 garbage).

Source

pub fn from_data_table(d: Arc<DataTable>) -> Self

Convenience: a Ptr(HeapKind::DataTable)-kind slot from an Arc<DataTable>. R8 W6 G.1 W17-marshal-return-arms close (2026-05-24): sibling of from_io_handle — same family of ConcreteReturn discriminant gap (disc 15 vs disc 16). Slot bits = Arc::into_raw(d) as u64 via ValueSlot::from_data_table; the Drop / Clone arms for HeapKind::DataTable (kinded_slot.rs ~line 863 / ~line 1222) already dispatch the matching Arc::increment/decrement_strong_count::<DataTable> retain/release. Used by project_typed_return to land the ConcreteReturn::DataTable(Arc<DataTable>) arm from arrow_module / wire-conversion factory returns.

Source

pub fn from_char(c: char) -> Self

Convenience: a Char-kind slot. ADR-006 §2.7.5 amendment (Round 19 S1.5 W12-nativekind-scalar-additions, 2026-05-14): Char joins the scalar bucket — char is Copy + 4-byte (UTF-32 codepoint), no Arc payload. Slot bits store c as u32 zero-extended into the low 32 bits of the 8-byte slot.

Pre-amendment (Round 18 and earlier) this constructor returned a slot with kind NativeKind::Ptr(HeapKind::Char) — the inline- codepoint payload tagged through HeapKind for dispatch uniformity. The post-amendment shape is a pure scalar variant (NativeKind::Char), aligning Char with the other 4-byte scalars (Int32 / UInt32 / Float32) per §Q8 carrier-API bound (one constructor per scalar variant). The NativeKind::Ptr(HeapKind::Char) label still exists in source (direct push_kinded(c as u64, NativeKind::Ptr(HeapKind::Char)) call-sites have NOT been migrated in this dispatch — a future cluster-1 hardening sub-cluster retires that parallel label). Drop is a no-op (inline scalar; the NativeKind::Char arm in Drop is part of the inline-scalar group).

Source

pub fn from_matrix(m: Arc<MatrixData>) -> Self

Convenience: a Ptr(HeapKind::Matrix)-kind slot. ADR-006 §2.7.22 amendment (Round 18 S3 W12-matrix-floatslice-heapkind-exit, 2026-05-13). Slot bits are Arc::into_raw(Arc<MatrixData>) as u64; recovery goes through the canonical reconstruct-clone-restore pattern (Arc::<MatrixData>::from_raw(bits) → clone → into_raw) to bump the inner share while preserving the carrier’s owned outer share. Mirror of from_iterator / from_range typed-Arc dispatch shape — as_heap_value() on a Matrix-labeled slot is unsound (the slot bits are an Arc<MatrixData> pointer, not a *const HeapValue). The Drop / Clone arms for HeapKind::Matrix dispatch the matching Arc::increment/decrement_strong_count ::<MatrixData> retain/release.

Source

pub fn from_matrix_slice(s: Arc<MatrixSliceData>) -> Self

Convenience: a Ptr(HeapKind::MatrixSlice)-kind slot. ADR-006 §2.7.22 amendment (Round 18 S3 W12-matrix-floatslice-heapkind-exit, 2026-05-13). Slot bits are Arc::into_raw(Arc<MatrixSliceData>) as u64. Same typed-Arc pure-discriminator dispatch shape as from_matrix. The inner MatrixSliceData { parent, offset, len } retains a separate strong-count share on its parent matrix; cloning the outer share does NOT bump the parent — that bump happens at MatrixSliceData::clone (auto-derived) when the inner struct is duplicated under Arc::make_mut.

Source

pub fn from_module_fn_id(id: u64) -> Self

Convenience: a Ptr(HeapKind::ModuleFn)-kind slot. Stores the module_fn_id as raw u64 slot bits directly (inline-scalar payload — no Arc<T>, no heap state). Same shape as from_char / from_future per ADR-006 §2.7.26 (W17-comptime-vm-dispatch).

Construction-side contract: id must index a registered entry in VirtualMachine.module_fn_table. The dispatch shell at executor/call_convention.rs::call_value_immediate_nb consumes the kind label to route the slot’s bits to invoke_module_fn_id_stub at CallValue time.

Source

pub fn from_string(s: &str) -> Self

Convenience: a String-kind slot from a &str. Allocates a fresh Arc<String>. Use from_string_arc when you already have the Arc<String> in hand and want to avoid a clone.

Source

pub fn none() -> Self

A null/none-value KindedSlot.

R5b-2-bool-null-sentinel-cluster (ADR-006 §2.7 + §2.7.5 + §2.7.7/Q9, 2026-05-19): pre-disposition this returned (ValueSlot::none(), NativeKind::Bool) as the §2.7 sentinel, which collided with legitimate false bool slots (both encoded as bits=0). The collision caused VM-only divergence per W14.2-G6 SURFACE-G6-BOOL-NULL + SURFACE-G6-LET-ONLY-BODY + SURFACE-G6-NONE-OUTPUT-ADAPTER. Post-disposition: kind IS the discriminator per §2.7.7/Q9 — return NativeKind::Null. Drop remains a no-op (Null is a non-parametric absence-of-value sentinel with no Arc payload).

Source

pub fn slot(&self) -> ValueSlot

Read the inner slot.

Source

pub fn kind(&self) -> NativeKind

Read the kind.

Source

pub fn raw(&self) -> u64

Raw slot bits. Provided for sites that need to peek at the storage shape (e.g. wire serialization). Prefer typed accessors.

Source

pub fn as_i64(&self) -> Option<i64>

Read as i64 if self.kind == NativeKind::Int64, else None.

Source

pub fn as_f64(&self) -> Option<f64>

Read as f64 if self.kind == NativeKind::Float64, else None.

Source

pub fn as_bool(&self) -> Option<bool>

Read as bool if self.kind == NativeKind::Bool, else None.

Source

pub fn as_char(&self) -> Option<char>

Read as char if self.kind == NativeKind::Char, else None. ADR-006 §2.7.5 amendment (Round 19 S1.5, 2026-05-14): the §Q8 carrier-API bound binds as_char to the new scalar NativeKind::Char variant. The pre-amendment NativeKind::Ptr(HeapKind::Char) carrier label is ALSO recognized for cross-tier-compatibility — the label still exists in source (direct push_kinded(c as u64, NativeKind::Ptr(HeapKind::Char)) call-sites have NOT been migrated in this dispatch); recognizing both labels avoids producer/consumer mismatch when those call- sites flow values through code paths that materialize as KindedSlot before consuming as_char. Both labels store codepoint bits zero-extended in the low 32 bits of the slot, so the read is identical in either kind.

Source

pub fn as_f32(&self) -> Option<f32>

Read as f32 if self.kind == NativeKind::Float32, else None. ADR-006 §2.7.5 amendment (Round 19 S1.5, 2026-05-14). Slot bits store the IEEE-754 single-precision pattern zero-extended into the low 32 bits; f32::from_bits reinterprets the low 32 bits.

Source

pub fn as_str(&self) -> Option<&str>

Read as &str if self.kind == NativeKind::String (legacy Arc carrier) or NativeKind::StringV2 (v2-raw *const StringObj carrier), else None. Both carriers expose the same UTF-8 bytes; the accessor dispatches on kind and borrows the inner &str for the lifetime of &self. The carrier owns one strong-count share (Arc) / HeapHeader refcount (StringObj), so the inner string is alive while &self lives.

D-β string-join receiver-kind fix (v0.3 KC #6(d), 2026-05-22): the pre-fix arm gated only on NativeKind::String. Elements read from a v2-raw TypedArray<*const StringObj> (i.e. an Array<string> literal lowered through NewTypedArrayString + TypedArrayPushString) flow through TypedArrayGetString (v2_handlers/array.rs:702) which pushes NativeKind::StringV2; without the StringV2 arm here, every universal-method dispatch on a v2-raw string receiver (e.g. arr[i].toString() inside Vec<T>.join’s body) surfaced “TypeError: expected string receiver, got non-string kind”. Per ADR-006 §2.7.5 amendment Wave 2 Agent B both carrier labels store equivalent UTF-8 bytes; the per-carrier read is the producer-site proof, not fabrication.

Trait Implementations§

Source§

impl Clone for KindedSlot

Clone dispatches on kind to bump the matching Arc<T> strong-count.

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for KindedSlot

Source§

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

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

impl Default for KindedSlot

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for KindedSlot

Drop dispatches on kind to retire the matching Arc<T> strong-count share. Mirrors TypedObjectStorage::Drop in heap_value.rs:761.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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,