Skip to main content

Module pooling_serde

Module pooling_serde 

Source
Expand description

Serde helper for Pooling fields exposed through the JS surface.

Pooling is #[repr(u8)] with Serialize_repr / Deserialize_repr, so the default wire shape is the numeric discriminant (0/1/2). That number leaks into JSON / Object output and makes XxxJSON.pooling: string declarations false. The helper switches the human-readable path to a camelCase string ("never"/"ifAvailable"/"standard") while keeping the non-HR path at the original u8 so bincode (consensus binary format) is untouched.

Apply via #[serde(with = "crate::withdrawal::pooling_serde")] on the pooling field of any state transition that surfaces it to JS.

Functions§

deserialize
Deserialize accepts both shapes regardless of the deserializer’s human-readable flag — mirrors the BinaryData / Identifier pattern. Necessary because platform_value::to_value reports HR=false (emits the numeric discriminant on the way to JsValue), but platform_value::from_value reports HR=true on the way back. Without dual acceptance, the fromObject(toObject()) round-trip fails on the pooling field.
serialize