encodeInlineElement
Returns Encoder for decoding an underlying type of an inline class. Serializable inline class is described by the child descriptor of given descriptor at index.
Namely, for the @Serializable inline class MyInt(val my: Int)
, and @Serializable class MyData(val myInt: MyInt)
the following sequence is used:
thisEncoder.encodeInlineElement(MyData.serializer.descriptor, 0).encodeInt(my)
This method is an optimization and its invocation should have the exact same result as
thisEncoder.encodeSerializableElement(MyData.serializer.descriptor, 0, MyInt.serializer(), myInt)
Current encoder may return any other instance of Encoder class, depending on provided descriptor. For example, when this function is called on Json encoder with descriptor that has UInt.serializer().descriptor
at the given index, the returned encoder is able to encode unsigned integers.
Note that this function returns Encoder instead of CompositeEncoder because inline classes always have one property. Calling Encoder.beginStructure on returned instance leads to an undefined behavior.