data.Size.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of noise-kotlin Show documentation
Show all versions of noise-kotlin Show documentation
Noise protocols based on Diffie-Hellman key agreement
The newest version!
package nl.sanderdijkhuis.noise.data
/** Size of a [Data] object. */
@JvmInline
value class Size(val value: UShort) {
val integerValue get() = value.toInt()
operator fun compareTo(size: Size) = value.compareTo(size.value)
fun byteArray(f: (Int) -> Byte) = ByteArray(value.toInt(), f)
operator fun plus(size: Size) = (value + size.value).takeIf { it <= UShort.MAX_VALUE }?.let { Size(it.toUShort()) }
companion object {
val MAX_MESSAGE = Size(UShort.MAX_VALUE)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy