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

darwinMain.com.arkivanov.essenty.parcelable.CommonParceler.kt Maven / Gradle / Ivy

There is a newer version: 1.3.0-dev02
Show newest version
package com.arkivanov.essenty.parcelable

import com.arkivanov.essenty.utils.internal.ExperimentalEssentyApi
import platform.Foundation.NSCoder

/**
 * Interface for [Parceler] implementations in common code (e.g. in `commonMain` source set).
 */
@ExperimentalEssentyApi
actual interface CommonParceler : Parceler {

    /**
     * Writes the [T] instance state to the provided [writer].
     */
    actual fun T.write(writer: ParcelWriter)

    /**
     * Creates a new instance of [T] and reads all its data from the provided [reader].
     */
    actual fun create(reader: ParcelReader): T

    override fun create(coder: NSCoder): T =
        create(ParcelReader(coder))

    override fun T.write(coder: NSCoder) {
        write(ParcelWriter(coder))
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy