hashabler
hashabler copied to clipboard
Can this be the basis for a serialization library?
It's obvious that the Hashable
class is about serialization, or feeding bytes to a consumer in a consistent way. We've found we already have to do mixConstructor
, so already have something that looks close to a serialization/deserialization library. Note Hashable
allows us to hash without allocating and actually writing to memory, so it is more appropriate to implement a serialization library in terms of (what we now call) Hashable
rather than the other way around.
If we try this we'd also want a class for Hashable (Serializable) types of statically-known size (or even a statically-known maximum size for e.g. non-recursive sum types), so that the bytearray for a structure can be allocated all at once, when possible.
I don't have much motivation at the moment to build this or try to build consensus around using this as a core for hashing and serialization libraries, but just putting the idea in writing.