Skip to main content

tonic_reflection/
lib.rs

1/*
2 *
3 * Copyright 2025 gRPC authors.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 */
24
25//! A `tonic` based gRPC Server Reflection implementation.
26
27#![doc(
28    html_logo_url = "https://github.com/grpc/grpc-rust/raw/master/.github/assets/tonic-docs.png"
29)]
30#![doc(issue_tracker_base_url = "https://github.com/grpc/grpc-rust/issues/")]
31#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
32#![cfg_attr(docsrs, feature(doc_cfg))]
33
34mod generated {
35    #![allow(unreachable_pub)]
36    #![allow(missing_docs)]
37    #![allow(rustdoc::invalid_html_tags)]
38
39    #[rustfmt::skip]
40    pub mod grpc_reflection_v1alpha;
41
42    #[rustfmt::skip]
43    pub mod grpc_reflection_v1;
44
45    #[rustfmt::skip]
46    pub mod reflection_v1_fds;
47
48    #[rustfmt::skip]
49    pub mod reflection_v1alpha1_fds;
50
51    pub use reflection_v1_fds::FILE_DESCRIPTOR_SET as FILE_DESCRIPTOR_SET_V1;
52    pub use reflection_v1alpha1_fds::FILE_DESCRIPTOR_SET as FILE_DESCRIPTOR_SET_V1ALPHA;
53
54    #[cfg(test)]
55    mod tests {
56        use super::{FILE_DESCRIPTOR_SET_V1, FILE_DESCRIPTOR_SET_V1ALPHA};
57        use prost::Message as _;
58
59        #[test]
60        fn v1alpha_file_descriptor_set_is_valid() {
61            prost_types::FileDescriptorSet::decode(FILE_DESCRIPTOR_SET_V1ALPHA).unwrap();
62        }
63
64        #[test]
65        fn v1_file_descriptor_set_is_valid() {
66            prost_types::FileDescriptorSet::decode(FILE_DESCRIPTOR_SET_V1).unwrap();
67        }
68    }
69}
70
71/// Generated protobuf types from the `grpc.reflection` namespace.
72pub mod pb {
73    /// Generated protobuf types from the `grpc.reflection.v1` package.
74    pub mod v1 {
75        pub use crate::generated::{
76            FILE_DESCRIPTOR_SET_V1 as FILE_DESCRIPTOR_SET, grpc_reflection_v1::*,
77        };
78    }
79
80    /// Generated protobuf types from the `grpc.reflection.v1alpha` package.
81    pub mod v1alpha {
82        pub use crate::generated::{
83            FILE_DESCRIPTOR_SET_V1ALPHA as FILE_DESCRIPTOR_SET, grpc_reflection_v1alpha::*,
84        };
85    }
86}
87
88/// Implementation of the server component of gRPC Server Reflection.
89#[cfg(feature = "server")]
90pub mod server;