Module workflow_serializer::serializer

source ·

Structs§

  • Serializable<T> is a stop-gap between Borsh serialization and the actual type T that needs to be serialized. T must implement Serializer as opposed to Borsh traits, while Serializable<T> implements Borsh traits. This allows functions requiring Borsh serialization to accept T that does not implement Borsh traits by wrapping it in Serializable<T>.

Traits§

  • Serializer is a trait that allows for data serialization and deserialization similar to Borsh, but via a separate trait. This allows for serialization of additional metadata while using underlying Borsh primitives. For example: a struct can implement both Borsh and Serializer traits where Serializer can store custom metadata (e.g. struct version) and then store the struct using Borsh. Both Serializer and Borsh are almost identical, where Serializer is meant to signal intent for custom serialization. Serializer is a complimentary trait for Serializable struct and can be used to prevent direct Borsh serialization of a struct.