xref: /tonic/tonic-reflection/src/lib.rs (revision 8ee85fc4)
1 //! A `tonic` based gRPC Server Reflection implementation.
2 
3 #![doc(
4     html_logo_url = "https://github.com/hyperium/tonic/raw/master/.github/assets/tonic-docs.png"
5 )]
6 #![doc(issue_tracker_base_url = "https://github.com/hyperium/tonic/issues/")]
7 #![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
8 #![cfg_attr(docsrs, feature(doc_auto_cfg))]
9 
10 mod generated {
11     #![allow(unreachable_pub)]
12     #![allow(missing_docs)]
13     #![allow(rustdoc::invalid_html_tags)]
14 
15     #[rustfmt::skip]
16     pub mod grpc_reflection_v1alpha;
17 
18     #[rustfmt::skip]
19     pub mod grpc_reflection_v1;
20 
21     #[rustfmt::skip]
22     pub mod reflection_v1_fds;
23 
24     #[rustfmt::skip]
25     pub mod reflection_v1alpha1_fds;
26 
27     pub use reflection_v1_fds::FILE_DESCRIPTOR_SET as FILE_DESCRIPTOR_SET_V1;
28     pub use reflection_v1alpha1_fds::FILE_DESCRIPTOR_SET as FILE_DESCRIPTOR_SET_V1ALPHA;
29 
30     #[cfg(test)]
31     mod tests {
32         use super::{FILE_DESCRIPTOR_SET_V1, FILE_DESCRIPTOR_SET_V1ALPHA};
33         use prost::Message as _;
34 
35         #[test]
v1alpha_file_descriptor_set_is_valid()36         fn v1alpha_file_descriptor_set_is_valid() {
37             prost_types::FileDescriptorSet::decode(FILE_DESCRIPTOR_SET_V1ALPHA).unwrap();
38         }
39 
40         #[test]
v1_file_descriptor_set_is_valid()41         fn v1_file_descriptor_set_is_valid() {
42             prost_types::FileDescriptorSet::decode(FILE_DESCRIPTOR_SET_V1).unwrap();
43         }
44     }
45 }
46 
47 /// Generated protobuf types from the `grpc.reflection` namespace.
48 pub mod pb {
49     /// Generated protobuf types from the `grpc.reflection.v1` package.
50     pub mod v1 {
51         pub use crate::generated::{
52             grpc_reflection_v1::*, FILE_DESCRIPTOR_SET_V1 as FILE_DESCRIPTOR_SET,
53         };
54     }
55 
56     /// Generated protobuf types from the `grpc.reflection.v1alpha` package.
57     pub mod v1alpha {
58         pub use crate::generated::{
59             grpc_reflection_v1alpha::*, FILE_DESCRIPTOR_SET_V1ALPHA as FILE_DESCRIPTOR_SET,
60         };
61     }
62 }
63 
64 /// Implementation of the server component of gRPC Server Reflection.
65 #[cfg(feature = "server")]
66 pub mod server;
67