commonMain.pro.felixo.protobuf.serialization.encoding.DecodeUtil.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protobuf-kotlin-serialization Show documentation
Show all versions of protobuf-kotlin-serialization Show documentation
Protocol Buffers 3 support for Kotlin Multiplatform
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)
}
}