(
&mut self,
package: &str,
descriptor: ServiceDescriptorProto,
source_id: usize,
descriptor_path: &[i32],
comments: &SourceCodeComments,
)
| 569 | } |
| 570 | |
| 571 | fn register_service( |
| 572 | &mut self, |
| 573 | package: &str, |
| 574 | descriptor: ServiceDescriptorProto, |
| 575 | source_id: usize, |
| 576 | descriptor_path: &[i32], |
| 577 | comments: &SourceCodeComments, |
| 578 | ) { |
| 579 | let simple_name = descriptor.name.clone().unwrap_or_default(); |
| 580 | let full_name = qualified_service_name(package, &simple_name); |
| 581 | let methods = descriptor |
| 582 | .method |
| 583 | .into_iter() |
| 584 | .enumerate() |
| 585 | .map(|(idx, method)| { |
| 586 | let description = comments |
| 587 | .comment_for(&extend_path(descriptor_path, 2, idx as i32)) |
| 588 | .map(|s| s.to_string()); |
| 589 | MethodInfo { |
| 590 | name: method.name.unwrap_or_default(), |
| 591 | input_type: normalize_type_name(&method.input_type.unwrap_or_default()), |
| 592 | output_type: normalize_type_name(&method.output_type.unwrap_or_default()), |
| 593 | client_streaming: method.client_streaming.unwrap_or(false), |
| 594 | server_streaming: method.server_streaming.unwrap_or(false), |
| 595 | description, |
| 596 | } |
| 597 | }) |
| 598 | .collect(); |
| 599 | let description = comments.comment_for(descriptor_path).map(|s| s.to_string()); |
| 600 | let service = ServiceInfo { |
| 601 | full_name: full_name.clone(), |
| 602 | source_id, |
| 603 | description, |
| 604 | methods, |
| 605 | }; |
| 606 | let idx = self.services.len(); |
| 607 | self.services.push(service); |
| 608 | self.service_by_full_name.insert(full_name, idx); |
| 609 | self.service_by_simple_name |
| 610 | .entry(simple_name) |
| 611 | .or_default() |
| 612 | .push(idx); |
| 613 | } |
| 614 | |
| 615 | fn resolve_service(&self, source_id: usize, query: &str) -> Result<&ServiceInfo> { |
| 616 | let normalized = query.trim_start_matches('.').to_string(); |
no test coverage detected