summaryrefslogtreecommitdiff
path: root/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/google.golang.org/protobuf/reflect/protoreflect/type.go')
-rw-r--r--vendor/google.golang.org/protobuf/reflect/protoreflect/type.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go
index 5be14a725..8e53c44a9 100644
--- a/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go
+++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go
@@ -232,11 +232,15 @@ type MessageDescriptor interface {
type isMessageDescriptor interface{ ProtoType(MessageDescriptor) }
// MessageType encapsulates a MessageDescriptor with a concrete Go implementation.
+// It is recommended that implementations of this interface also implement the
+// MessageFieldTypes interface.
type MessageType interface {
// New returns a newly allocated empty message.
+ // It may return nil for synthetic messages representing a map entry.
New() Message
// Zero returns an empty, read-only message.
+ // It may return nil for synthetic messages representing a map entry.
Zero() Message
// Descriptor returns the message descriptor.
@@ -245,6 +249,26 @@ type MessageType interface {
Descriptor() MessageDescriptor
}
+// MessageFieldTypes extends a MessageType by providing type information
+// regarding enums and messages referenced by the message fields.
+type MessageFieldTypes interface {
+ MessageType
+
+ // Enum returns the EnumType for the ith field in Descriptor.Fields.
+ // It returns nil if the ith field is not an enum kind.
+ // It panics if out of bounds.
+ //
+ // Invariant: mt.Enum(i).Descriptor() == mt.Descriptor().Fields(i).Enum()
+ Enum(i int) EnumType
+
+ // Message returns the MessageType for the ith field in Descriptor.Fields.
+ // It returns nil if the ith field is not a message or group kind.
+ // It panics if out of bounds.
+ //
+ // Invariant: mt.Message(i).Descriptor() == mt.Descriptor().Fields(i).Message()
+ Message(i int) MessageType
+}
+
// MessageDescriptors is a list of message declarations.
type MessageDescriptors interface {
// Len reports the number of messages.
@@ -279,8 +303,15 @@ type FieldDescriptor interface {
// JSONName reports the name used for JSON serialization.
// It is usually the camel-cased form of the field name.
+ // Extension fields are represented by the full name surrounded by brackets.
JSONName() string
+ // TextName reports the name used for text serialization.
+ // It is usually the name of the field, except that groups use the name
+ // of the inlined message, and extension fields are represented by the
+ // full name surrounded by brackets.
+ TextName() string
+
// HasPresence reports whether the field distinguishes between unpopulated
// and default values.
HasPresence() bool
@@ -371,6 +402,9 @@ type FieldDescriptors interface {
// ByJSONName returns the FieldDescriptor for a field with s as the JSON name.
// It returns nil if not found.
ByJSONName(s string) FieldDescriptor
+ // ByTextName returns the FieldDescriptor for a field with s as the text name.
+ // It returns nil if not found.
+ ByTextName(s string) FieldDescriptor
// ByNumber returns the FieldDescriptor for a field numbered n.
// It returns nil if not found.
ByNumber(n FieldNumber) FieldDescriptor