Skip to main content

Module serde_bytes

Module serde_bytes 

Source
Expand description

Generic serde helper for fixed-size byte arrays [u8; N].

Default serde serializes [u8; N] for N ≤ 32 as a tuple of u8 elements (a sequence of numbers in JSON, opaque in non-self-describing formats). For N > 32 there is no default impl at all.

This module gives a single, length-agnostic shape:

  • Human-readable formats (JSON): base64-encoded string (matches Bytes20 / Bytes32 / Bytes36 / BinaryData in rs-platform-value)
  • Binary formats (bincode, CBOR, platform_value): raw byte sequence (which becomes Uint8Array through serde_wasm_bindgen with serialize_bytes_as_arrays(false))

Used via #[serde(with = "crate::serialization::serde_bytes")] on any [u8; N] field. The #[json_safe_fields] proc-macro injects this for every fixed-size byte field.

Functions§

deserialize
serialize