encodeInline

open override fun encodeInline(descriptor: SerialDescriptor): Encoder(source)

Returns Encoder for encoding an underlying type of a value class in an inline manner. descriptor describes a serializable value class.

Namely, for the @Serializable @JvmInline value class MyInt(val my: Int), the following sequence is used:

thisEncoder.encodeInline(MyInt.serializer().descriptor).encodeInt(my)

Current encoder may return any other instance of Encoder class, depending on the provided descriptor. For example, when this function is called on Json encoder with UInt.serializer().descriptor, the returned encoder is able to encode unsigned integers.

Note that this function returns Encoder instead of the CompositeEncoder because value classes always have the single property. Calling Encoder.beginStructure on returned instance leads to an unspecified behavior and, in general, is prohibited.