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

commonMain.maryk.core.protobuf.writeKeyWithLength.kt Maven / Gradle / Ivy

Go to download

Maryk is a Kotlin Multiplatform library which helps you to store, query and send data in a structured way over multiple platforms. The data store stores any value with a version, so it is possible to request only the changed data or live listen for updates.

The newest version!
package maryk.core.protobuf

import maryk.core.extensions.bytes.writeVarBytes
import maryk.core.protobuf.WireType.LENGTH_DELIMITED

/**
 * Write ProtoBuf key with length if necessary for [wireType]
 * Pass [index] and [cacheGetter] for values to write to [writer]
 */
fun writeKeyWithLength(
    wireType: WireType,
    index: UInt,
    writer: (byte: Byte) -> Unit,
    cacheGetter: WriteCacheReader
) {
    ProtoBuf.writeKey(index, wireType, writer)
    if (wireType == LENGTH_DELIMITED) {
        cacheGetter.nextLengthFromCache().writeVarBytes(writer)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy