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

commonMain.pro.felixo.protobuf.serialization.encoding.DecodeUtil.kt Maven / Gradle / Ivy

The newest version!
package pro.felixo.protobuf.serialization.encoding

import pro.felixo.protobuf.wire.EMPTY_LEN
import pro.felixo.protobuf.wire.WireBuffer
import pro.felixo.protobuf.wire.WireValue

fun , TDecoded: Any> decodeLast(
    wireValues: List?,
    type: TField
): TDecoded? {
    var ret: TDecoded? = null
    wireValues?.forEach { v -> type.decode(v) { ret = it } }
    return ret
}

fun concatLenValues(wireValues: List): WireValue.Len = when (wireValues.size) {
    1 -> wireValues[0]
    0 -> EMPTY_LEN
    else -> {
        val out = WireBuffer()
        for (value in wireValues)
            out.writeAndConsume(value.value)
        WireValue.Len(out)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy