A consolidated list of the options each public entry point accepts. Unknown options are rejected (they raise or return a PB.OptionError) rather than being silently ignored.

:unknown_fields means the same everywhere: on encode, how map keys the message does not define are handled; on JSON and text format decode, how fields in the input the message does not define are handled. Binary decode always keeps unknown fields, as protobuf requires.

PB.compile/2

OptionValuesDefaultNotes
:projectionslist of {fqn, opts}[]Message-level adapters and structural representation. See below.
:pluginslist of module | {module, opts}[]PB.Schema.Plugins that compile their own data into the schema, such as PB.Validate.
:allow_missing_importsbooleanfalseCompile a descriptor set that lacks some of the files its files import, leaving the options they define undecoded. See Missing imports.

Each :projections entry pairs a fully-qualified message name with a keyword list. adapter: is mutually exclusive with the structural keys:

KeyValuesNotes
adapter:%PB.Adapter{}App/proto conversion spec.
struct:ModuleProject the message to a struct.
unwrap:field_name | trueProject to the single field's value.
preserved_unknown_fields::drop | :reject | {:field, atom}Unknown-field policy (struct/unwrap). Default :drop.
extensions::reject | {:field, atom}Extension policy (struct). Default :reject.
oneofs:[{oneof_name, [representation: :identity]}]Identity-projected oneofs.

See Decoding into structs and Adapters and well-known types.

PB.encode/4 / PB.encode!/4 / PB.encode_iodata/4

OptionValuesDefaultNotes
:unknown_fields:error | :ignore:errorHow unknown map keys are handled.

PB.decode/4 / PB.decode!/4

OptionValuesDefaultNotes
:defaultsbooleanfalsePopulate missing scalar/enum/repeated/map fields with proto3 defaults. Singular messages and oneofs are never populated.
:message_namesnil | :rootnilAnnotate the root decoded map with :__message_name__.

PB.JSON encode (encode/4, encode_iodata/4, to_term/4)

OptionValuesDefault
:emit_defaultsbooleanfalse
:use_proto_namesbooleanfalse
:enums_as_intsbooleanfalse
:unknown_fields:error | :ignore:error

PB.JSON decode (decode/4, from_term/4)

OptionValuesDefault
:unknown_fields:error | :ignore:error

:ignore also skips enum strings the enum does not declare.

PB.TextFormat decode (decode/4)

OptionValuesDefault
:unknown_fields:error | :ignore:error
:allow_field_numbersbooleanfalse

PB.TextFormat encode (encode/4, encode_iodata/4)

OptionValuesDefault
:unknown_fields:error | :ignore:error
:single_linebooleanfalse
:short_repeatedbooleanfalse
:print_unknown_fieldsbooleantrue

use PB.Schema accepts :projections, :plugins and :allow_missing_imports with the same meaning.