1 use crate::descriptor::MethodDescriptorProto; 2 use crate::descriptor::ServiceDescriptorProto; 3 use crate::reflect::field::index::ForwardProtobufTypeBox; 4 use crate::reflect::file::building::FileDescriptorBuilding; 5 6 #[derive(Debug)] 7 pub(crate) struct ServiceIndex { 8 pub(crate) methods: Vec<MethodIndex>, 9 } 10 11 impl ServiceIndex { index( proto: &ServiceDescriptorProto, building: &FileDescriptorBuilding, ) -> crate::Result<ServiceIndex>12 pub(crate) fn index( 13 proto: &ServiceDescriptorProto, 14 building: &FileDescriptorBuilding, 15 ) -> crate::Result<ServiceIndex> { 16 let methods = proto 17 .method 18 .iter() 19 .map(|method| MethodIndex::index(method, building)) 20 .collect::<crate::Result<Vec<_>>>()?; 21 Ok(ServiceIndex { methods }) 22 } 23 } 24 25 #[derive(Debug)] 26 pub(crate) struct MethodIndex { 27 pub(crate) input_type: ForwardProtobufTypeBox, 28 pub(crate) output_type: ForwardProtobufTypeBox, 29 } 30 31 impl MethodIndex { index( proto: &MethodDescriptorProto, building: &FileDescriptorBuilding, ) -> crate::Result<MethodIndex>32 pub(crate) fn index( 33 proto: &MethodDescriptorProto, 34 building: &FileDescriptorBuilding, 35 ) -> crate::Result<MethodIndex> { 36 let input_type = building.resolve_message(proto.input_type())?; 37 let output_type = building.resolve_message(proto.output_type())?; 38 Ok(MethodIndex { 39 input_type, 40 output_type, 41 }) 42 } 43 } 44