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 the given message
37         /// type, and 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 message_request
72     /// 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 message_request
81     /// 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> + std::marker::Send + 'static,
171         <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::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> + std::marker::Send + std::marker::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.v1.ServerReflection/ServerReflectionInfo",
254             );
255             let mut req = request.into_streaming_request();
256             req.extensions_mut()
257                 .insert(
258                     GrpcMethod::new(
259                         "grpc.reflection.v1.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: std::marker::Send + std::marker::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             + std::marker::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> {
295         inner: Arc<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     impl<T> 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             Self {
307                 inner,
308                 accept_compression_encodings: Default::default(),
309                 send_compression_encodings: Default::default(),
310                 max_decoding_message_size: None,
311                 max_encoding_message_size: None,
312             }
313         }
314         pub fn with_interceptor<F>(
315             inner: T,
316             interceptor: F,
317         ) -> InterceptedService<Self, F>
318         where
319             F: tonic::service::Interceptor,
320         {
321             InterceptedService::new(Self::new(inner), interceptor)
322         }
323         /// Enable decompressing requests with the given encoding.
324         #[must_use]
325         pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
326             self.accept_compression_encodings.enable(encoding);
327             self
328         }
329         /// Compress responses with the given encoding, if the client supports it.
330         #[must_use]
331         pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
332             self.send_compression_encodings.enable(encoding);
333             self
334         }
335         /// Limits the maximum size of a decoded message.
336         ///
337         /// Default: `4MB`
338         #[must_use]
339         pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
340             self.max_decoding_message_size = Some(limit);
341             self
342         }
343         /// Limits the maximum size of an encoded message.
344         ///
345         /// Default: `usize::MAX`
346         #[must_use]
347         pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
348             self.max_encoding_message_size = Some(limit);
349             self
350         }
351     }
352     impl<T, B> tonic::codegen::Service<http::Request<B>> for ServerReflectionServer<T>
353     where
354         T: ServerReflection,
355         B: Body + std::marker::Send + 'static,
356         B::Error: Into<StdError> + std::marker::Send + 'static,
357     {
358         type Response = http::Response<tonic::body::BoxBody>;
359         type Error = std::convert::Infallible;
360         type Future = BoxFuture<Self::Response, Self::Error>;
361         fn poll_ready(
362             &mut self,
363             _cx: &mut Context<'_>,
364         ) -> Poll<std::result::Result<(), Self::Error>> {
365             Poll::Ready(Ok(()))
366         }
367         fn call(&mut self, req: http::Request<B>) -> Self::Future {
368             match req.uri().path() {
369                 "/grpc.reflection.v1.ServerReflection/ServerReflectionInfo" => {
370                     #[allow(non_camel_case_types)]
371                     struct ServerReflectionInfoSvc<T: ServerReflection>(pub Arc<T>);
372                     impl<
373                         T: ServerReflection,
374                     > tonic::server::StreamingService<super::ServerReflectionRequest>
375                     for ServerReflectionInfoSvc<T> {
376                         type Response = super::ServerReflectionResponse;
377                         type ResponseStream = T::ServerReflectionInfoStream;
378                         type Future = BoxFuture<
379                             tonic::Response<Self::ResponseStream>,
380                             tonic::Status,
381                         >;
382                         fn call(
383                             &mut self,
384                             request: tonic::Request<
385                                 tonic::Streaming<super::ServerReflectionRequest>,
386                             >,
387                         ) -> Self::Future {
388                             let inner = Arc::clone(&self.0);
389                             let fut = async move {
390                                 <T as ServerReflection>::server_reflection_info(
391                                         &inner,
392                                         request,
393                                     )
394                                     .await
395                             };
396                             Box::pin(fut)
397                         }
398                     }
399                     let accept_compression_encodings = self.accept_compression_encodings;
400                     let send_compression_encodings = self.send_compression_encodings;
401                     let max_decoding_message_size = self.max_decoding_message_size;
402                     let max_encoding_message_size = self.max_encoding_message_size;
403                     let inner = self.inner.clone();
404                     let fut = async move {
405                         let method = ServerReflectionInfoSvc(inner);
406                         let codec = tonic::codec::ProstCodec::default();
407                         let mut grpc = tonic::server::Grpc::new(codec)
408                             .apply_compression_config(
409                                 accept_compression_encodings,
410                                 send_compression_encodings,
411                             )
412                             .apply_max_message_size_config(
413                                 max_decoding_message_size,
414                                 max_encoding_message_size,
415                             );
416                         let res = grpc.streaming(method, req).await;
417                         Ok(res)
418                     };
419                     Box::pin(fut)
420                 }
421                 _ => {
422                     Box::pin(async move {
423                         Ok(
424                             http::Response::builder()
425                                 .status(200)
426                                 .header("grpc-status", tonic::Code::Unimplemented as i32)
427                                 .header(
428                                     http::header::CONTENT_TYPE,
429                                     tonic::metadata::GRPC_CONTENT_TYPE,
430                                 )
431                                 .body(empty_body())
432                                 .unwrap(),
433                         )
434                     })
435                 }
436             }
437         }
438     }
439     impl<T> 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     /// Generated gRPC service name
452     pub const SERVICE_NAME: &str = "grpc.reflection.v1.ServerReflection";
453     impl<T> tonic::server::NamedService for ServerReflectionServer<T> {
454         const NAME: &'static str = SERVICE_NAME;
455     }
456 }
457