1#[cfg(feature = "grpc")]
4#[cfg_attr(docsrs, doc(cfg(feature = "grpc")))]
5pub mod query_client {
6 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
7 use tonic::codegen::http::Uri;
8 use tonic::codegen::*;
9 #[derive(Debug, Clone)]
10 pub struct QueryClient<T> {
11 inner: tonic::client::Grpc<T>,
12 }
13 #[cfg(feature = "grpc-transport")]
14 #[cfg_attr(docsrs, doc(cfg(feature = "grpc-transport")))]
15 impl QueryClient<tonic::transport::Channel> {
16 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
18 where
19 D: std::convert::TryInto<tonic::transport::Endpoint>,
20 D::Error: Into<StdError>,
21 {
22 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
23 Ok(Self::new(conn))
24 }
25 }
26 impl<T> QueryClient<T>
27 where
28 T: tonic::client::GrpcService<tonic::body::BoxBody>,
29 T::Error: Into<StdError>,
30 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
31 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
32 {
33 pub fn new(inner: T) -> Self {
34 let inner = tonic::client::Grpc::new(inner);
35 Self { inner }
36 }
37 pub fn with_origin(inner: T, origin: Uri) -> Self {
38 let inner = tonic::client::Grpc::with_origin(inner, origin);
39 Self { inner }
40 }
41 pub fn with_interceptor<F>(
42 inner: T,
43 interceptor: F,
44 ) -> QueryClient<InterceptedService<T, F>>
45 where
46 F: tonic::service::Interceptor,
47 T::ResponseBody: Default,
48 T: tonic::codegen::Service<
49 http::Request<tonic::body::BoxBody>,
50 Response = http::Response<
51 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
52 >,
53 >,
54 <T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error:
55 Into<StdError> + Send + Sync,
56 {
57 QueryClient::new(InterceptedService::new(inner, interceptor))
58 }
59 #[must_use]
64 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
65 self.inner = self.inner.send_compressed(encoding);
66 self
67 }
68 #[must_use]
70 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
71 self.inner = self.inner.accept_compressed(encoding);
72 self
73 }
74 pub async fn params(
75 &mut self,
76 request: impl tonic::IntoRequest<super::QueryParamsRequest>,
77 ) -> Result<tonic::Response<super::QueryParamsResponse>, tonic::Status> {
78 self.inner.ready().await.map_err(|e| {
79 tonic::Status::new(
80 tonic::Code::Unknown,
81 format!("Service was not ready: {}", e.into()),
82 )
83 })?;
84 let codec = tonic::codec::ProstCodec::default();
85 let path =
86 http::uri::PathAndQuery::from_static("/cosmos.slashing.v1beta1.Query/Params");
87 self.inner.unary(request.into_request(), path, codec).await
88 }
89 pub async fn signing_info(
90 &mut self,
91 request: impl tonic::IntoRequest<super::QuerySigningInfoRequest>,
92 ) -> Result<tonic::Response<super::QuerySigningInfoResponse>, tonic::Status> {
93 self.inner.ready().await.map_err(|e| {
94 tonic::Status::new(
95 tonic::Code::Unknown,
96 format!("Service was not ready: {}", e.into()),
97 )
98 })?;
99 let codec = tonic::codec::ProstCodec::default();
100 let path =
101 http::uri::PathAndQuery::from_static("/cosmos.slashing.v1beta1.Query/SigningInfo");
102 self.inner.unary(request.into_request(), path, codec).await
103 }
104 pub async fn signing_infos(
105 &mut self,
106 request: impl tonic::IntoRequest<super::QuerySigningInfosRequest>,
107 ) -> Result<tonic::Response<super::QuerySigningInfosResponse>, tonic::Status> {
108 self.inner.ready().await.map_err(|e| {
109 tonic::Status::new(
110 tonic::Code::Unknown,
111 format!("Service was not ready: {}", e.into()),
112 )
113 })?;
114 let codec = tonic::codec::ProstCodec::default();
115 let path =
116 http::uri::PathAndQuery::from_static("/cosmos.slashing.v1beta1.Query/SigningInfos");
117 self.inner.unary(request.into_request(), path, codec).await
118 }
119 }
120}
121#[cfg(feature = "grpc")]
123#[cfg_attr(docsrs, doc(cfg(feature = "grpc")))]
124pub mod query_server {
125 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
126 use tonic::codegen::*;
127 #[async_trait]
129 pub trait Query: Send + Sync + 'static {
130 async fn params(
131 &self,
132 request: tonic::Request<super::QueryParamsRequest>,
133 ) -> Result<tonic::Response<super::QueryParamsResponse>, tonic::Status>;
134 async fn signing_info(
135 &self,
136 request: tonic::Request<super::QuerySigningInfoRequest>,
137 ) -> Result<tonic::Response<super::QuerySigningInfoResponse>, tonic::Status>;
138 async fn signing_infos(
139 &self,
140 request: tonic::Request<super::QuerySigningInfosRequest>,
141 ) -> Result<tonic::Response<super::QuerySigningInfosResponse>, tonic::Status>;
142 }
143 #[derive(Debug)]
144 pub struct QueryServer<T: Query> {
145 inner: _Inner<T>,
146 accept_compression_encodings: EnabledCompressionEncodings,
147 send_compression_encodings: EnabledCompressionEncodings,
148 }
149 struct _Inner<T>(Arc<T>);
150 impl<T: Query> QueryServer<T> {
151 pub fn new(inner: T) -> Self {
152 Self::from_arc(Arc::new(inner))
153 }
154 pub fn from_arc(inner: Arc<T>) -> Self {
155 let inner = _Inner(inner);
156 Self {
157 inner,
158 accept_compression_encodings: Default::default(),
159 send_compression_encodings: Default::default(),
160 }
161 }
162 pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
163 where
164 F: tonic::service::Interceptor,
165 {
166 InterceptedService::new(Self::new(inner), interceptor)
167 }
168 #[must_use]
170 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
171 self.accept_compression_encodings.enable(encoding);
172 self
173 }
174 #[must_use]
176 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
177 self.send_compression_encodings.enable(encoding);
178 self
179 }
180 }
181 impl<T, B> tonic::codegen::Service<http::Request<B>> for QueryServer<T>
182 where
183 T: Query,
184 B: Body + Send + 'static,
185 B::Error: Into<StdError> + Send + 'static,
186 {
187 type Response = http::Response<tonic::body::BoxBody>;
188 type Error = std::convert::Infallible;
189 type Future = BoxFuture<Self::Response, Self::Error>;
190 fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
191 Poll::Ready(Ok(()))
192 }
193 fn call(&mut self, req: http::Request<B>) -> Self::Future {
194 let inner = self.inner.clone();
195 match req.uri().path() {
196 "/cosmos.slashing.v1beta1.Query/Params" => {
197 #[allow(non_camel_case_types)]
198 struct ParamsSvc<T: Query>(pub Arc<T>);
199 impl<T: Query> tonic::server::UnaryService<super::QueryParamsRequest> for ParamsSvc<T> {
200 type Response = super::QueryParamsResponse;
201 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
202 fn call(
203 &mut self,
204 request: tonic::Request<super::QueryParamsRequest>,
205 ) -> Self::Future {
206 let inner = self.0.clone();
207 let fut = async move { (*inner).params(request).await };
208 Box::pin(fut)
209 }
210 }
211 let accept_compression_encodings = self.accept_compression_encodings;
212 let send_compression_encodings = self.send_compression_encodings;
213 let inner = self.inner.clone();
214 let fut = async move {
215 let inner = inner.0;
216 let method = ParamsSvc(inner);
217 let codec = tonic::codec::ProstCodec::default();
218 let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
219 accept_compression_encodings,
220 send_compression_encodings,
221 );
222 let res = grpc.unary(method, req).await;
223 Ok(res)
224 };
225 Box::pin(fut)
226 }
227 "/cosmos.slashing.v1beta1.Query/SigningInfo" => {
228 #[allow(non_camel_case_types)]
229 struct SigningInfoSvc<T: Query>(pub Arc<T>);
230 impl<T: Query> tonic::server::UnaryService<super::QuerySigningInfoRequest> for SigningInfoSvc<T> {
231 type Response = super::QuerySigningInfoResponse;
232 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
233 fn call(
234 &mut self,
235 request: tonic::Request<super::QuerySigningInfoRequest>,
236 ) -> Self::Future {
237 let inner = self.0.clone();
238 let fut = async move { (*inner).signing_info(request).await };
239 Box::pin(fut)
240 }
241 }
242 let accept_compression_encodings = self.accept_compression_encodings;
243 let send_compression_encodings = self.send_compression_encodings;
244 let inner = self.inner.clone();
245 let fut = async move {
246 let inner = inner.0;
247 let method = SigningInfoSvc(inner);
248 let codec = tonic::codec::ProstCodec::default();
249 let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
250 accept_compression_encodings,
251 send_compression_encodings,
252 );
253 let res = grpc.unary(method, req).await;
254 Ok(res)
255 };
256 Box::pin(fut)
257 }
258 "/cosmos.slashing.v1beta1.Query/SigningInfos" => {
259 #[allow(non_camel_case_types)]
260 struct SigningInfosSvc<T: Query>(pub Arc<T>);
261 impl<T: Query> tonic::server::UnaryService<super::QuerySigningInfosRequest> for SigningInfosSvc<T> {
262 type Response = super::QuerySigningInfosResponse;
263 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
264 fn call(
265 &mut self,
266 request: tonic::Request<super::QuerySigningInfosRequest>,
267 ) -> Self::Future {
268 let inner = self.0.clone();
269 let fut = async move { (*inner).signing_infos(request).await };
270 Box::pin(fut)
271 }
272 }
273 let accept_compression_encodings = self.accept_compression_encodings;
274 let send_compression_encodings = self.send_compression_encodings;
275 let inner = self.inner.clone();
276 let fut = async move {
277 let inner = inner.0;
278 let method = SigningInfosSvc(inner);
279 let codec = tonic::codec::ProstCodec::default();
280 let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
281 accept_compression_encodings,
282 send_compression_encodings,
283 );
284 let res = grpc.unary(method, req).await;
285 Ok(res)
286 };
287 Box::pin(fut)
288 }
289 _ => Box::pin(async move {
290 Ok(http::Response::builder()
291 .status(200)
292 .header("grpc-status", "12")
293 .header("content-type", "application/grpc")
294 .body(empty_body())
295 .unwrap())
296 }),
297 }
298 }
299 }
300 impl<T: Query> Clone for QueryServer<T> {
301 fn clone(&self) -> Self {
302 let inner = self.inner.clone();
303 Self {
304 inner,
305 accept_compression_encodings: self.accept_compression_encodings,
306 send_compression_encodings: self.send_compression_encodings,
307 }
308 }
309 }
310 impl<T: Query> Clone for _Inner<T> {
311 fn clone(&self) -> Self {
312 Self(self.0.clone())
313 }
314 }
315 impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
316 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
317 write!(f, "{:?}", self.0)
318 }
319 }
320 impl<T: Query> tonic::server::NamedService for QueryServer<T> {
321 const NAME: &'static str = "cosmos.slashing.v1beta1.Query";
322 }
323}
324#[cfg(feature = "grpc")]
326#[cfg_attr(docsrs, doc(cfg(feature = "grpc")))]
327pub mod msg_client {
328 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
329 use tonic::codegen::http::Uri;
330 use tonic::codegen::*;
331 #[derive(Debug, Clone)]
332 pub struct MsgClient<T> {
333 inner: tonic::client::Grpc<T>,
334 }
335 #[cfg(feature = "grpc-transport")]
336 #[cfg_attr(docsrs, doc(cfg(feature = "grpc-transport")))]
337 impl MsgClient<tonic::transport::Channel> {
338 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
340 where
341 D: std::convert::TryInto<tonic::transport::Endpoint>,
342 D::Error: Into<StdError>,
343 {
344 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
345 Ok(Self::new(conn))
346 }
347 }
348 impl<T> MsgClient<T>
349 where
350 T: tonic::client::GrpcService<tonic::body::BoxBody>,
351 T::Error: Into<StdError>,
352 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
353 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
354 {
355 pub fn new(inner: T) -> Self {
356 let inner = tonic::client::Grpc::new(inner);
357 Self { inner }
358 }
359 pub fn with_origin(inner: T, origin: Uri) -> Self {
360 let inner = tonic::client::Grpc::with_origin(inner, origin);
361 Self { inner }
362 }
363 pub fn with_interceptor<F>(inner: T, interceptor: F) -> MsgClient<InterceptedService<T, F>>
364 where
365 F: tonic::service::Interceptor,
366 T::ResponseBody: Default,
367 T: tonic::codegen::Service<
368 http::Request<tonic::body::BoxBody>,
369 Response = http::Response<
370 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
371 >,
372 >,
373 <T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error:
374 Into<StdError> + Send + Sync,
375 {
376 MsgClient::new(InterceptedService::new(inner, interceptor))
377 }
378 #[must_use]
383 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
384 self.inner = self.inner.send_compressed(encoding);
385 self
386 }
387 #[must_use]
389 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
390 self.inner = self.inner.accept_compressed(encoding);
391 self
392 }
393 pub async fn unjail(
394 &mut self,
395 request: impl tonic::IntoRequest<super::MsgUnjail>,
396 ) -> Result<tonic::Response<super::MsgUnjailResponse>, tonic::Status> {
397 self.inner.ready().await.map_err(|e| {
398 tonic::Status::new(
399 tonic::Code::Unknown,
400 format!("Service was not ready: {}", e.into()),
401 )
402 })?;
403 let codec = tonic::codec::ProstCodec::default();
404 let path = http::uri::PathAndQuery::from_static("/cosmos.slashing.v1beta1.Msg/Unjail");
405 self.inner.unary(request.into_request(), path, codec).await
406 }
407 pub async fn update_params(
408 &mut self,
409 request: impl tonic::IntoRequest<super::MsgUpdateParams>,
410 ) -> Result<tonic::Response<super::MsgUpdateParamsResponse>, tonic::Status> {
411 self.inner.ready().await.map_err(|e| {
412 tonic::Status::new(
413 tonic::Code::Unknown,
414 format!("Service was not ready: {}", e.into()),
415 )
416 })?;
417 let codec = tonic::codec::ProstCodec::default();
418 let path =
419 http::uri::PathAndQuery::from_static("/cosmos.slashing.v1beta1.Msg/UpdateParams");
420 self.inner.unary(request.into_request(), path, codec).await
421 }
422 }
423}
424#[cfg(feature = "grpc")]
426#[cfg_attr(docsrs, doc(cfg(feature = "grpc")))]
427pub mod msg_server {
428 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
429 use tonic::codegen::*;
430 #[async_trait]
432 pub trait Msg: Send + Sync + 'static {
433 async fn unjail(
434 &self,
435 request: tonic::Request<super::MsgUnjail>,
436 ) -> Result<tonic::Response<super::MsgUnjailResponse>, tonic::Status>;
437 async fn update_params(
438 &self,
439 request: tonic::Request<super::MsgUpdateParams>,
440 ) -> Result<tonic::Response<super::MsgUpdateParamsResponse>, tonic::Status>;
441 }
442 #[derive(Debug)]
443 pub struct MsgServer<T: Msg> {
444 inner: _Inner<T>,
445 accept_compression_encodings: EnabledCompressionEncodings,
446 send_compression_encodings: EnabledCompressionEncodings,
447 }
448 struct _Inner<T>(Arc<T>);
449 impl<T: Msg> MsgServer<T> {
450 pub fn new(inner: T) -> Self {
451 Self::from_arc(Arc::new(inner))
452 }
453 pub fn from_arc(inner: Arc<T>) -> Self {
454 let inner = _Inner(inner);
455 Self {
456 inner,
457 accept_compression_encodings: Default::default(),
458 send_compression_encodings: Default::default(),
459 }
460 }
461 pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
462 where
463 F: tonic::service::Interceptor,
464 {
465 InterceptedService::new(Self::new(inner), interceptor)
466 }
467 #[must_use]
469 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
470 self.accept_compression_encodings.enable(encoding);
471 self
472 }
473 #[must_use]
475 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
476 self.send_compression_encodings.enable(encoding);
477 self
478 }
479 }
480 impl<T, B> tonic::codegen::Service<http::Request<B>> for MsgServer<T>
481 where
482 T: Msg,
483 B: Body + Send + 'static,
484 B::Error: Into<StdError> + Send + 'static,
485 {
486 type Response = http::Response<tonic::body::BoxBody>;
487 type Error = std::convert::Infallible;
488 type Future = BoxFuture<Self::Response, Self::Error>;
489 fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
490 Poll::Ready(Ok(()))
491 }
492 fn call(&mut self, req: http::Request<B>) -> Self::Future {
493 let inner = self.inner.clone();
494 match req.uri().path() {
495 "/cosmos.slashing.v1beta1.Msg/Unjail" => {
496 #[allow(non_camel_case_types)]
497 struct UnjailSvc<T: Msg>(pub Arc<T>);
498 impl<T: Msg> tonic::server::UnaryService<super::MsgUnjail> for UnjailSvc<T> {
499 type Response = super::MsgUnjailResponse;
500 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
501 fn call(
502 &mut self,
503 request: tonic::Request<super::MsgUnjail>,
504 ) -> Self::Future {
505 let inner = self.0.clone();
506 let fut = async move { (*inner).unjail(request).await };
507 Box::pin(fut)
508 }
509 }
510 let accept_compression_encodings = self.accept_compression_encodings;
511 let send_compression_encodings = self.send_compression_encodings;
512 let inner = self.inner.clone();
513 let fut = async move {
514 let inner = inner.0;
515 let method = UnjailSvc(inner);
516 let codec = tonic::codec::ProstCodec::default();
517 let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
518 accept_compression_encodings,
519 send_compression_encodings,
520 );
521 let res = grpc.unary(method, req).await;
522 Ok(res)
523 };
524 Box::pin(fut)
525 }
526 "/cosmos.slashing.v1beta1.Msg/UpdateParams" => {
527 #[allow(non_camel_case_types)]
528 struct UpdateParamsSvc<T: Msg>(pub Arc<T>);
529 impl<T: Msg> tonic::server::UnaryService<super::MsgUpdateParams> for UpdateParamsSvc<T> {
530 type Response = super::MsgUpdateParamsResponse;
531 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
532 fn call(
533 &mut self,
534 request: tonic::Request<super::MsgUpdateParams>,
535 ) -> Self::Future {
536 let inner = self.0.clone();
537 let fut = async move { (*inner).update_params(request).await };
538 Box::pin(fut)
539 }
540 }
541 let accept_compression_encodings = self.accept_compression_encodings;
542 let send_compression_encodings = self.send_compression_encodings;
543 let inner = self.inner.clone();
544 let fut = async move {
545 let inner = inner.0;
546 let method = UpdateParamsSvc(inner);
547 let codec = tonic::codec::ProstCodec::default();
548 let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
549 accept_compression_encodings,
550 send_compression_encodings,
551 );
552 let res = grpc.unary(method, req).await;
553 Ok(res)
554 };
555 Box::pin(fut)
556 }
557 _ => Box::pin(async move {
558 Ok(http::Response::builder()
559 .status(200)
560 .header("grpc-status", "12")
561 .header("content-type", "application/grpc")
562 .body(empty_body())
563 .unwrap())
564 }),
565 }
566 }
567 }
568 impl<T: Msg> Clone for MsgServer<T> {
569 fn clone(&self) -> Self {
570 let inner = self.inner.clone();
571 Self {
572 inner,
573 accept_compression_encodings: self.accept_compression_encodings,
574 send_compression_encodings: self.send_compression_encodings,
575 }
576 }
577 }
578 impl<T: Msg> Clone for _Inner<T> {
579 fn clone(&self) -> Self {
580 Self(self.0.clone())
581 }
582 }
583 impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
584 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
585 write!(f, "{:?}", self.0)
586 }
587 }
588 impl<T: Msg> tonic::server::NamedService for MsgServer<T> {
589 const NAME: &'static str = "cosmos.slashing.v1beta1.Msg";
590 }
591}