fun <T : Any> T.serialize(kryo: Kryo = threadLocalP2PKryo(), internalOnly: Boolean = false): SerializedBytes<T>
Can be called on any object to convert it to a byte array (wrapped by SerializedBytes), regardless of whether the type is marked as serializable or was designed for it (so be careful!).