Hey, when making a custom `TaggedEncoder` is there...
# serialization
m
Hey, when making a custom
TaggedEncoder
is there a way to detect if a value is UInt? I can find the override
encodeTaggedInt
but not one of UInt, seems like it gets converted to Int
b
Maybe something like this? https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/formats.md#format-specific-types
Copy code
serializer.descriptor == byteArraySerializer.descriptor
Specially handling the UInt serializer in
encodeSerializableValue
, point it to a private
encodeUInt
that's implemented the same as the other encode methods, then calling your own
encodeTaggedUInt
(edit: first part won't work because the UInt serializer doesn't call encodeSerializableValue. see my 3rd reply)
Since UInt is inline, you might be able to optimize it a little by using
encodeInline
, though I'm not familiar enough with inline serializing to know the best way to implement that
(not at a computer right now so the code might not quite work) Looking at the UIntSerializer, it looks like something like this would work: