me.maciejb.snappyflows.impl.Int24.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snappy-flows_2.11 Show documentation
Show all versions of snappy-flows_2.11 Show documentation
Snappy compression Akka Streams flows
The newest version!
package me.maciejb.snappyflows.impl
import akka.util.ByteString
import me.maciejb.snappyflows.impl.ByteStringParser.ByteReader
private[snappyflows] object Int24 {
def readLE(r: ByteReader): Int = r.readByte() | r.readByte() << 8 | r.readByte() << 16
def readLE(arr: Array[Byte]): Int = arr(0) | arr(1) << 8 | arr(2) << 16
def writeLE(number: Int): ByteString = ByteString.apply(
(number & 0xff).toByte,
(number >> 8 & 0xff).toByte,
(number >> 16 & 0xff).toByte
)
}