Function serialize_32_bytes

Source
pub fn serialize_32_bytes<S>(
    bytes: &[u8; 32],
    serializer: S,
) -> Result<S::Ok, S::Error>
where S: Serializer,
Expand description

Custom serialization for 32-byte arrays (challenge params, public keys).

Serializes a fixed-size 32-byte array into a byte sequence suitable for various serialization formats.

§Arguments

  • bytes: A reference to a 32-byte array representing cryptographic data such as public keys or challenge parameters.
  • serializer: The serde serializer instance that will handle the actual serialization format.

§Returns

  • Result<S::Ok, S::Error>: Success value from the serializer or a serialization error if the operation fails.

§Type Parameters

  • S: The serializer type that implements the Serializer trait.

§Example

use ironshield_types::serialize_32_bytes;

#[derive(serde::Serialize)]
struct CryptoKey {
    #[serde(serialize_with = "serialize_32_bytes")]
    public_key: [u8; 32],
}