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

commonMain.com.arkivanov.mvikotlin.timetravel.proto.internal.io.ProtoDecoder.kt Maven / Gradle / Ivy

package com.arkivanov.mvikotlin.timetravel.proto.internal.io

import com.arkivanov.mvikotlin.timetravel.proto.internal.data.ProtoObject
import com.arkivanov.mvikotlin.timetravel.proto.internal.data.timetravelcomand.readTimeTravelCommand
import com.arkivanov.mvikotlin.timetravel.proto.internal.data.timetravelexport.readTimeTravelExport
import com.arkivanov.mvikotlin.timetravel.proto.internal.data.timetravelstateupdate.readTimeTravelStateUpdate

class ProtoDecoder {

    fun decode(data: ByteArray): ProtoObject {
        val reader = DataReader(data)

        return when (reader.readEnum()) {
            ProtoObjectType.TIME_TRAVEL_STATE_UPDATE -> reader.readTimeTravelStateUpdate()
            ProtoObjectType.TIME_TRAVEL_COMMAND -> reader.readTimeTravelCommand()
            ProtoObjectType.TIME_TRAVEL_EXPORT -> reader.readTimeTravelExport()
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy