Native adapters for protobuf well-known types.
projections/1 returns ready-to-use entries for the :projections option of
PB.compile/2 and PB.Schema. The adapters are opt-in — nothing is applied
to a schema that does not register them.
PB.compile(descriptor_set,
projections: PB.WellKnownTypes.projections([:time, :wrappers, :json])
)Representations
Each group maps a set of well-known messages to a native Elixir value:
:time
google.protobuf.Timestamp→{:timestamp, unix_nanoseconds}google.protobuf.Duration→{:duration, nanoseconds}
Integer nanoseconds keep protobuf precision intact. Higher-level
integrations can expose lossy DateTime / Duration forms explicitly via a
custom PB.Adapter.
:wrappers
The scalar wrapper messages unwrap to their bare scalar value (or nil when
absent):
google.protobuf.{Int32,Int64,UInt32,UInt64}Value→integergoogle.protobuf.{Float,Double}Value→floatgoogle.protobuf.BoolValue→booleangoogle.protobuf.StringValue→String.t()google.protobuf.BytesValue→binary
:json
The JSON-value messages map to JSON-shaped Elixir terms:
google.protobuf.Value→nil | boolean | number | String.t() | list | mapgoogle.protobuf.ListValue→listgoogle.protobuf.Struct→mapwith string keys
See Adapters and well-known types for how adapters compose with encode, decode, JSON, and validation.
Summary
Types
Native representation of google.protobuf.Duration (:time group).
Native representation of google.protobuf.Timestamp (:time group).
Functions
Returns PB projection entries for a well-known type group or list of groups.
Types
Functions
@spec projections(group() | [group()]) :: [{PB.message_name(), keyword()}]
Returns PB projection entries for a well-known type group or list of groups.