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

endless.core.protocol.Decoder.scala Maven / Gradle / Ivy

There is a newer version: 0.31.0
Show newest version
package endless.core.protocol

/** Generic binary decoder
  * @tparam A
  *   value
  */
trait Decoder[+A] {

  /** Decode binary array into value of type `A`
    * @param payload
    *   array of bytes
    * @return
    *   value
    */
  def decode(payload: Array[Byte]): A

  /** Converts this decoder to a Decoder[B] using the supplied A => B */
  def map[B](f: A => B): Decoder[B] = (payload: Array[Byte]) => f(decode(payload))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy