PB.Schema.Info (PB v0.2.0)

Copy Markdown View Source

Public introspection structs returned by PB.Schema.fetch_message/2 and friends.

These structs are a stable, intentionally narrow projection of the internal compiled schema. Callers should branch off the public structs rather than reading schema.messages directly: the internal compiled representation may grow new fields or change shape as the runtime evolves.

Packages

package on Message, Enum and Service is the proto package of the file declaring the type, or nil for a file without one. Nested types share their file's package, so a.b.Outer.Inner declared in package a.b has package: :"a.b".

Options

options on Field and Message is the declaration's google.protobuf.FieldOptions or google.protobuf.MessageOptions, decoded like any other message: standard options under their field names and custom options under :__extensions__, keyed by the extension's full name. It is %{} when the declaration has no options. Custom options whose extension isn't in the descriptor set stay undecoded under :__unknown_fields__.

field.options[:deprecated]
#=> true

PB.Schema.option(field, :"acme.v1.sensitive")
#=> true

Field types

%PB.Schema.Info.Field{}.type is a tagged tuple:

  • {:scalar, scalar} where scalar is one of :double, :float, :int32, :int64, :uint32, :uint64, :sint32, :sint64, :fixed32, :fixed64, :sfixed32, :sfixed64, :bool, :string, :bytes.
  • {:message, message_name} — a message reference.
  • {:enum, enum_name} — an enum reference.
  • {:map, key_type, value_type} — only emitted when field.cardinality == :map; key_type and value_type are themselves tagged tuples following the same shape.