diff --git a/src/descriptor.rs b/src/descriptor.rs index 01110b2..86ff8c0 100644 --- a/src/descriptor.rs +++ b/src/descriptor.rs @@ -342,12 +342,26 @@ impl Descriptors { self.messages_by_name.get(name).map(|m| &self.messages[m.0]) } + /// Iterates over the messages in the descriptor set. + /// + /// The order of iteration is unspecified. + pub fn iter_messages(&self) -> impl Iterator { + self.messages.iter() + } + /// Looks up an enum by its fully qualified name (i.e. `.foo.package.Enum`). #[inline] pub fn enum_by_name(&self, name: &str) -> Option<&EnumDescriptor> { self.enums_by_name.get(name).map(|e| &self.enums[e.0]) } + /// Iterates over the enums in the descriptor set. + /// + /// The order of iteration is unspecified. + pub fn iter_enums(&self) -> impl Iterator { + self.enums.iter() + } + /// Adds all types defined in the specified protocol buffer file descriptor set to this /// registry. pub fn add_file_set_proto(&mut self, file_set_proto: &descriptor::FileDescriptorSet) {