1#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct ServerReflectionRequest {
5 #[prost(string, tag = "1")]
6 pub host: ::prost::alloc::string::String,
7 #[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}
15pub mod server_reflection_request {
17 #[derive(Clone, PartialEq, ::prost::Oneof)]
21 pub enum MessageRequest {
22 #[prost(string, tag = "3")]
24 FileByFilename(::prost::alloc::string::String),
25 #[prost(string, tag = "4")]
29 FileContainingSymbol(::prost::alloc::string::String),
30 #[prost(message, tag = "5")]
33 FileContainingExtension(super::ExtensionRequest),
34 #[prost(string, tag = "6")]
43 AllExtensionNumbersOfType(::prost::alloc::string::String),
44 #[prost(string, tag = "7")]
47 ListServices(::prost::alloc::string::String),
48 }
49}
50#[derive(Clone, PartialEq, ::prost::Message)]
53pub struct ExtensionRequest {
54 #[prost(string, tag = "1")]
56 pub containing_type: ::prost::alloc::string::String,
57 #[prost(int32, tag = "2")]
58 pub extension_number: i32,
59}
60#[derive(Clone, PartialEq, ::prost::Message)]
62pub struct ServerReflectionResponse {
63 #[prost(string, tag = "1")]
64 pub valid_host: ::prost::alloc::string::String,
65 #[prost(message, optional, tag = "2")]
66 pub original_request: ::core::option::Option<ServerReflectionRequest>,
67 #[prost(oneof = "server_reflection_response::MessageResponse", tags = "4, 5, 6, 7")]
70 pub message_response: ::core::option::Option<
71 server_reflection_response::MessageResponse,
72 >,
73}
74pub mod server_reflection_response {
76 #[derive(Clone, PartialEq, ::prost::Oneof)]
79 pub enum MessageResponse {
80 #[prost(message, tag = "4")]
87 FileDescriptorResponse(super::FileDescriptorResponse),
88 #[prost(message, tag = "5")]
90 AllExtensionNumbersResponse(super::ExtensionNumberResponse),
91 #[prost(message, tag = "6")]
93 ListServicesResponse(super::ListServiceResponse),
94 #[prost(message, tag = "7")]
96 ErrorResponse(super::ErrorResponse),
97 }
98}
99#[derive(Clone, PartialEq, ::prost::Message)]
103pub struct FileDescriptorResponse {
104 #[prost(bytes = "vec", repeated, tag = "1")]
108 pub file_descriptor_proto: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
109}
110#[derive(Clone, PartialEq, ::prost::Message)]
113pub struct ExtensionNumberResponse {
114 #[prost(string, tag = "1")]
117 pub base_type_name: ::prost::alloc::string::String,
118 #[prost(int32, repeated, tag = "2")]
119 pub extension_number: ::prost::alloc::vec::Vec<i32>,
120}
121#[derive(Clone, PartialEq, ::prost::Message)]
123pub struct ListServiceResponse {
124 #[prost(message, repeated, tag = "1")]
127 pub service: ::prost::alloc::vec::Vec<ServiceResponse>,
128}
129#[derive(Clone, PartialEq, ::prost::Message)]
132pub struct ServiceResponse {
133 #[prost(string, tag = "1")]
136 pub name: ::prost::alloc::string::String,
137}
138#[derive(Clone, PartialEq, ::prost::Message)]
140pub struct ErrorResponse {
141 #[prost(int32, tag = "1")]
143 pub error_code: i32,
144 #[prost(string, tag = "2")]
145 pub error_message: ::prost::alloc::string::String,
146}
147pub mod server_reflection_client {
149 #![allow(
150 unused_variables,
151 dead_code,
152 missing_docs,
153 clippy::wildcard_imports,
154 clippy::let_unit_value,
155 )]
156 use tonic::codegen::*;
157 use tonic::codegen::http::Uri;
158 #[derive(Debug, Clone)]
159 pub struct ServerReflectionClient<T> {
160 inner: tonic::client::Grpc<T>,
161 }
162 impl<T> ServerReflectionClient<T>
163 where
164 T: tonic::client::GrpcService<tonic::body::BoxBody>,
165 T::Error: Into<StdError>,
166 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
167 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
168 {
169 pub fn new(inner: T) -> Self {
170 let inner = tonic::client::Grpc::new(inner);
171 Self { inner }
172 }
173 pub fn with_origin(inner: T, origin: Uri) -> Self {
174 let inner = tonic::client::Grpc::with_origin(inner, origin);
175 Self { inner }
176 }
177 pub fn with_interceptor<F>(
178 inner: T,
179 interceptor: F,
180 ) -> ServerReflectionClient<InterceptedService<T, F>>
181 where
182 F: tonic::service::Interceptor,
183 T::ResponseBody: Default,
184 T: tonic::codegen::Service<
185 http::Request<tonic::body::BoxBody>,
186 Response = http::Response<
187 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
188 >,
189 >,
190 <T as tonic::codegen::Service<
191 http::Request<tonic::body::BoxBody>,
192 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
193 {
194 ServerReflectionClient::new(InterceptedService::new(inner, interceptor))
195 }
196 #[must_use]
201 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
202 self.inner = self.inner.send_compressed(encoding);
203 self
204 }
205 #[must_use]
207 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
208 self.inner = self.inner.accept_compressed(encoding);
209 self
210 }
211 #[must_use]
215 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
216 self.inner = self.inner.max_decoding_message_size(limit);
217 self
218 }
219 #[must_use]
223 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
224 self.inner = self.inner.max_encoding_message_size(limit);
225 self
226 }
227 pub async fn server_reflection_info(
230 &mut self,
231 request: impl tonic::IntoStreamingRequest<
232 Message = super::ServerReflectionRequest,
233 >,
234 ) -> std::result::Result<
235 tonic::Response<tonic::codec::Streaming<super::ServerReflectionResponse>>,
236 tonic::Status,
237 > {
238 self.inner
239 .ready()
240 .await
241 .map_err(|e| {
242 tonic::Status::unknown(
243 format!("Service was not ready: {}", e.into()),
244 )
245 })?;
246 let codec = tonic::codec::ProstCodec::default();
247 let path = http::uri::PathAndQuery::from_static(
248 "/grpc.reflection.v1.ServerReflection/ServerReflectionInfo",
249 );
250 let mut req = request.into_streaming_request();
251 req.extensions_mut()
252 .insert(
253 GrpcMethod::new(
254 "grpc.reflection.v1.ServerReflection",
255 "ServerReflectionInfo",
256 ),
257 );
258 self.inner.streaming(req, path, codec).await
259 }
260 }
261}
262pub mod server_reflection_server {
264 #![allow(
265 unused_variables,
266 dead_code,
267 missing_docs,
268 clippy::wildcard_imports,
269 clippy::let_unit_value,
270 )]
271 use tonic::codegen::*;
272 #[async_trait]
274 pub trait ServerReflection: std::marker::Send + std::marker::Sync + 'static {
275 type ServerReflectionInfoStream: tonic::codegen::tokio_stream::Stream<
277 Item = std::result::Result<
278 super::ServerReflectionResponse,
279 tonic::Status,
280 >,
281 >
282 + std::marker::Send
283 + 'static;
284 async fn server_reflection_info(
287 &self,
288 request: tonic::Request<tonic::Streaming<super::ServerReflectionRequest>>,
289 ) -> std::result::Result<
290 tonic::Response<Self::ServerReflectionInfoStream>,
291 tonic::Status,
292 >;
293 }
294 #[derive(Debug)]
295 pub struct ServerReflectionServer<T> {
296 inner: Arc<T>,
297 accept_compression_encodings: EnabledCompressionEncodings,
298 send_compression_encodings: EnabledCompressionEncodings,
299 max_decoding_message_size: Option<usize>,
300 max_encoding_message_size: Option<usize>,
301 }
302 impl<T> 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 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 #[must_use]
326 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
327 self.accept_compression_encodings.enable(encoding);
328 self
329 }
330 #[must_use]
332 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
333 self.send_compression_encodings.enable(encoding);
334 self
335 }
336 #[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 #[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 + std::marker::Send + 'static,
357 B::Error: Into<StdError> + std::marker::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 match req.uri().path() {
370 "/grpc.reflection.v1.ServerReflection/ServerReflectionInfo" => {
371 #[allow(non_camel_case_types)]
372 struct ServerReflectionInfoSvc<T: ServerReflection>(pub Arc<T>);
373 impl<
374 T: ServerReflection,
375 > tonic::server::StreamingService<super::ServerReflectionRequest>
376 for ServerReflectionInfoSvc<T> {
377 type Response = super::ServerReflectionResponse;
378 type ResponseStream = T::ServerReflectionInfoStream;
379 type Future = BoxFuture<
380 tonic::Response<Self::ResponseStream>,
381 tonic::Status,
382 >;
383 fn call(
384 &mut self,
385 request: tonic::Request<
386 tonic::Streaming<super::ServerReflectionRequest>,
387 >,
388 ) -> Self::Future {
389 let inner = Arc::clone(&self.0);
390 let fut = async move {
391 <T as ServerReflection>::server_reflection_info(
392 &inner,
393 request,
394 )
395 .await
396 };
397 Box::pin(fut)
398 }
399 }
400 let accept_compression_encodings = self.accept_compression_encodings;
401 let send_compression_encodings = self.send_compression_encodings;
402 let max_decoding_message_size = self.max_decoding_message_size;
403 let max_encoding_message_size = self.max_encoding_message_size;
404 let inner = self.inner.clone();
405 let fut = async move {
406 let method = ServerReflectionInfoSvc(inner);
407 let codec = tonic::codec::ProstCodec::default();
408 let mut grpc = tonic::server::Grpc::new(codec)
409 .apply_compression_config(
410 accept_compression_encodings,
411 send_compression_encodings,
412 )
413 .apply_max_message_size_config(
414 max_decoding_message_size,
415 max_encoding_message_size,
416 );
417 let res = grpc.streaming(method, req).await;
418 Ok(res)
419 };
420 Box::pin(fut)
421 }
422 _ => {
423 Box::pin(async move {
424 let mut response = http::Response::new(empty_body());
425 let headers = response.headers_mut();
426 headers
427 .insert(
428 tonic::Status::GRPC_STATUS,
429 (tonic::Code::Unimplemented as i32).into(),
430 );
431 headers
432 .insert(
433 http::header::CONTENT_TYPE,
434 tonic::metadata::GRPC_CONTENT_TYPE,
435 );
436 Ok(response)
437 })
438 }
439 }
440 }
441 }
442 impl<T> Clone for ServerReflectionServer<T> {
443 fn clone(&self) -> Self {
444 let inner = self.inner.clone();
445 Self {
446 inner,
447 accept_compression_encodings: self.accept_compression_encodings,
448 send_compression_encodings: self.send_compression_encodings,
449 max_decoding_message_size: self.max_decoding_message_size,
450 max_encoding_message_size: self.max_encoding_message_size,
451 }
452 }
453 }
454 pub const SERVICE_NAME: &str = "grpc.reflection.v1.ServerReflection";
456 impl<T> tonic::server::NamedService for ServerReflectionServer<T> {
457 const NAME: &'static str = SERVICE_NAME;
458 }
459}