cosmos_sdk_proto/prost/cosmos-sdk/
cosmos.base.reflection.v1beta1.tonic.rs

1// @generated
2/// Generated client implementations.
3#[cfg(feature = "grpc")]
4pub mod reflection_service_client {
5    #![allow(
6        unused_variables,
7        dead_code,
8        missing_docs,
9        clippy::wildcard_imports,
10        clippy::let_unit_value
11    )]
12    use tonic::codegen::http::Uri;
13    use tonic::codegen::*;
14    #[derive(Debug, Clone)]
15    pub struct ReflectionServiceClient<T> {
16        inner: tonic::client::Grpc<T>,
17    }
18    #[cfg(feature = "grpc-transport")]
19    impl ReflectionServiceClient<tonic::transport::Channel> {
20        /// Attempt to create a new client by connecting to a given endpoint.
21        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
22        where
23            D: TryInto<tonic::transport::Endpoint>,
24            D::Error: Into<StdError>,
25        {
26            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
27            Ok(Self::new(conn))
28        }
29    }
30    impl<T> ReflectionServiceClient<T>
31    where
32        T: tonic::client::GrpcService<tonic::body::Body>,
33        T::Error: Into<StdError>,
34        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
35        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
36    {
37        pub fn new(inner: T) -> Self {
38            let inner = tonic::client::Grpc::new(inner);
39            Self { inner }
40        }
41        pub fn with_origin(inner: T, origin: Uri) -> Self {
42            let inner = tonic::client::Grpc::with_origin(inner, origin);
43            Self { inner }
44        }
45        pub fn with_interceptor<F>(
46            inner: T,
47            interceptor: F,
48        ) -> ReflectionServiceClient<InterceptedService<T, F>>
49        where
50            F: tonic::service::Interceptor,
51            T::ResponseBody: Default,
52            T: tonic::codegen::Service<
53                http::Request<tonic::body::Body>,
54                Response = http::Response<
55                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
56                >,
57            >,
58            <T as tonic::codegen::Service<http::Request<tonic::body::Body>>>::Error:
59                Into<StdError> + std::marker::Send + std::marker::Sync,
60        {
61            ReflectionServiceClient::new(InterceptedService::new(inner, interceptor))
62        }
63        /// Compress requests with the given encoding.
64        ///
65        /// This requires the server to support it otherwise it might respond with an
66        /// error.
67        #[must_use]
68        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
69            self.inner = self.inner.send_compressed(encoding);
70            self
71        }
72        /// Enable decompressing responses.
73        #[must_use]
74        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
75            self.inner = self.inner.accept_compressed(encoding);
76            self
77        }
78        /// Limits the maximum size of a decoded message.
79        ///
80        /// Default: `4MB`
81        #[must_use]
82        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
83            self.inner = self.inner.max_decoding_message_size(limit);
84            self
85        }
86        /// Limits the maximum size of an encoded message.
87        ///
88        /// Default: `usize::MAX`
89        #[must_use]
90        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
91            self.inner = self.inner.max_encoding_message_size(limit);
92            self
93        }
94        pub async fn list_all_interfaces(
95            &mut self,
96            request: impl tonic::IntoRequest<super::ListAllInterfacesRequest>,
97        ) -> core::result::Result<tonic::Response<super::ListAllInterfacesResponse>, tonic::Status>
98        {
99            self.inner.ready().await.map_err(|e| {
100                tonic::Status::unknown(alloc::format!("Service was not ready: {}", e.into()))
101            })?;
102            let codec = tonic::codec::ProstCodec::default();
103            let path = http::uri::PathAndQuery::from_static(
104                "/cosmos.base.reflection.v1beta1.ReflectionService/ListAllInterfaces",
105            );
106            let mut req = request.into_request();
107            req.extensions_mut().insert(GrpcMethod::new(
108                "cosmos.base.reflection.v1beta1.ReflectionService",
109                "ListAllInterfaces",
110            ));
111            self.inner.unary(req, path, codec).await
112        }
113        pub async fn list_implementations(
114            &mut self,
115            request: impl tonic::IntoRequest<super::ListImplementationsRequest>,
116        ) -> core::result::Result<tonic::Response<super::ListImplementationsResponse>, tonic::Status>
117        {
118            self.inner.ready().await.map_err(|e| {
119                tonic::Status::unknown(alloc::format!("Service was not ready: {}", e.into()))
120            })?;
121            let codec = tonic::codec::ProstCodec::default();
122            let path = http::uri::PathAndQuery::from_static(
123                "/cosmos.base.reflection.v1beta1.ReflectionService/ListImplementations",
124            );
125            let mut req = request.into_request();
126            req.extensions_mut().insert(GrpcMethod::new(
127                "cosmos.base.reflection.v1beta1.ReflectionService",
128                "ListImplementations",
129            ));
130            self.inner.unary(req, path, codec).await
131        }
132    }
133}
134/// Generated server implementations.
135#[cfg(feature = "grpc")]
136pub mod reflection_service_server {
137    #![allow(
138        unused_variables,
139        dead_code,
140        missing_docs,
141        clippy::wildcard_imports,
142        clippy::let_unit_value
143    )]
144    use tonic::codegen::*;
145    /// Generated trait containing gRPC methods that should be implemented for use with ReflectionServiceServer.
146    #[async_trait]
147    pub trait ReflectionService: std::marker::Send + std::marker::Sync + 'static {
148        async fn list_all_interfaces(
149            &self,
150            request: tonic::Request<super::ListAllInterfacesRequest>,
151        ) -> core::result::Result<tonic::Response<super::ListAllInterfacesResponse>, tonic::Status>;
152        async fn list_implementations(
153            &self,
154            request: tonic::Request<super::ListImplementationsRequest>,
155        ) -> core::result::Result<tonic::Response<super::ListImplementationsResponse>, tonic::Status>;
156    }
157    #[derive(Debug)]
158    pub struct ReflectionServiceServer<T> {
159        inner: Arc<T>,
160        accept_compression_encodings: EnabledCompressionEncodings,
161        send_compression_encodings: EnabledCompressionEncodings,
162        max_decoding_message_size: Option<usize>,
163        max_encoding_message_size: Option<usize>,
164    }
165    impl<T> ReflectionServiceServer<T> {
166        pub fn new(inner: T) -> Self {
167            Self::from_arc(Arc::new(inner))
168        }
169        pub fn from_arc(inner: Arc<T>) -> Self {
170            Self {
171                inner,
172                accept_compression_encodings: Default::default(),
173                send_compression_encodings: Default::default(),
174                max_decoding_message_size: None,
175                max_encoding_message_size: None,
176            }
177        }
178        pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
179        where
180            F: tonic::service::Interceptor,
181        {
182            InterceptedService::new(Self::new(inner), interceptor)
183        }
184        /// Enable decompressing requests with the given encoding.
185        #[must_use]
186        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
187            self.accept_compression_encodings.enable(encoding);
188            self
189        }
190        /// Compress responses with the given encoding, if the client supports it.
191        #[must_use]
192        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
193            self.send_compression_encodings.enable(encoding);
194            self
195        }
196        /// Limits the maximum size of a decoded message.
197        ///
198        /// Default: `4MB`
199        #[must_use]
200        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
201            self.max_decoding_message_size = Some(limit);
202            self
203        }
204        /// Limits the maximum size of an encoded message.
205        ///
206        /// Default: `usize::MAX`
207        #[must_use]
208        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
209            self.max_encoding_message_size = Some(limit);
210            self
211        }
212    }
213    impl<T, B> tonic::codegen::Service<http::Request<B>> for ReflectionServiceServer<T>
214    where
215        T: ReflectionService,
216        B: Body + std::marker::Send + 'static,
217        B::Error: Into<StdError> + std::marker::Send + 'static,
218    {
219        type Response = http::Response<tonic::body::Body>;
220        type Error = std::convert::Infallible;
221        type Future = BoxFuture<Self::Response, Self::Error>;
222        fn poll_ready(
223            &mut self,
224            _cx: &mut Context<'_>,
225        ) -> Poll<core::result::Result<(), Self::Error>> {
226            Poll::Ready(Ok(()))
227        }
228        fn call(&mut self, req: http::Request<B>) -> Self::Future {
229            match req.uri().path() {
230                "/cosmos.base.reflection.v1beta1.ReflectionService/ListAllInterfaces" => {
231                    #[allow(non_camel_case_types)]
232                    struct ListAllInterfacesSvc<T: ReflectionService>(pub Arc<T>);
233                    impl<T: ReflectionService>
234                        tonic::server::UnaryService<super::ListAllInterfacesRequest>
235                        for ListAllInterfacesSvc<T>
236                    {
237                        type Response = super::ListAllInterfacesResponse;
238                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
239                        fn call(
240                            &mut self,
241                            request: tonic::Request<super::ListAllInterfacesRequest>,
242                        ) -> Self::Future {
243                            let inner = Arc::clone(&self.0);
244                            let fut = async move {
245                                <T as ReflectionService>::list_all_interfaces(&inner, request).await
246                            };
247                            Box::pin(fut)
248                        }
249                    }
250                    let accept_compression_encodings = self.accept_compression_encodings;
251                    let send_compression_encodings = self.send_compression_encodings;
252                    let max_decoding_message_size = self.max_decoding_message_size;
253                    let max_encoding_message_size = self.max_encoding_message_size;
254                    let inner = self.inner.clone();
255                    let fut = async move {
256                        let method = ListAllInterfacesSvc(inner);
257                        let codec = tonic::codec::ProstCodec::default();
258                        let mut grpc = tonic::server::Grpc::new(codec)
259                            .apply_compression_config(
260                                accept_compression_encodings,
261                                send_compression_encodings,
262                            )
263                            .apply_max_message_size_config(
264                                max_decoding_message_size,
265                                max_encoding_message_size,
266                            );
267                        let res = grpc.unary(method, req).await;
268                        Ok(res)
269                    };
270                    Box::pin(fut)
271                }
272                "/cosmos.base.reflection.v1beta1.ReflectionService/ListImplementations" => {
273                    #[allow(non_camel_case_types)]
274                    struct ListImplementationsSvc<T: ReflectionService>(pub Arc<T>);
275                    impl<T: ReflectionService>
276                        tonic::server::UnaryService<super::ListImplementationsRequest>
277                        for ListImplementationsSvc<T>
278                    {
279                        type Response = super::ListImplementationsResponse;
280                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
281                        fn call(
282                            &mut self,
283                            request: tonic::Request<super::ListImplementationsRequest>,
284                        ) -> Self::Future {
285                            let inner = Arc::clone(&self.0);
286                            let fut = async move {
287                                <T as ReflectionService>::list_implementations(&inner, request)
288                                    .await
289                            };
290                            Box::pin(fut)
291                        }
292                    }
293                    let accept_compression_encodings = self.accept_compression_encodings;
294                    let send_compression_encodings = self.send_compression_encodings;
295                    let max_decoding_message_size = self.max_decoding_message_size;
296                    let max_encoding_message_size = self.max_encoding_message_size;
297                    let inner = self.inner.clone();
298                    let fut = async move {
299                        let method = ListImplementationsSvc(inner);
300                        let codec = tonic::codec::ProstCodec::default();
301                        let mut grpc = tonic::server::Grpc::new(codec)
302                            .apply_compression_config(
303                                accept_compression_encodings,
304                                send_compression_encodings,
305                            )
306                            .apply_max_message_size_config(
307                                max_decoding_message_size,
308                                max_encoding_message_size,
309                            );
310                        let res = grpc.unary(method, req).await;
311                        Ok(res)
312                    };
313                    Box::pin(fut)
314                }
315                _ => Box::pin(async move {
316                    let mut response = http::Response::new(tonic::body::Body::default());
317                    let headers = response.headers_mut();
318                    headers.insert(
319                        tonic::Status::GRPC_STATUS,
320                        (tonic::Code::Unimplemented as i32).into(),
321                    );
322                    headers.insert(
323                        http::header::CONTENT_TYPE,
324                        tonic::metadata::GRPC_CONTENT_TYPE,
325                    );
326                    Ok(response)
327                }),
328            }
329        }
330    }
331    impl<T> Clone for ReflectionServiceServer<T> {
332        fn clone(&self) -> Self {
333            let inner = self.inner.clone();
334            Self {
335                inner,
336                accept_compression_encodings: self.accept_compression_encodings,
337                send_compression_encodings: self.send_compression_encodings,
338                max_decoding_message_size: self.max_decoding_message_size,
339                max_encoding_message_size: self.max_encoding_message_size,
340            }
341        }
342    }
343    /// Generated gRPC service name
344    pub const SERVICE_NAME: &str = "cosmos.base.reflection.v1beta1.ReflectionService";
345    impl<T> tonic::server::NamedService for ReflectionServiceServer<T> {
346        const NAME: &'static str = SERVICE_NAME;
347    }
348}