pub fn heap_to_json_value(hv: &HeapValue) -> Result<JsonValue, String>Expand description
Walk a HeapValue tree and produce a JsonValue.
Universal intermediate per the N7 ε disposition (docs/defections.md,
2026-05-07). Format-specific encoders take &JsonValue (NOT
&HeapValue) and produce per-format bytes/string. Mirrors json.rs’s
parse-side serde_json_to_json_value (stdlib/json.rs:172-196) in
reverse.
Recursion lives at the JsonValue layer (Array/Object children); the
ConcreteReturn leaf-only invariant is preserved.
§Variant classification (REFINEMENT-1A + REFINEMENT-1B-ITEM-A)
Mechanical-yes (5): String, BigInt, Char, TypedArray, HashMap
- TypedObject schema-aware (1) — produce a JsonValue directly or recurse.
Categorically-non-data Reject (5): Future, IoHandle, NativeView,
ClosureRaw, TaskGroup — Err("cannot serialize: <variant>")
permanently. These hold runtime resources; no serialization policy
can convert them to wire format.
Architectural-choice deferred (7): Decimal, DataTable, Content,
Temporal, TableView, Instant, NativeScalar — first-landing
Err(<policy not yet decided>). Each represents a user-visible
behavioral commitment requiring explicit decision per consumer
demand.
V3-S5 ckpt-5-prime (2026-05-15): the TypedArrayData inner-dispatch
description below previously named the 13-arm typed_array_to_json_value
helper. That helper + the HeapValue::TypedArray(ta) outer arm here are
RETIRED in lockstep with the deleted HeapValue::TypedArray variant
(ckpt-4) + deleted TypedArrayData inner enum (ckpt-1). The v2-raw
*mut TypedArray<T> JSON-serialisation path lands at the ckpt-5-prime²
- ckpt-6 producer/consumer storage-shape migration (per W12 audit §3.6
— no
*mut TypedArray<T>value ever reachesheap_to_json_valuepost-V3-S5 ckpt-5: the JSON projection happens at the marshal layer before the value becomes aHeapValue). Refusal #1 binding.