WellKnownTypes

nscn.polaris2.protoc.runtime.WellKnownTypes

The default mapping from Well-Known Types to Scala and Java standard library types.

The raw side of every mapping is protobuf-java's own generated class rather than a hand-written Scala mirror. That is what (nscn.polaris2.protoc.field).wkt_mapping = RAW falls back to, and it means there is no second implementation of Timestamp to keep in step with protobuf's.

The generator emits references to these mappers by name, so they are plain vals and not only givens - nothing here depends on implicit search succeeding.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

object givens

The same mappers as givens, for hand-written code and for a user-declared (nscn.polaris2.protoc.field).type that targets one of these.

The same mappers as givens, for hand-written code and for a user-declared (nscn.polaris2.protoc.field).type that targets one of these.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
givens.type

Value members

Concrete fields

val any: TypeMapper[Any, ProtoAny]
val boolValue: TypeMapper[BoolValue, Boolean]
val bytesValue: TypeMapper[BytesValue, ByteString]
val doubleValue: TypeMapper[DoubleValue, Double]
val durationJava: TypeMapper[Duration, Duration]

Duration as a java.time.Duration.

Duration as a java.time.Duration.

The two disagree about how to represent a negative duration and the difference is silent. java.time.Duration keeps nano in [0, 1e9) and pushes the borrow into seconds, so -1.5s is (-2, 500000000). protobuf requires both components to carry the same sign, so the same value is (-1, -500000000). Writing getSeconds and getNano straight through produces a duration off by one second, which is why the borrow is undone here.

Attributes

val empty: TypeMapper[Empty, Unit]

Empty as Unit.

Empty as Unit.

A field of type Empty therefore reads as Option[Unit], which looks odd but is accurate: the only information such a field carries is whether it is there.

Attributes

val fieldMask: TypeMapper[FieldMask, Vector[String]]
val floatValue: TypeMapper[FloatValue, Float]
val int32Value: TypeMapper[Int32Value, Int]
val int64Value: TypeMapper[Int64Value, Long]
val listValue: TypeMapper[ListValue, Vector[ProtoValue]]
val stringValue: TypeMapper[StringValue, String]
val struct: TypeMapper[Struct, Map[String, ProtoValue]]
val timestampInstant: TypeMapper[Timestamp, Instant]

Timestamp as an Instant.

Timestamp as an Instant.

Instant.getNano is always in [0, 1e9), which is exactly what protobuf requires of Timestamp.nanos, so this direction needs no normalization. The mapping is not total in reverse: a Timestamp carrying an out-of-range nanos is normalized by Instant and will not come back byte-identical.

Attributes

val uint32Value: TypeMapper[UInt32Value, Int]
val uint64Value: TypeMapper[UInt64Value, Long]
val value: TypeMapper[Value, ProtoValue]