1 /// The message sent by the client when calling ServerReflectionInfo method.
2 #[allow(clippy::derive_partial_eq_without_eq)]
3 #[derive(Clone, PartialEq, ::prost::Message)]
4 pub struct ServerReflectionRequest {
5     #[prost(string, tag = "1")]
6     pub host: ::prost::alloc::string::String,
7     /// To use reflection service, the client should set one of the following
8     /// fields in message_request. The server distinguishes requests by their
9     /// defined field and then handles them using corresponding methods.
10     #[prost(oneof = "server_reflection_request::MessageRequest", tags = "3, 4, 5, 6, 7")]
11     pub message_request: ::core::option::Option<
12         server_reflection_request::MessageRequest,
13     >,
14 }
15 /// Nested message and enum types in `ServerReflectionRequest`.
16 pub mod server_reflection_request {
17     /// To use reflection service, the client should set one of the following
18     /// fields in message_request. The server distinguishes requests by their
19     /// defined field and then handles them using corresponding methods.
20     #[allow(clippy::derive_partial_eq_without_eq)]
21     #[derive(Clone, PartialEq, ::prost::Oneof)]
22     pub enum MessageRequest {
23         /// Find a proto file by the file name.
24         #[prost(string, tag = "3")]
25         FileByFilename(::prost::alloc::string::String),
26         /// Find the proto file that declares the given fully-qualified symbol name.
27         /// This field should be a fully-qualified symbol name
28         /// (e.g. <package>.<service>\[.<method>\] or <package>.<type>).
29         #[prost(string, tag = "4")]
30         FileContainingSymbol(::prost::alloc::string::String),
31         /// Find the proto file which defines an extension extending the given
32         /// message type with the given field number.
33         #[prost(message, tag = "5")]
34         FileContainingExtension(super::ExtensionRequest),
35         /// Finds the tag numbers used by all known extensions of extendee_type, and
36         /// appends them to ExtensionNumberResponse in an undefined order.
37         /// Its corresponding method is best-effort: it's not guaranteed that the
38         /// reflection service will implement this method, and it's not guaranteed
39         /// that this method will provide all extensions. Returns
40         /// StatusCode::UNIMPLEMENTED if it's not implemented.
41         /// This field should be a fully-qualified type name. The format is
42         /// <package>.<type>
43         #[prost(string, tag = "6")]
44         AllExtensionNumbersOfType(::prost::alloc::string::String),
45         /// List the full names of registered services. The content will not be
46         /// checked.
47         #[prost(string, tag = "7")]
48         ListServices(::prost::alloc::string::String),
49     }
50 }
51 /// The type name and extension number sent by the client when requesting
52 /// file_containing_extension.
53 #[allow(clippy::derive_partial_eq_without_eq)]
54 #[derive(Clone, PartialEq, ::prost::Message)]
55 pub struct ExtensionRequest {
56     /// Fully-qualified type name. The format should be <package>.<type>
57     #[prost(string, tag = "1")]
58     pub containing_type: ::prost::alloc::string::String,
59     #[prost(int32, tag = "2")]
60     pub extension_number: i32,
61 }
62 /// The message sent by the server to answer ServerReflectionInfo method.
63 #[allow(clippy::derive_partial_eq_without_eq)]
64 #[derive(Clone, PartialEq, ::prost::Message)]
65 pub struct ServerReflectionResponse {
66     #[prost(string, tag = "1")]
67     pub valid_host: ::prost::alloc::string::String,
68     #[prost(message, optional, tag = "2")]
69     pub original_request: ::core::option::Option<ServerReflectionRequest>,
70     /// The server sets one of the following fields according to the
71     /// message_request in the request.
72     #[prost(oneof = "server_reflection_response::MessageResponse", tags = "4, 5, 6, 7")]
73     pub message_response: ::core::option::Option<
74         server_reflection_response::MessageResponse,
75     >,
76 }
77 /// Nested message and enum types in `ServerReflectionResponse`.
78 pub mod server_reflection_response {
79     /// The server sets one of the following fields according to the
80     /// message_request in the request.
81     #[allow(clippy::derive_partial_eq_without_eq)]
82     #[derive(Clone, PartialEq, ::prost::Oneof)]
83     pub enum MessageResponse {
84         /// This message is used to answer file_by_filename, file_containing_symbol,
85         /// file_containing_extension requests with transitive dependencies.
86         /// As the repeated label is not allowed in oneof fields, we use a
87         /// FileDescriptorResponse message to encapsulate the repeated fields.
88         /// The reflection service is allowed to avoid sending FileDescriptorProtos
89         /// that were previously sent in response to earlier requests in the stream.
90         #[prost(message, tag = "4")]
91         FileDescriptorResponse(super::FileDescriptorResponse),
92         /// This message is used to answer all_extension_numbers_of_type requests.
93         #[prost(message, tag = "5")]
94         AllExtensionNumbersResponse(super::ExtensionNumberResponse),
95         /// This message is used to answer list_services requests.
96         #[prost(message, tag = "6")]
97         ListServicesResponse(super::ListServiceResponse),
98         /// This message is used when an error occurs.
99         #[prost(message, tag = "7")]
100         ErrorResponse(super::ErrorResponse),
101     }
102 }
103 /// Serialized FileDescriptorProto messages sent by the server answering
104 /// a file_by_filename, file_containing_symbol, or file_containing_extension
105 /// request.
106 #[allow(clippy::derive_partial_eq_without_eq)]
107 #[derive(Clone, PartialEq, ::prost::Message)]
108 pub struct FileDescriptorResponse {
109     /// Serialized FileDescriptorProto messages. We avoid taking a dependency on
110     /// descriptor.proto, which uses proto2 only features, by making them opaque
111     /// bytes instead.
112     #[prost(bytes = "vec", repeated, tag = "1")]
113     pub file_descriptor_proto: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
114 }
115 /// A list of extension numbers sent by the server answering
116 /// all_extension_numbers_of_type request.
117 #[allow(clippy::derive_partial_eq_without_eq)]
118 #[derive(Clone, PartialEq, ::prost::Message)]
119 pub struct ExtensionNumberResponse {
120     /// Full name of the base type, including the package name. The format
121     /// is <package>.<type>
122     #[prost(string, tag = "1")]
123     pub base_type_name: ::prost::alloc::string::String,
124     #[prost(int32, repeated, tag = "2")]
125     pub extension_number: ::prost::alloc::vec::Vec<i32>,
126 }
127 /// A list of ServiceResponse sent by the server answering list_services request.
128 #[allow(clippy::derive_partial_eq_without_eq)]
129 #[derive(Clone, PartialEq, ::prost::Message)]
130 pub struct ListServiceResponse {
131     /// The information of each service may be expanded in the future, so we use
132     /// ServiceResponse message to encapsulate it.
133     #[prost(message, repeated, tag = "1")]
134     pub service: ::prost::alloc::vec::Vec<ServiceResponse>,
135 }
136 /// The information of a single service used by ListServiceResponse to answer
137 /// list_services request.
138 #[allow(clippy::derive_partial_eq_without_eq)]
139 #[derive(Clone, PartialEq, ::prost::Message)]
140 pub struct ServiceResponse {
141     /// Full name of a registered service, including its package name. The format
142     /// is <package>.<service>
143     #[prost(string, tag = "1")]
144     pub name: ::prost::alloc::string::String,
145 }
146 /// The error code and error message sent by the server when an error occurs.
147 #[allow(clippy::derive_partial_eq_without_eq)]
148 #[derive(Clone, PartialEq, ::prost::Message)]
149 pub struct ErrorResponse {
150     /// This field uses the error codes defined in grpc::StatusCode.
151     #[prost(int32, tag = "1")]
152     pub error_code: i32,
153     #[prost(string, tag = "2")]
154     pub error_message: ::prost::alloc::string::String,
155 }
156 /// Generated client implementations.
157 pub mod server_reflection_client {
158     #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
159     use tonic::codegen::*;
160     use tonic::codegen::http::Uri;
161     #[derive(Debug, Clone)]
162     pub struct ServerReflectionClient<T> {
163         inner: tonic::client::Grpc<T>,
164     }
165     impl<T> ServerReflectionClient<T>
166     where
167         T: tonic::client::GrpcService<tonic::body::BoxBody>,
168         T::Error: Into<StdError>,
169         T::ResponseBody: Body<Data = Bytes> + Send + 'static,
170         <T::ResponseBody as Body>::Error: Into<StdError> + Send,
171     {
172         pub fn new(inner: T) -> Self {
173             let inner = tonic::client::Grpc::new(inner);
174             Self { inner }
175         }
176         pub fn with_origin(inner: T, origin: Uri) -> Self {
177             let inner = tonic::client::Grpc::with_origin(inner, origin);
178             Self { inner }
179         }
180         pub fn with_interceptor<F>(
181             inner: T,
182             interceptor: F,
183         ) -> ServerReflectionClient<InterceptedService<T, F>>
184         where
185             F: tonic::service::Interceptor,
186             T::ResponseBody: Default,
187             T: tonic::codegen::Service<
188                 http::Request<tonic::body::BoxBody>,
189                 Response = http::Response<
190                     <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
191                 >,
192             >,
193             <T as tonic::codegen::Service<
194                 http::Request<tonic::body::BoxBody>,
195             >>::Error: Into<StdError> + Send + Sync,
196         {
197             ServerReflectionClient::new(InterceptedService::new(inner, interceptor))
198         }
199         /// Compress requests with the given encoding.
200         ///
201         /// This requires the server to support it otherwise it might respond with an
202         /// error.
203         #[must_use]
204         pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
205             self.inner = self.inner.send_compressed(encoding);
206             self
207         }
208         /// Enable decompressing responses.
209         #[must_use]
210         pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
211             self.inner = self.inner.accept_compressed(encoding);
212             self
213         }
214         /// Limits the maximum size of a decoded message.
215         ///
216         /// Default: `4MB`
217         #[must_use]
218         pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
219             self.inner = self.inner.max_decoding_message_size(limit);
220             self
221         }
222         /// Limits the maximum size of an encoded message.
223         ///
224         /// Default: `usize::MAX`
225         #[must_use]
226         pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
227             self.inner = self.inner.max_encoding_message_size(limit);
228             self
229         }
230         /// The reflection service is structured as a bidirectional stream, ensuring
231         /// all related requests go to a single server.
232         pub async fn server_reflection_info(
233             &mut self,
234             request: impl tonic::IntoStreamingRequest<
235                 Message = super::ServerReflectionRequest,
236             >,
237         ) -> std::result::Result<
238             tonic::Response<tonic::codec::Streaming<super::ServerReflectionResponse>>,
239             tonic::Status,
240         > {
241             self.inner
242                 .ready()
243                 .await
244                 .map_err(|e| {
245                     tonic::Status::new(
246                         tonic::Code::Unknown,
247                         format!("Service was not ready: {}", e.into()),
248                     )
249                 })?;
250             let codec = tonic::codec::ProstCodec::default();
251             let path = http::uri::PathAndQuery::from_static(
252                 "/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo",
253             );
254             let mut req = request.into_streaming_request();
255             req.extensions_mut()
256                 .insert(
257                     GrpcMethod::new(
258                         "grpc.reflection.v1alpha.ServerReflection",
259                         "ServerReflectionInfo",
260                     ),
261                 );
262             self.inner.streaming(req, path, codec).await
263         }
264     }
265 }
266 /// Generated server implementations.
267 pub mod server_reflection_server {
268     #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
269     use tonic::codegen::*;
270     /// Generated trait containing gRPC methods that should be implemented for use with ServerReflectionServer.
271     #[async_trait]
272     pub trait ServerReflection: Send + Sync + 'static {
273         /// Server streaming response type for the ServerReflectionInfo method.
274         type ServerReflectionInfoStream: tonic::codegen::tokio_stream::Stream<
275                 Item = std::result::Result<
276                     super::ServerReflectionResponse,
277                     tonic::Status,
278                 >,
279             >
280             + Send
281             + 'static;
282         /// The reflection service is structured as a bidirectional stream, ensuring
283         /// all related requests go to a single server.
284         async fn server_reflection_info(
285             &self,
286             request: tonic::Request<tonic::Streaming<super::ServerReflectionRequest>>,
287         ) -> std::result::Result<
288             tonic::Response<Self::ServerReflectionInfoStream>,
289             tonic::Status,
290         >;
291     }
292     #[derive(Debug)]
293     pub struct ServerReflectionServer<T: ServerReflection> {
294         inner: _Inner<T>,
295         accept_compression_encodings: EnabledCompressionEncodings,
296         send_compression_encodings: EnabledCompressionEncodings,
297         max_decoding_message_size: Option<usize>,
298         max_encoding_message_size: Option<usize>,
299     }
300     struct _Inner<T>(Arc<T>);
301     impl<T: ServerReflection> ServerReflectionServer<T> {
302         pub fn new(inner: T) -> Self {
303             Self::from_arc(Arc::new(inner))
304         }
305         pub fn from_arc(inner: Arc<T>) -> Self {
306             let inner = _Inner(inner);
307             Self {
308                 inner,
309                 accept_compression_encodings: Default::default(),
310                 send_compression_encodings: Default::default(),
311                 max_decoding_message_size: None,
312                 max_encoding_message_size: None,
313             }
314         }
315         pub fn with_interceptor<F>(
316             inner: T,
317             interceptor: F,
318         ) -> InterceptedService<Self, F>
319         where
320             F: tonic::service::Interceptor,
321         {
322             InterceptedService::new(Self::new(inner), interceptor)
323         }
324         /// Enable decompressing requests with the given encoding.
325         #[must_use]
326         pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
327             self.accept_compression_encodings.enable(encoding);
328             self
329         }
330         /// Compress responses with the given encoding, if the client supports it.
331         #[must_use]
332         pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
333             self.send_compression_encodings.enable(encoding);
334             self
335         }
336         /// Limits the maximum size of a decoded message.
337         ///
338         /// Default: `4MB`
339         #[must_use]
340         pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
341             self.max_decoding_message_size = Some(limit);
342             self
343         }
344         /// Limits the maximum size of an encoded message.
345         ///
346         /// Default: `usize::MAX`
347         #[must_use]
348         pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
349             self.max_encoding_message_size = Some(limit);
350             self
351         }
352     }
353     impl<T, B> tonic::codegen::Service<http::Request<B>> for ServerReflectionServer<T>
354     where
355         T: ServerReflection,
356         B: Body + Send + 'static,
357         B::Error: Into<StdError> + Send + 'static,
358     {
359         type Response = http::Response<tonic::body::BoxBody>;
360         type Error = std::convert::Infallible;
361         type Future = BoxFuture<Self::Response, Self::Error>;
362         fn poll_ready(
363             &mut self,
364             _cx: &mut Context<'_>,
365         ) -> Poll<std::result::Result<(), Self::Error>> {
366             Poll::Ready(Ok(()))
367         }
368         fn call(&mut self, req: http::Request<B>) -> Self::Future {
369             let inner = self.inner.clone();
370             match req.uri().path() {
371                 "/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo" => {
372                     #[allow(non_camel_case_types)]
373                     struct ServerReflectionInfoSvc<T: ServerReflection>(pub Arc<T>);
374                     impl<
375                         T: ServerReflection,
376                     > tonic::server::StreamingService<super::ServerReflectionRequest>
377                     for ServerReflectionInfoSvc<T> {
378                         type Response = super::ServerReflectionResponse;
379                         type ResponseStream = T::ServerReflectionInfoStream;
380                         type Future = BoxFuture<
381                             tonic::Response<Self::ResponseStream>,
382                             tonic::Status,
383                         >;
384                         fn call(
385                             &mut self,
386                             request: tonic::Request<
387                                 tonic::Streaming<super::ServerReflectionRequest>,
388                             >,
389                         ) -> Self::Future {
390                             let inner = Arc::clone(&self.0);
391                             let fut = async move {
392                                 <T as ServerReflection>::server_reflection_info(
393                                         &inner,
394                                         request,
395                                     )
396                                     .await
397                             };
398                             Box::pin(fut)
399                         }
400                     }
401                     let accept_compression_encodings = self.accept_compression_encodings;
402                     let send_compression_encodings = self.send_compression_encodings;
403                     let max_decoding_message_size = self.max_decoding_message_size;
404                     let max_encoding_message_size = self.max_encoding_message_size;
405                     let inner = self.inner.clone();
406                     let fut = async move {
407                         let inner = inner.0;
408                         let method = ServerReflectionInfoSvc(inner);
409                         let codec = tonic::codec::ProstCodec::default();
410                         let mut grpc = tonic::server::Grpc::new(codec)
411                             .apply_compression_config(
412                                 accept_compression_encodings,
413                                 send_compression_encodings,
414                             )
415                             .apply_max_message_size_config(
416                                 max_decoding_message_size,
417                                 max_encoding_message_size,
418                             );
419                         let res = grpc.streaming(method, req).await;
420                         Ok(res)
421                     };
422                     Box::pin(fut)
423                 }
424                 _ => {
425                     Box::pin(async move {
426                         Ok(
427                             http::Response::builder()
428                                 .status(200)
429                                 .header("grpc-status", "12")
430                                 .header("content-type", "application/grpc")
431                                 .body(empty_body())
432                                 .unwrap(),
433                         )
434                     })
435                 }
436             }
437         }
438     }
439     impl<T: ServerReflection> Clone for ServerReflectionServer<T> {
440         fn clone(&self) -> Self {
441             let inner = self.inner.clone();
442             Self {
443                 inner,
444                 accept_compression_encodings: self.accept_compression_encodings,
445                 send_compression_encodings: self.send_compression_encodings,
446                 max_decoding_message_size: self.max_decoding_message_size,
447                 max_encoding_message_size: self.max_encoding_message_size,
448             }
449         }
450     }
451     impl<T: ServerReflection> Clone for _Inner<T> {
452         fn clone(&self) -> Self {
453             Self(Arc::clone(&self.0))
454         }
455     }
456     impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
457         fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
458             write!(f, "{:?}", self.0)
459         }
460     }
461     impl<T: ServerReflection> tonic::server::NamedService for ServerReflectionServer<T> {
462         const NAME: &'static str = "grpc.reflection.v1alpha.ServerReflection";
463     }
464 }
465