commonMain.at.asitplus.wallet.cor.IsoSexEnumSerializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of certificateofresidence-jvm Show documentation
Show all versions of certificateofresidence-jvm Show documentation
Use data representing Certificates of Residence as a SD JWT Credential
The newest version!
package at.asitplus.wallet.cor
import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
object IsoSexEnumSerializer : KSerializer {
override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor("IsoSexEnum?", PrimitiveKind.STRING)
override fun serialize(encoder: Encoder, value: IsoSexEnum?) {
value?.let { encoder.encodeInt(it.code) }
}
override fun deserialize(decoder: Decoder): IsoSexEnum? {
return IsoSexEnum.parseCode(decoder.decodeInt())
}
}