khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame^] | 1 | // Copyright 2018 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package protoreflect |
| 6 | |
| 7 | // Descriptor provides a set of accessors that are common to every descriptor. |
| 8 | // Each descriptor type wraps the equivalent google.protobuf.XXXDescriptorProto, |
| 9 | // but provides efficient lookup and immutability. |
| 10 | // |
| 11 | // Each descriptor is comparable. Equality implies that the two types are |
| 12 | // exactly identical. However, it is possible for the same semantically |
| 13 | // identical proto type to be represented by multiple type descriptors. |
| 14 | // |
| 15 | // For example, suppose we have t1 and t2 which are both MessageDescriptors. |
| 16 | // If t1 == t2, then the types are definitely equal and all accessors return |
| 17 | // the same information. However, if t1 != t2, then it is still possible that |
| 18 | // they still represent the same proto type (e.g., t1.FullName == t2.FullName). |
| 19 | // This can occur if a descriptor type is created dynamically, or multiple |
| 20 | // versions of the same proto type are accidentally linked into the Go binary. |
| 21 | type Descriptor interface { |
| 22 | // ParentFile returns the parent file descriptor that this descriptor |
| 23 | // is declared within. The parent file for the file descriptor is itself. |
| 24 | // |
| 25 | // Support for this functionality is optional and may return nil. |
| 26 | ParentFile() FileDescriptor |
| 27 | |
| 28 | // Parent returns the parent containing this descriptor declaration. |
| 29 | // The following shows the mapping from child type to possible parent types: |
| 30 | // |
| 31 | // ╔═════════════════════╤═══════════════════════════════════╗ |
| 32 | // ║ Child type │ Possible parent types ║ |
| 33 | // ╠═════════════════════╪═══════════════════════════════════╣ |
| 34 | // ║ FileDescriptor │ nil ║ |
| 35 | // ║ MessageDescriptor │ FileDescriptor, MessageDescriptor ║ |
| 36 | // ║ FieldDescriptor │ FileDescriptor, MessageDescriptor ║ |
| 37 | // ║ OneofDescriptor │ MessageDescriptor ║ |
| 38 | // ║ EnumDescriptor │ FileDescriptor, MessageDescriptor ║ |
| 39 | // ║ EnumValueDescriptor │ EnumDescriptor ║ |
| 40 | // ║ ServiceDescriptor │ FileDescriptor ║ |
| 41 | // ║ MethodDescriptor │ ServiceDescriptor ║ |
| 42 | // ╚═════════════════════╧═══════════════════════════════════╝ |
| 43 | // |
| 44 | // Support for this functionality is optional and may return nil. |
| 45 | Parent() Descriptor |
| 46 | |
| 47 | // Index returns the index of this descriptor within its parent. |
| 48 | // It returns 0 if the descriptor does not have a parent or if the parent |
| 49 | // is unknown. |
| 50 | Index() int |
| 51 | |
| 52 | // Syntax is the protobuf syntax. |
| 53 | Syntax() Syntax // e.g., Proto2 or Proto3 |
| 54 | |
| 55 | // Name is the short name of the declaration (i.e., FullName.Name). |
| 56 | Name() Name // e.g., "Any" |
| 57 | |
| 58 | // FullName is the fully-qualified name of the declaration. |
| 59 | // |
| 60 | // The FullName is a concatenation of the full name of the type that this |
| 61 | // type is declared within and the declaration name. For example, |
| 62 | // field "foo_field" in message "proto.package.MyMessage" is |
| 63 | // uniquely identified as "proto.package.MyMessage.foo_field". |
| 64 | // Enum values are an exception to the rule (see EnumValueDescriptor). |
| 65 | FullName() FullName // e.g., "google.protobuf.Any" |
| 66 | |
| 67 | // IsPlaceholder reports whether type information is missing since a |
| 68 | // dependency is not resolved, in which case only name information is known. |
| 69 | // |
| 70 | // Placeholder types may only be returned by the following accessors |
| 71 | // as a result of unresolved dependencies or weak imports: |
| 72 | // |
| 73 | // ╔═══════════════════════════════════╤═════════════════════╗ |
| 74 | // ║ Accessor │ Descriptor ║ |
| 75 | // ╠═══════════════════════════════════╪═════════════════════╣ |
| 76 | // ║ FileImports.FileDescriptor │ FileDescriptor ║ |
| 77 | // ║ FieldDescriptor.Enum │ EnumDescriptor ║ |
| 78 | // ║ FieldDescriptor.Message │ MessageDescriptor ║ |
| 79 | // ║ FieldDescriptor.DefaultEnumValue │ EnumValueDescriptor ║ |
| 80 | // ║ FieldDescriptor.ContainingMessage │ MessageDescriptor ║ |
| 81 | // ║ MethodDescriptor.Input │ MessageDescriptor ║ |
| 82 | // ║ MethodDescriptor.Output │ MessageDescriptor ║ |
| 83 | // ╚═══════════════════════════════════╧═════════════════════╝ |
| 84 | // |
| 85 | // If true, only Name and FullName are valid. |
| 86 | // For FileDescriptor, the Path is also valid. |
| 87 | IsPlaceholder() bool |
| 88 | |
| 89 | // Options returns the descriptor options. The caller must not modify |
| 90 | // the returned value. |
| 91 | // |
| 92 | // To avoid a dependency cycle, this function returns a proto.Message value. |
| 93 | // The proto message type returned for each descriptor type is as follows: |
| 94 | // ╔═════════════════════╤══════════════════════════════════════════╗ |
| 95 | // ║ Go type │ Protobuf message type ║ |
| 96 | // ╠═════════════════════╪══════════════════════════════════════════╣ |
| 97 | // ║ FileDescriptor │ google.protobuf.FileOptions ║ |
| 98 | // ║ EnumDescriptor │ google.protobuf.EnumOptions ║ |
| 99 | // ║ EnumValueDescriptor │ google.protobuf.EnumValueOptions ║ |
| 100 | // ║ MessageDescriptor │ google.protobuf.MessageOptions ║ |
| 101 | // ║ FieldDescriptor │ google.protobuf.FieldOptions ║ |
| 102 | // ║ OneofDescriptor │ google.protobuf.OneofOptions ║ |
| 103 | // ║ ServiceDescriptor │ google.protobuf.ServiceOptions ║ |
| 104 | // ║ MethodDescriptor │ google.protobuf.MethodOptions ║ |
| 105 | // ╚═════════════════════╧══════════════════════════════════════════╝ |
| 106 | // |
| 107 | // This method returns a typed nil-pointer if no options are present. |
| 108 | // The caller must import the descriptorpb package to use this. |
| 109 | Options() ProtoMessage |
| 110 | |
| 111 | doNotImplement |
| 112 | } |
| 113 | |
| 114 | // FileDescriptor describes the types in a complete proto file and |
| 115 | // corresponds with the google.protobuf.FileDescriptorProto message. |
| 116 | // |
| 117 | // Top-level declarations: |
| 118 | // EnumDescriptor, MessageDescriptor, FieldDescriptor, and/or ServiceDescriptor. |
| 119 | type FileDescriptor interface { |
| 120 | Descriptor // Descriptor.FullName is identical to Package |
| 121 | |
| 122 | // Path returns the file name, relative to the source tree root. |
| 123 | Path() string // e.g., "path/to/file.proto" |
| 124 | // Package returns the protobuf package namespace. |
| 125 | Package() FullName // e.g., "google.protobuf" |
| 126 | |
| 127 | // Imports is a list of imported proto files. |
| 128 | Imports() FileImports |
| 129 | |
| 130 | // Enums is a list of the top-level enum declarations. |
| 131 | Enums() EnumDescriptors |
| 132 | // Messages is a list of the top-level message declarations. |
| 133 | Messages() MessageDescriptors |
| 134 | // Extensions is a list of the top-level extension declarations. |
| 135 | Extensions() ExtensionDescriptors |
| 136 | // Services is a list of the top-level service declarations. |
| 137 | Services() ServiceDescriptors |
| 138 | |
| 139 | // SourceLocations is a list of source locations. |
| 140 | SourceLocations() SourceLocations |
| 141 | |
| 142 | isFileDescriptor |
| 143 | } |
| 144 | type isFileDescriptor interface{ ProtoType(FileDescriptor) } |
| 145 | |
| 146 | // FileImports is a list of file imports. |
| 147 | type FileImports interface { |
| 148 | // Len reports the number of files imported by this proto file. |
| 149 | Len() int |
| 150 | // Get returns the ith FileImport. It panics if out of bounds. |
| 151 | Get(i int) FileImport |
| 152 | |
| 153 | doNotImplement |
| 154 | } |
| 155 | |
| 156 | // FileImport is the declaration for a proto file import. |
| 157 | type FileImport struct { |
| 158 | // FileDescriptor is the file type for the given import. |
| 159 | // It is a placeholder descriptor if IsWeak is set or if a dependency has |
| 160 | // not been regenerated to implement the new reflection APIs. |
| 161 | FileDescriptor |
| 162 | |
| 163 | // IsPublic reports whether this is a public import, which causes this file |
| 164 | // to alias declarations within the imported file. The intended use cases |
| 165 | // for this feature is the ability to move proto files without breaking |
| 166 | // existing dependencies. |
| 167 | // |
| 168 | // The current file and the imported file must be within proto package. |
| 169 | IsPublic bool |
| 170 | |
| 171 | // IsWeak reports whether this is a weak import, which does not impose |
| 172 | // a direct dependency on the target file. |
| 173 | // |
| 174 | // Weak imports are a legacy proto1 feature. Equivalent behavior is |
| 175 | // achieved using proto2 extension fields or proto3 Any messages. |
| 176 | IsWeak bool |
| 177 | } |
| 178 | |
| 179 | // MessageDescriptor describes a message and |
| 180 | // corresponds with the google.protobuf.DescriptorProto message. |
| 181 | // |
| 182 | // Nested declarations: |
| 183 | // FieldDescriptor, OneofDescriptor, FieldDescriptor, EnumDescriptor, |
| 184 | // and/or MessageDescriptor. |
| 185 | type MessageDescriptor interface { |
| 186 | Descriptor |
| 187 | |
| 188 | // IsMapEntry indicates that this is an auto-generated message type to |
| 189 | // represent the entry type for a map field. |
| 190 | // |
| 191 | // Map entry messages have only two fields: |
| 192 | // • a "key" field with a field number of 1 |
| 193 | // • a "value" field with a field number of 2 |
| 194 | // The key and value types are determined by these two fields. |
| 195 | // |
| 196 | // If IsMapEntry is true, it implies that FieldDescriptor.IsMap is true |
| 197 | // for some field with this message type. |
| 198 | IsMapEntry() bool |
| 199 | |
| 200 | // Fields is a list of nested field declarations. |
| 201 | Fields() FieldDescriptors |
| 202 | // Oneofs is a list of nested oneof declarations. |
| 203 | Oneofs() OneofDescriptors |
| 204 | |
| 205 | // ReservedNames is a list of reserved field names. |
| 206 | ReservedNames() Names |
| 207 | // ReservedRanges is a list of reserved ranges of field numbers. |
| 208 | ReservedRanges() FieldRanges |
| 209 | // RequiredNumbers is a list of required field numbers. |
| 210 | // In Proto3, it is always an empty list. |
| 211 | RequiredNumbers() FieldNumbers |
| 212 | // ExtensionRanges is the field ranges used for extension fields. |
| 213 | // In Proto3, it is always an empty ranges. |
| 214 | ExtensionRanges() FieldRanges |
| 215 | // ExtensionRangeOptions returns the ith extension range options. |
| 216 | // |
| 217 | // To avoid a dependency cycle, this method returns a proto.Message value, |
| 218 | // which always contains a google.protobuf.ExtensionRangeOptions message. |
| 219 | // This method returns a typed nil-pointer if no options are present. |
| 220 | // The caller must import the descriptorpb package to use this. |
| 221 | ExtensionRangeOptions(i int) ProtoMessage |
| 222 | |
| 223 | // Enums is a list of nested enum declarations. |
| 224 | Enums() EnumDescriptors |
| 225 | // Messages is a list of nested message declarations. |
| 226 | Messages() MessageDescriptors |
| 227 | // Extensions is a list of nested extension declarations. |
| 228 | Extensions() ExtensionDescriptors |
| 229 | |
| 230 | isMessageDescriptor |
| 231 | } |
| 232 | type isMessageDescriptor interface{ ProtoType(MessageDescriptor) } |
| 233 | |
| 234 | // MessageType encapsulates a MessageDescriptor with a concrete Go implementation. |
| 235 | // It is recommended that implementations of this interface also implement the |
| 236 | // MessageFieldTypes interface. |
| 237 | type MessageType interface { |
| 238 | // New returns a newly allocated empty message. |
| 239 | // It may return nil for synthetic messages representing a map entry. |
| 240 | New() Message |
| 241 | |
| 242 | // Zero returns an empty, read-only message. |
| 243 | // It may return nil for synthetic messages representing a map entry. |
| 244 | Zero() Message |
| 245 | |
| 246 | // Descriptor returns the message descriptor. |
| 247 | // |
| 248 | // Invariant: t.Descriptor() == t.New().Descriptor() |
| 249 | Descriptor() MessageDescriptor |
| 250 | } |
| 251 | |
| 252 | // MessageFieldTypes extends a MessageType by providing type information |
| 253 | // regarding enums and messages referenced by the message fields. |
| 254 | type MessageFieldTypes interface { |
| 255 | MessageType |
| 256 | |
| 257 | // Enum returns the EnumType for the ith field in Descriptor.Fields. |
| 258 | // It returns nil if the ith field is not an enum kind. |
| 259 | // It panics if out of bounds. |
| 260 | // |
| 261 | // Invariant: mt.Enum(i).Descriptor() == mt.Descriptor().Fields(i).Enum() |
| 262 | Enum(i int) EnumType |
| 263 | |
| 264 | // Message returns the MessageType for the ith field in Descriptor.Fields. |
| 265 | // It returns nil if the ith field is not a message or group kind. |
| 266 | // It panics if out of bounds. |
| 267 | // |
| 268 | // Invariant: mt.Message(i).Descriptor() == mt.Descriptor().Fields(i).Message() |
| 269 | Message(i int) MessageType |
| 270 | } |
| 271 | |
| 272 | // MessageDescriptors is a list of message declarations. |
| 273 | type MessageDescriptors interface { |
| 274 | // Len reports the number of messages. |
| 275 | Len() int |
| 276 | // Get returns the ith MessageDescriptor. It panics if out of bounds. |
| 277 | Get(i int) MessageDescriptor |
| 278 | // ByName returns the MessageDescriptor for a message named s. |
| 279 | // It returns nil if not found. |
| 280 | ByName(s Name) MessageDescriptor |
| 281 | |
| 282 | doNotImplement |
| 283 | } |
| 284 | |
| 285 | // FieldDescriptor describes a field within a message and |
| 286 | // corresponds with the google.protobuf.FieldDescriptorProto message. |
| 287 | // |
| 288 | // It is used for both normal fields defined within the parent message |
| 289 | // (e.g., MessageDescriptor.Fields) and fields that extend some remote message |
| 290 | // (e.g., FileDescriptor.Extensions or MessageDescriptor.Extensions). |
| 291 | type FieldDescriptor interface { |
| 292 | Descriptor |
| 293 | |
| 294 | // Number reports the unique number for this field. |
| 295 | Number() FieldNumber |
| 296 | // Cardinality reports the cardinality for this field. |
| 297 | Cardinality() Cardinality |
| 298 | // Kind reports the basic kind for this field. |
| 299 | Kind() Kind |
| 300 | |
| 301 | // HasJSONName reports whether this field has an explicitly set JSON name. |
| 302 | HasJSONName() bool |
| 303 | |
| 304 | // JSONName reports the name used for JSON serialization. |
| 305 | // It is usually the camel-cased form of the field name. |
| 306 | // Extension fields are represented by the full name surrounded by brackets. |
| 307 | JSONName() string |
| 308 | |
| 309 | // TextName reports the name used for text serialization. |
| 310 | // It is usually the name of the field, except that groups use the name |
| 311 | // of the inlined message, and extension fields are represented by the |
| 312 | // full name surrounded by brackets. |
| 313 | TextName() string |
| 314 | |
| 315 | // HasPresence reports whether the field distinguishes between unpopulated |
| 316 | // and default values. |
| 317 | HasPresence() bool |
| 318 | |
| 319 | // IsExtension reports whether this is an extension field. If false, |
| 320 | // then Parent and ContainingMessage refer to the same message. |
| 321 | // Otherwise, ContainingMessage and Parent likely differ. |
| 322 | IsExtension() bool |
| 323 | |
| 324 | // HasOptionalKeyword reports whether the "optional" keyword was explicitly |
| 325 | // specified in the source .proto file. |
| 326 | HasOptionalKeyword() bool |
| 327 | |
| 328 | // IsWeak reports whether this is a weak field, which does not impose a |
| 329 | // direct dependency on the target type. |
| 330 | // If true, then Message returns a placeholder type. |
| 331 | IsWeak() bool |
| 332 | |
| 333 | // IsPacked reports whether repeated primitive numeric kinds should be |
| 334 | // serialized using a packed encoding. |
| 335 | // If true, then it implies Cardinality is Repeated. |
| 336 | IsPacked() bool |
| 337 | |
| 338 | // IsList reports whether this field represents a list, |
| 339 | // where the value type for the associated field is a List. |
| 340 | // It is equivalent to checking whether Cardinality is Repeated and |
| 341 | // that IsMap reports false. |
| 342 | IsList() bool |
| 343 | |
| 344 | // IsMap reports whether this field represents a map, |
| 345 | // where the value type for the associated field is a Map. |
| 346 | // It is equivalent to checking whether Cardinality is Repeated, |
| 347 | // that the Kind is MessageKind, and that Message.IsMapEntry reports true. |
| 348 | IsMap() bool |
| 349 | |
| 350 | // MapKey returns the field descriptor for the key in the map entry. |
| 351 | // It returns nil if IsMap reports false. |
| 352 | MapKey() FieldDescriptor |
| 353 | |
| 354 | // MapValue returns the field descriptor for the value in the map entry. |
| 355 | // It returns nil if IsMap reports false. |
| 356 | MapValue() FieldDescriptor |
| 357 | |
| 358 | // HasDefault reports whether this field has a default value. |
| 359 | HasDefault() bool |
| 360 | |
| 361 | // Default returns the default value for scalar fields. |
| 362 | // For proto2, it is the default value as specified in the proto file, |
| 363 | // or the zero value if unspecified. |
| 364 | // For proto3, it is always the zero value of the scalar. |
| 365 | // The Value type is determined by the Kind. |
| 366 | Default() Value |
| 367 | |
| 368 | // DefaultEnumValue returns the enum value descriptor for the default value |
| 369 | // of an enum field, and is nil for any other kind of field. |
| 370 | DefaultEnumValue() EnumValueDescriptor |
| 371 | |
| 372 | // ContainingOneof is the containing oneof that this field belongs to, |
| 373 | // and is nil if this field is not part of a oneof. |
| 374 | ContainingOneof() OneofDescriptor |
| 375 | |
| 376 | // ContainingMessage is the containing message that this field belongs to. |
| 377 | // For extension fields, this may not necessarily be the parent message |
| 378 | // that the field is declared within. |
| 379 | ContainingMessage() MessageDescriptor |
| 380 | |
| 381 | // Enum is the enum descriptor if Kind is EnumKind. |
| 382 | // It returns nil for any other Kind. |
| 383 | Enum() EnumDescriptor |
| 384 | |
| 385 | // Message is the message descriptor if Kind is |
| 386 | // MessageKind or GroupKind. It returns nil for any other Kind. |
| 387 | Message() MessageDescriptor |
| 388 | |
| 389 | isFieldDescriptor |
| 390 | } |
| 391 | type isFieldDescriptor interface{ ProtoType(FieldDescriptor) } |
| 392 | |
| 393 | // FieldDescriptors is a list of field declarations. |
| 394 | type FieldDescriptors interface { |
| 395 | // Len reports the number of fields. |
| 396 | Len() int |
| 397 | // Get returns the ith FieldDescriptor. It panics if out of bounds. |
| 398 | Get(i int) FieldDescriptor |
| 399 | // ByName returns the FieldDescriptor for a field named s. |
| 400 | // It returns nil if not found. |
| 401 | ByName(s Name) FieldDescriptor |
| 402 | // ByJSONName returns the FieldDescriptor for a field with s as the JSON name. |
| 403 | // It returns nil if not found. |
| 404 | ByJSONName(s string) FieldDescriptor |
| 405 | // ByTextName returns the FieldDescriptor for a field with s as the text name. |
| 406 | // It returns nil if not found. |
| 407 | ByTextName(s string) FieldDescriptor |
| 408 | // ByNumber returns the FieldDescriptor for a field numbered n. |
| 409 | // It returns nil if not found. |
| 410 | ByNumber(n FieldNumber) FieldDescriptor |
| 411 | |
| 412 | doNotImplement |
| 413 | } |
| 414 | |
| 415 | // OneofDescriptor describes a oneof field set within a given message and |
| 416 | // corresponds with the google.protobuf.OneofDescriptorProto message. |
| 417 | type OneofDescriptor interface { |
| 418 | Descriptor |
| 419 | |
| 420 | // IsSynthetic reports whether this is a synthetic oneof created to support |
| 421 | // proto3 optional semantics. If true, Fields contains exactly one field |
| 422 | // with HasOptionalKeyword specified. |
| 423 | IsSynthetic() bool |
| 424 | |
| 425 | // Fields is a list of fields belonging to this oneof. |
| 426 | Fields() FieldDescriptors |
| 427 | |
| 428 | isOneofDescriptor |
| 429 | } |
| 430 | type isOneofDescriptor interface{ ProtoType(OneofDescriptor) } |
| 431 | |
| 432 | // OneofDescriptors is a list of oneof declarations. |
| 433 | type OneofDescriptors interface { |
| 434 | // Len reports the number of oneof fields. |
| 435 | Len() int |
| 436 | // Get returns the ith OneofDescriptor. It panics if out of bounds. |
| 437 | Get(i int) OneofDescriptor |
| 438 | // ByName returns the OneofDescriptor for a oneof named s. |
| 439 | // It returns nil if not found. |
| 440 | ByName(s Name) OneofDescriptor |
| 441 | |
| 442 | doNotImplement |
| 443 | } |
| 444 | |
| 445 | // ExtensionDescriptor is an alias of FieldDescriptor for documentation. |
| 446 | type ExtensionDescriptor = FieldDescriptor |
| 447 | |
| 448 | // ExtensionTypeDescriptor is an ExtensionDescriptor with an associated ExtensionType. |
| 449 | type ExtensionTypeDescriptor interface { |
| 450 | ExtensionDescriptor |
| 451 | |
| 452 | // Type returns the associated ExtensionType. |
| 453 | Type() ExtensionType |
| 454 | |
| 455 | // Descriptor returns the plain ExtensionDescriptor without the |
| 456 | // associated ExtensionType. |
| 457 | Descriptor() ExtensionDescriptor |
| 458 | } |
| 459 | |
| 460 | // ExtensionDescriptors is a list of field declarations. |
| 461 | type ExtensionDescriptors interface { |
| 462 | // Len reports the number of fields. |
| 463 | Len() int |
| 464 | // Get returns the ith ExtensionDescriptor. It panics if out of bounds. |
| 465 | Get(i int) ExtensionDescriptor |
| 466 | // ByName returns the ExtensionDescriptor for a field named s. |
| 467 | // It returns nil if not found. |
| 468 | ByName(s Name) ExtensionDescriptor |
| 469 | |
| 470 | doNotImplement |
| 471 | } |
| 472 | |
| 473 | // ExtensionType encapsulates an ExtensionDescriptor with a concrete |
| 474 | // Go implementation. The nested field descriptor must be for a extension field. |
| 475 | // |
| 476 | // While a normal field is a member of the parent message that it is declared |
| 477 | // within (see Descriptor.Parent), an extension field is a member of some other |
| 478 | // target message (see ExtensionDescriptor.Extendee) and may have no |
| 479 | // relationship with the parent. However, the full name of an extension field is |
| 480 | // relative to the parent that it is declared within. |
| 481 | // |
| 482 | // For example: |
| 483 | // syntax = "proto2"; |
| 484 | // package example; |
| 485 | // message FooMessage { |
| 486 | // extensions 100 to max; |
| 487 | // } |
| 488 | // message BarMessage { |
| 489 | // extends FooMessage { optional BarMessage bar_field = 100; } |
| 490 | // } |
| 491 | // |
| 492 | // Field "bar_field" is an extension of FooMessage, but its full name is |
| 493 | // "example.BarMessage.bar_field" instead of "example.FooMessage.bar_field". |
| 494 | type ExtensionType interface { |
| 495 | // New returns a new value for the field. |
| 496 | // For scalars, this returns the default value in native Go form. |
| 497 | New() Value |
| 498 | |
| 499 | // Zero returns a new value for the field. |
| 500 | // For scalars, this returns the default value in native Go form. |
| 501 | // For composite types, this returns an empty, read-only message, list, or map. |
| 502 | Zero() Value |
| 503 | |
| 504 | // TypeDescriptor returns the extension type descriptor. |
| 505 | TypeDescriptor() ExtensionTypeDescriptor |
| 506 | |
| 507 | // ValueOf wraps the input and returns it as a Value. |
| 508 | // ValueOf panics if the input value is invalid or not the appropriate type. |
| 509 | // |
| 510 | // ValueOf is more extensive than protoreflect.ValueOf for a given field's |
| 511 | // value as it has more type information available. |
| 512 | ValueOf(interface{}) Value |
| 513 | |
| 514 | // InterfaceOf completely unwraps the Value to the underlying Go type. |
| 515 | // InterfaceOf panics if the input is nil or does not represent the |
| 516 | // appropriate underlying Go type. For composite types, it panics if the |
| 517 | // value is not mutable. |
| 518 | // |
| 519 | // InterfaceOf is able to unwrap the Value further than Value.Interface |
| 520 | // as it has more type information available. |
| 521 | InterfaceOf(Value) interface{} |
| 522 | |
| 523 | // IsValidValue reports whether the Value is valid to assign to the field. |
| 524 | IsValidValue(Value) bool |
| 525 | |
| 526 | // IsValidInterface reports whether the input is valid to assign to the field. |
| 527 | IsValidInterface(interface{}) bool |
| 528 | } |
| 529 | |
| 530 | // EnumDescriptor describes an enum and |
| 531 | // corresponds with the google.protobuf.EnumDescriptorProto message. |
| 532 | // |
| 533 | // Nested declarations: |
| 534 | // EnumValueDescriptor. |
| 535 | type EnumDescriptor interface { |
| 536 | Descriptor |
| 537 | |
| 538 | // Values is a list of nested enum value declarations. |
| 539 | Values() EnumValueDescriptors |
| 540 | |
| 541 | // ReservedNames is a list of reserved enum names. |
| 542 | ReservedNames() Names |
| 543 | // ReservedRanges is a list of reserved ranges of enum numbers. |
| 544 | ReservedRanges() EnumRanges |
| 545 | |
| 546 | isEnumDescriptor |
| 547 | } |
| 548 | type isEnumDescriptor interface{ ProtoType(EnumDescriptor) } |
| 549 | |
| 550 | // EnumType encapsulates an EnumDescriptor with a concrete Go implementation. |
| 551 | type EnumType interface { |
| 552 | // New returns an instance of this enum type with its value set to n. |
| 553 | New(n EnumNumber) Enum |
| 554 | |
| 555 | // Descriptor returns the enum descriptor. |
| 556 | // |
| 557 | // Invariant: t.Descriptor() == t.New(0).Descriptor() |
| 558 | Descriptor() EnumDescriptor |
| 559 | } |
| 560 | |
| 561 | // EnumDescriptors is a list of enum declarations. |
| 562 | type EnumDescriptors interface { |
| 563 | // Len reports the number of enum types. |
| 564 | Len() int |
| 565 | // Get returns the ith EnumDescriptor. It panics if out of bounds. |
| 566 | Get(i int) EnumDescriptor |
| 567 | // ByName returns the EnumDescriptor for an enum named s. |
| 568 | // It returns nil if not found. |
| 569 | ByName(s Name) EnumDescriptor |
| 570 | |
| 571 | doNotImplement |
| 572 | } |
| 573 | |
| 574 | // EnumValueDescriptor describes an enum value and |
| 575 | // corresponds with the google.protobuf.EnumValueDescriptorProto message. |
| 576 | // |
| 577 | // All other proto declarations are in the namespace of the parent. |
| 578 | // However, enum values do not follow this rule and are within the namespace |
| 579 | // of the parent's parent (i.e., they are a sibling of the containing enum). |
| 580 | // Thus, a value named "FOO_VALUE" declared within an enum uniquely identified |
| 581 | // as "proto.package.MyEnum" has a full name of "proto.package.FOO_VALUE". |
| 582 | type EnumValueDescriptor interface { |
| 583 | Descriptor |
| 584 | |
| 585 | // Number returns the enum value as an integer. |
| 586 | Number() EnumNumber |
| 587 | |
| 588 | isEnumValueDescriptor |
| 589 | } |
| 590 | type isEnumValueDescriptor interface{ ProtoType(EnumValueDescriptor) } |
| 591 | |
| 592 | // EnumValueDescriptors is a list of enum value declarations. |
| 593 | type EnumValueDescriptors interface { |
| 594 | // Len reports the number of enum values. |
| 595 | Len() int |
| 596 | // Get returns the ith EnumValueDescriptor. It panics if out of bounds. |
| 597 | Get(i int) EnumValueDescriptor |
| 598 | // ByName returns the EnumValueDescriptor for the enum value named s. |
| 599 | // It returns nil if not found. |
| 600 | ByName(s Name) EnumValueDescriptor |
| 601 | // ByNumber returns the EnumValueDescriptor for the enum value numbered n. |
| 602 | // If multiple have the same number, the first one defined is returned |
| 603 | // It returns nil if not found. |
| 604 | ByNumber(n EnumNumber) EnumValueDescriptor |
| 605 | |
| 606 | doNotImplement |
| 607 | } |
| 608 | |
| 609 | // ServiceDescriptor describes a service and |
| 610 | // corresponds with the google.protobuf.ServiceDescriptorProto message. |
| 611 | // |
| 612 | // Nested declarations: MethodDescriptor. |
| 613 | type ServiceDescriptor interface { |
| 614 | Descriptor |
| 615 | |
| 616 | // Methods is a list of nested message declarations. |
| 617 | Methods() MethodDescriptors |
| 618 | |
| 619 | isServiceDescriptor |
| 620 | } |
| 621 | type isServiceDescriptor interface{ ProtoType(ServiceDescriptor) } |
| 622 | |
| 623 | // ServiceDescriptors is a list of service declarations. |
| 624 | type ServiceDescriptors interface { |
| 625 | // Len reports the number of services. |
| 626 | Len() int |
| 627 | // Get returns the ith ServiceDescriptor. It panics if out of bounds. |
| 628 | Get(i int) ServiceDescriptor |
| 629 | // ByName returns the ServiceDescriptor for a service named s. |
| 630 | // It returns nil if not found. |
| 631 | ByName(s Name) ServiceDescriptor |
| 632 | |
| 633 | doNotImplement |
| 634 | } |
| 635 | |
| 636 | // MethodDescriptor describes a method and |
| 637 | // corresponds with the google.protobuf.MethodDescriptorProto message. |
| 638 | type MethodDescriptor interface { |
| 639 | Descriptor |
| 640 | |
| 641 | // Input is the input message descriptor. |
| 642 | Input() MessageDescriptor |
| 643 | // Output is the output message descriptor. |
| 644 | Output() MessageDescriptor |
| 645 | // IsStreamingClient reports whether the client streams multiple messages. |
| 646 | IsStreamingClient() bool |
| 647 | // IsStreamingServer reports whether the server streams multiple messages. |
| 648 | IsStreamingServer() bool |
| 649 | |
| 650 | isMethodDescriptor |
| 651 | } |
| 652 | type isMethodDescriptor interface{ ProtoType(MethodDescriptor) } |
| 653 | |
| 654 | // MethodDescriptors is a list of method declarations. |
| 655 | type MethodDescriptors interface { |
| 656 | // Len reports the number of methods. |
| 657 | Len() int |
| 658 | // Get returns the ith MethodDescriptor. It panics if out of bounds. |
| 659 | Get(i int) MethodDescriptor |
| 660 | // ByName returns the MethodDescriptor for a service method named s. |
| 661 | // It returns nil if not found. |
| 662 | ByName(s Name) MethodDescriptor |
| 663 | |
| 664 | doNotImplement |
| 665 | } |