NAME

Protobuf::Descriptor::MessageDef - Descriptor for a Protocol Buffer message

VERSION

version 0.04

SYNOPSIS

my $pool = Protobuf::DescriptorPool->generated_pool;
my $msg_def = $pool->find_message_by_name('my.package.MyMessage');

if ($msg_def) {
    print "Message Name: ", $msg_def->full_name, "
";
    for my $i (0 .. $msg_def->field_count - 1) {
        my $field = $msg_def->get_field($i);
        print "  Field: ", $field->name, " (", $field->type_name, ")
";
    }
}

DESCRIPTION

This class represents the descriptor for a single Protocol Buffer message type. It provides methods to introspect the message's structure, including its fields, oneofs, and nested types.

Instances of this class are usually obtained from a Protobuf::DescriptorPool.

METHODS

full_name()

Returns the fully qualified name of the message (e.g., my.package.MyMessage).

name()

Returns the short name of the message (e.g., MyMessage).

field_count()

Returns the number of fields defined in this message.

get_field($index)

Returns the Protobuf::Descriptor::Field at the given $index (0-based).

find_field_by_name($name)

Returns the Protobuf::Descriptor::Field with the given $name, or undef if not found.

find_field_by_number($number)

Returns the Protobuf::Descriptor::Field with the given tag $number, or undef if not found.

oneof_count()

Returns the number of oneof declarations in this message.

get_oneof($index)

Returns the Protobuf::Descriptor::OneofDef at the given $index (0-based).

find_oneof_by_name($name)

Returns the Protobuf::Descriptor::OneofDef with the given $name, or undef if not found.

nested_message_count()

Returns the number of nested message types defined within this message.

get_nested_message($index)

Returns the Protobuf::Descriptor::MessageDef for the nested message at the given $index (0-based).

SEE ALSO

Protobuf, Protobuf::DescriptorPool, Protobuf::Descriptor

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.