Skip to main content

Module json_safe_u128_content

Module json_safe_u128_content 

Source
Expand description

Serde with module for a u128 field that is buffered through serde’s Content enum — i.e. a field of an internally-tagged (#[serde(tag = "…")]) enum or struct.

Same JS-safety as json_safe_u128 (values above Number.MAX_SAFE_INTEGER stringify in human-readable JSON), but it never emits serialize_u128. serde’s Content enum cannot hold a 128-bit integer in this serde version, so json_safe_u128’s serialize_u128 round-trips to an “invalid type: integer … as u128” error once internal tagging buffers it. This variant instead encodes a plain number while the value fits in u64, and a string once it doesn’t (and, in human-readable JSON, once it exceeds Number.MAX_SAFE_INTEGER). The Value / bincode paths keep the value lossless via the same number/string split.

Functions§

deserialize
serialize