pub fn json_value_to_msgpack_bytes(jv: &JsonValue) -> Result<Vec<u8>, String>Expand description
Encode a JsonValue to MessagePack bytes.
Used by N7 consumers C12 (msgpack.encode) and C13
(msgpack.encode_bytes). Pair with heap_to_json_value to
round-trip a HeapValue tree to MessagePack-encoded bytes.
Routing: this helper internally converts the JsonValue to a
serde_json::Value via json_value_to_serde_json (C3) and then
calls rmp_serde::to_vec on the result. The external surface is a
single named &JsonValue → Result<Vec<u8>, String> contract;
consumers do NOT see the internal serde_json::Value intermediate.
Why this shape (Option C per team-lead authorization): the
rmpv::Value library is NOT in workspace deps, only rmp-serde and
rmp are. The legacy msgpack path
(stdlib/msgpack_module.rs:104-107 pre-bulldozer) routed
value.to_json_value() (deleted) through
rmp_serde::to_vec(&json_value) — the routing-through-serde_json
pattern is precedent. Option C preserves this structural pattern
while exposing a single named JsonValue→bytes helper, decoupling
consumer-body from internal routing (forbidden state: “consumer-
body couples with internal routing” is unrepresentable; future
rmpv-adoption for performance won’t change this helper’s external
contract).
Naming correction: the original REFINEMENT-1A scope brief
paraphrased C6 as json_value_to_rmpv_value. Team-lead self-flagged
this as paraphrase error: supervisor PB 1/4 said “C3-C6 per-format
encoders (json/yaml/toml/msgpack)” with implicit naming, NOT a
literal rmpv requirement. The signature here matches the actual
supervisor framing; rmpv is not used.