Google-ProtocolBuffers-Dynamic

 view release on metacpan or  search on metacpan

lib/Google/ProtocolBuffers/Dynamic.pm  view on Meta::CPAN

=head2 resolve_references

    $dynamic->resolve_references;

Called implicitly by L</map>, must be called when using the lower-level
mapping functions. Resolves any message cross-references (e.g. fields
with message or enumeration types).

=head1 OPTIONS

Can be passed to the various mapping methods.

=head2 implicit_maps

C<proto3> provides a special C<< map<key, value> >> syntax to define
map fields:

    map<key-type, value-type> field = 1;

which is equivalent to the following C<proto2> definition

    message FieldEntry {
        optional key-type key = 1;
        optional value-type value = 2;
    }
    repeated FieldEntry field = 1;

C<Google::ProtocolBuffers::Dynamic> can detect when a map-like
structure has been defined using the C<proto2> syntax above and
provide the same semantics as a C<proto3> map (i.e. it will accept a
Perl hash when encoding and produce a Perl hash when decoding).

When C<implicit_maps> is enabled, messages with the following properties:

=over 4

=item message name ends in C<Entry>

=item it has an C<optional> field named C<key> with tag 1

=item it has an C<optional> field named C<value> with tag 2

=item it has exactly two fields, and no C<oneof> field

=item C<key> is not a message or enum field

=back

will be marked as map entries. Those rules do not check all the
restrictions that are in place for a C<proto3> map, and they might be
made stricter in the future.

=head2 use_bigints

Enabled by default on Perls with 32-bit integers, disabled by default
on Perls with 64-bit integers.

When enabled, values that don't fit in a 32-bit integer are returned as
L<Math::BigInt> objects.

=head2 boolean_values

Defaults to C<perl>.

It controls how boolean values are mapped in Perl. Accepted values are:

=over 4

=item perl

Maps C<true> to C<1> and C<false> to C<"">.

=item numeric

Maps C<true> to C<1> and C<false> to C<0>.

=item json

Loads L<JSON> and uses C<JSON::true> and C<JSON::false> as
C<true>/C<false> values.

=back

=head2 check_required_fields

Enabled by default.

When enabled, checks that all required fields are present (for both
encoding and decoding).

=head2 encode_defaults

Disabled by default, it can't be enabled for C<proto3>.

When disabled, if the value of a field is equal to its default, the
field is not emitted during serialization, whether the value was
explicitly set or not.

When enabled, and a value was explicitly set for the field, the field
is always emitted.

=head2 encode_defaults_proto3

Disabled by default, it can't be enabled for C<proto2>.

Same as C<encode_defaults>. The only reason to enable this is as an
hack to emulate proto3 field presence support.

=head2 explicit_defaults

Disabled by default.

When enabled, explicitly sets all missing scalar fields (but not oneof
members) to their default value when decoding.

=head2 check_enum_values

Enabled by default.

When enabled, invalid enum values throw an error in
getters/setters/encoding and are replaced with the default value for



( run in 0.307 second using v1.01-cache-2.11-cpan-f4a522933cf )