NAME

Protobuf::UnknownFieldSet - Represents unknown fields in a message

VERSION

version 0.04

SYNOPSIS

# Get the set from a message
my $unknowns = $msg->unknown_fields;

# Check if there are any unknown fields
if ($unknowns->get_data) {
    print "Message has unknown fields
";
}

# Clear all unknown fields
$unknowns->clear;

DESCRIPTION

When a Protocol Buffer message is parsed, fields that are not defined in the message's schema (descriptor) are considered "unknown fields". Instead of discarding them, upb (and thus this module) preserves them. This allows messages to be round-tripped through systems with older or different schema versions without losing data.

This class provides an interface to access and manipulate the raw data of these unknown fields associated with a Protobuf::Message instance.

METHODS

get_data()

Returns the raw binary string containing all the unknown field data, or undef if there are no unknown fields.

add($data)

Appends the given $data (raw binary string) to the unknown field set.

clear()

Removes all unknown fields from the message.

delete_tag($tag)

Deletes all unknown fields with the given $tag number.

SEE ALSO

Protobuf, Protobuf::Message

AUTHOR

C.J. Collier <cjac@google.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Google LLC.

This is free software; you can redistribute it and/or modify it under the terms of the BSD 3-Clause License.