ProtoCodec

nscn.polaris2.grpc.codecs.ProtoCodec
object ProtoCodec

scodec codecs for messages generated by mill-protoc.

Was ScalaPb up to 0.0.2, when the messages came from ScalaPB. The shape is unchanged - a Codec[A] built from a message companion - because what a gRPC frame carries is a bare serialized message either way.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
ProtoCodec.type

Members list

Value members

Concrete methods

def codecForGenerated[A <: GeneratedMessage](companion: GeneratedMessageCompanion[A]): Codec[A]
def codecForWellKnown[B <: Message, A](parser: Parser[B], mapper: TypeMapper[B, A]): Codec[A]

A codec for a Well-Known Type used as an RPC request or response.

A codec for a Well-Known Type used as an RPC request or response.

mill-protoc does not generate the Well-Known Types - it maps them, onto protobuf-java's own classes and, under the default STDLIB mapping, onward onto a standard library type (google.protobuf.Empty to Unit, Timestamp to java.time.Instant, and so on). So there is no GeneratedMessageCompanion for codecForGenerated to take, and Unit is not a GeneratedMessage at all; the two halves have to be supplied separately.

Value parameters

mapper

the mapping to the Scala type the generated signature uses - nscn.polaris2.protoc.runtime.WellKnownTypes.empty for STDLIB, or TypeMapper.identity under wkt_mapping = RAW, where the generated signature is the protobuf-java class itself

parser

the protobuf-java parser for the wire form, e.g. com.google.protobuf.Empty.parser()

Attributes

Givens

Givens

given byteVectorTypeMapper: TypeMapper[ByteString, ByteVector]

Lets a bytes field be declared as a ByteVector.

Lets a bytes field be declared as a ByteVector.

Put it in scope and annotate the field with [(nscn.polaris2.protoc.field).type = "scodec.bits.ByteVector"]; the generator emits summon[TypeMapper[ByteString, ByteVector]], which resolves to this.

Attributes