Serialization formats typically handle these kinds by calling a corresponding primitive method on encoder or decoder. For example, if the following serializable class
class Color(val red: Byte, val green: Byte, val blue: Byte) is represented by your serializer as a single Int value, a typical serializer will serialize its value in the following manner:
val intValue = color.rgbToInt()
and a corresponding Decoder counterpart.
Serial descriptors for primitive kinds are not expected to have any nested elements, thus its element count should be zero. If a class is represented as a primitive value, its corresponding serial name should not be equal to the corresponding primitive type name. For the
Color example, represented as single Int, its descriptor should have INT kind, zero elements and serial name not equals to