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 an [MessageDescriptor]. 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 MessageDescriptor.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 MessageDescriptor.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 MessageDescriptor.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 FieldDescriptor.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 [FieldDescriptor.ContainingMessage]) 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 // 484 // syntax = "proto2"; 485 // package example; 486 // message FooMessage { 487 // extensions 100 to max; 488 // } 489 // message BarMessage { 490 // extends FooMessage { optional BarMessage bar_field = 100; } 491 // } 492 // 493 // Field "bar_field" is an extension of FooMessage, but its full name is 494 // "example.BarMessage.bar_field" instead of "example.FooMessage.bar_field". 495 type ExtensionType interface { 496 // New returns a new value for the field. 497 // For scalars, this returns the default value in native Go form. 498 New() Value 499 500 // Zero returns a new value for the field. 501 // For scalars, this returns the default value in native Go form. 502 // For composite types, this returns an empty, read-only message, list, or map. 503 Zero() Value 504 505 // TypeDescriptor returns the extension type descriptor. 506 TypeDescriptor() ExtensionTypeDescriptor 507 508 // ValueOf wraps the input and returns it as a Value. 509 // ValueOf panics if the input value is invalid or not the appropriate type. 510 // 511 // ValueOf is more extensive than protoreflect.ValueOf for a given field's 512 // value as it has more type information available. 513 ValueOf(interface{}) Value 514 515 // InterfaceOf completely unwraps the Value to the underlying Go type. 516 // InterfaceOf panics if the input is nil or does not represent the 517 // appropriate underlying Go type. For composite types, it panics if the 518 // value is not mutable. 519 // 520 // InterfaceOf is able to unwrap the Value further than Value.Interface 521 // as it has more type information available. 522 InterfaceOf(Value) interface{} 523 524 // IsValidValue reports whether the Value is valid to assign to the field. 525 IsValidValue(Value) bool 526 527 // IsValidInterface reports whether the input is valid to assign to the field. 528 IsValidInterface(interface{}) bool 529 } 530 531 // EnumDescriptor describes an enum and 532 // corresponds with the google.protobuf.EnumDescriptorProto message. 533 // 534 // Nested declarations: 535 // [EnumValueDescriptor]. 536 type EnumDescriptor interface { 537 Descriptor 538 539 // Values is a list of nested enum value declarations. 540 Values() EnumValueDescriptors 541 542 // ReservedNames is a list of reserved enum names. 543 ReservedNames() Names 544 // ReservedRanges is a list of reserved ranges of enum numbers. 545 ReservedRanges() EnumRanges 546 547 isEnumDescriptor 548 } 549 type isEnumDescriptor interface{ ProtoType(EnumDescriptor) } 550 551 // EnumType encapsulates an [EnumDescriptor] with a concrete Go implementation. 552 type EnumType interface { 553 // New returns an instance of this enum type with its value set to n. 554 New(n EnumNumber) Enum 555 556 // Descriptor returns the enum descriptor. 557 // 558 // Invariant: t.Descriptor() == t.New(0).Descriptor() 559 Descriptor() EnumDescriptor 560 } 561 562 // EnumDescriptors is a list of enum declarations. 563 type EnumDescriptors interface { 564 // Len reports the number of enum types. 565 Len() int 566 // Get returns the ith EnumDescriptor. It panics if out of bounds. 567 Get(i int) EnumDescriptor 568 // ByName returns the EnumDescriptor for an enum named s. 569 // It returns nil if not found. 570 ByName(s Name) EnumDescriptor 571 572 doNotImplement 573 } 574 575 // EnumValueDescriptor describes an enum value and 576 // corresponds with the google.protobuf.EnumValueDescriptorProto message. 577 // 578 // All other proto declarations are in the namespace of the parent. 579 // However, enum values do not follow this rule and are within the namespace 580 // of the parent's parent (i.e., they are a sibling of the containing enum). 581 // Thus, a value named "FOO_VALUE" declared within an enum uniquely identified 582 // as "proto.package.MyEnum" has a full name of "proto.package.FOO_VALUE". 583 type EnumValueDescriptor interface { 584 Descriptor 585 586 // Number returns the enum value as an integer. 587 Number() EnumNumber 588 589 isEnumValueDescriptor 590 } 591 type isEnumValueDescriptor interface{ ProtoType(EnumValueDescriptor) } 592 593 // EnumValueDescriptors is a list of enum value declarations. 594 type EnumValueDescriptors interface { 595 // Len reports the number of enum values. 596 Len() int 597 // Get returns the ith EnumValueDescriptor. It panics if out of bounds. 598 Get(i int) EnumValueDescriptor 599 // ByName returns the EnumValueDescriptor for the enum value named s. 600 // It returns nil if not found. 601 ByName(s Name) EnumValueDescriptor 602 // ByNumber returns the EnumValueDescriptor for the enum value numbered n. 603 // If multiple have the same number, the first one defined is returned 604 // It returns nil if not found. 605 ByNumber(n EnumNumber) EnumValueDescriptor 606 607 doNotImplement 608 } 609 610 // ServiceDescriptor describes a service and 611 // corresponds with the google.protobuf.ServiceDescriptorProto message. 612 // 613 // Nested declarations: [MethodDescriptor]. 614 type ServiceDescriptor interface { 615 Descriptor 616 617 // Methods is a list of nested message declarations. 618 Methods() MethodDescriptors 619 620 isServiceDescriptor 621 } 622 type isServiceDescriptor interface{ ProtoType(ServiceDescriptor) } 623 624 // ServiceDescriptors is a list of service declarations. 625 type ServiceDescriptors interface { 626 // Len reports the number of services. 627 Len() int 628 // Get returns the ith ServiceDescriptor. It panics if out of bounds. 629 Get(i int) ServiceDescriptor 630 // ByName returns the ServiceDescriptor for a service named s. 631 // It returns nil if not found. 632 ByName(s Name) ServiceDescriptor 633 634 doNotImplement 635 } 636 637 // MethodDescriptor describes a method and 638 // corresponds with the google.protobuf.MethodDescriptorProto message. 639 type MethodDescriptor interface { 640 Descriptor 641 642 // Input is the input message descriptor. 643 Input() MessageDescriptor 644 // Output is the output message descriptor. 645 Output() MessageDescriptor 646 // IsStreamingClient reports whether the client streams multiple messages. 647 IsStreamingClient() bool 648 // IsStreamingServer reports whether the server streams multiple messages. 649 IsStreamingServer() bool 650 651 isMethodDescriptor 652 } 653 type isMethodDescriptor interface{ ProtoType(MethodDescriptor) } 654 655 // MethodDescriptors is a list of method declarations. 656 type MethodDescriptors interface { 657 // Len reports the number of methods. 658 Len() int 659 // Get returns the ith MethodDescriptor. It panics if out of bounds. 660 Get(i int) MethodDescriptor 661 // ByName returns the MethodDescriptor for a service method named s. 662 // It returns nil if not found. 663 ByName(s Name) MethodDescriptor 664 665 doNotImplement 666 } 667