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

ru.m2.calypso.scalapb.GeneratedMessageDecoder.scala Maven / Gradle / Ivy

The newest version!
package ru.m2.calypso.scalapb

import cats.syntax.either._
import ru.m2.calypso.Decoder
import scalapb.GeneratedMessageCompanion

object GeneratedMessageDecoder {
  implicit def decodeGeneratedMessageFromBinary[
      A <: scalapb.GeneratedMessage: GeneratedMessageCompanion
  ]: Decoder[A] =
    Decoder[Array[Byte]]
      .emap { ba =>
        Either
          .catchNonFatal(implicitly[GeneratedMessageCompanion[A]].parseFrom(ba))
          .leftMap(_.getMessage)
      }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy