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