All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.dokar.quickjs.converter.TypeConverter.kt Maven / Gradle / Ivy

The newest version!
package com.dokar.quickjs.converter

import com.dokar.quickjs.QuickJs
import kotlin.reflect.KType

/**
 * The type converter for custom classes used by [QuickJs]'s functions.
 */
interface TypeConverter {
    /**
     * The source type class.
     */
    val sourceType: KType

    /**
     * The target type class.
     */
    val targetType: KType

    /**
     * Convert a value of type [Source] to type [Target].
     */
    fun convertToTarget(value: Source): Target

    /**
     * Convert a value of type [Target] back to type [Source].
     */
    fun convertToSource(value: Target): Source? = null
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy