I have a `@SerialInfo` annotation that indicates t...
# serialization
z
I have a
@SerialInfo
annotation that indicates that the property is tagged with the given name,
@Field("HEDR")
. When a property has this annotation, it is encoded as a Type-Length-Value structure. As an example,
Copy code
@Field("HEDR")
val header: String = "asdf"
Results in bytes matching
TT TT TT TT LL LL VV VV VV VV
(
HEDR 04 00 asdf
) But, to get this to happen, I have to override the
decode*Element
method for each primitive, to support each serializable type. Example,
Copy code
@Field("HEDR")
val header: String = "asdf"

@Field("INTV")
val taggedValues: Int = 1
Is there an easy/cheap way to perform this tagging on any type, without overriding that specific type in the codec?
My current workaround is to effectively box each property, so my callsite looks like
Copy code
@Field("HEDR")
val header: Field<String>
Or inline classes, allowing me to override the inline or structure methods.