Expand description
v2-raw HeapHeader-equipped element carrier trait.
§Purpose
HeapElement is the compile-time trait that constrains the element type T
of a TypedArray<*const T> instantiation to a HeapHeader-equipped v2-raw
carrier. Implementors (StringObj, DecimalObj, …) own the per-T drop
semantics: release_elem decrements the refcount and fully deallocates
when the count reaches zero.
§Authority
Per ADR-006 §2.7.24 Q25.A SUPERSEDED + R20 S2-prime audit deliverable (b)
§4.1.B decision: option (a) — HeapElement trait dispatch.
The trait is the compile-time-monomorphized per-T release dispatcher for
TypedArray<*const T>::drop_array_heap. Bodies dispatch via the Rust type
system; no runtime NativeKind parameter, no is_heap() probe, no
Bool-default fallback.
§Discipline
- One method (
release_elem), one*const Selfparameter. - Implementor types must have
HeapHeaderat offset 0 (sov2_release(&(*ptr).header)is sound). The#[repr(C)]+ first-field- header invariant perStringObjprecedent enforces this structurally. - The trait is
unsafebecause callers must guaranteeptrvalidity (live allocation, no concurrent free).
§Forbidden
Per ADR-006 §2.7.24 Q25.A SUPERSEDED + audit §4.1.B.3:
HeapElement::release_elemtaking aNativeKindparameter — refused; the trait dispatches via the Rust type system, not via a runtime kind probe. This is the §2.7.7 #4/#7 forbidden pattern (tag_bits-style runtime dispatch on the kind discriminator) at the per-element layer.- Bool-default fallback in
release_elembody — surface-and-stop withNotImplemented(SURFACE: ...)at the construction-site when an inner payload’s drop semantics are unproven. Per §2.7.7 #9. - Implementing
HeapElementfor non-HeapHeader-equipped types (e.g.Arc<>-wrapped storage). The trait is structurally constrained to types withHeapHeaderat offset 0; implementing it for anArc<>-wrapped struct would fail the(*ptr).headerfield access at compile time. - Renaming
HeapElementto defection-attractor framing (heap-bridge, elem-helper, release-translator, etc.) — per CLAUDE.md broader-family regex. The trait describes a structural property (this T lives on the v2-raw heap), not a dispatch role.
Traits§
- Heap
Element - v2-raw HeapHeader-equipped element carrier trait.