1#[cfg(feature = "grpc")]
4pub mod query_client {
5 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
6 use tonic::codegen::http::Uri;
7 use tonic::codegen::*;
8 #[derive(Debug, Clone)]
9 pub struct QueryClient<T> {
10 inner: tonic::client::Grpc<T>,
11 }
12 #[cfg(feature = "grpc-transport")]
13 impl QueryClient<tonic::transport::Channel> {
14 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
16 where
17 D: TryInto<tonic::transport::Endpoint>,
18 D::Error: Into<StdError>,
19 {
20 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
21 Ok(Self::new(conn))
22 }
23 }
24 impl<T> QueryClient<T>
25 where
26 T: tonic::client::GrpcService<tonic::body::BoxBody>,
27 T::Error: Into<StdError>,
28 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
29 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
30 {
31 pub fn new(inner: T) -> Self {
32 let inner = tonic::client::Grpc::new(inner);
33 Self { inner }
34 }
35 pub fn with_origin(inner: T, origin: Uri) -> Self {
36 let inner = tonic::client::Grpc::with_origin(inner, origin);
37 Self { inner }
38 }
39 pub fn with_interceptor<F>(
40 inner: T,
41 interceptor: F,
42 ) -> QueryClient<InterceptedService<T, F>>
43 where
44 F: tonic::service::Interceptor,
45 T::ResponseBody: Default,
46 T: tonic::codegen::Service<
47 http::Request<tonic::body::BoxBody>,
48 Response = http::Response<
49 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
50 >,
51 >,
52 <T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error:
53 Into<StdError> + Send + Sync,
54 {
55 QueryClient::new(InterceptedService::new(inner, interceptor))
56 }
57 #[must_use]
62 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
63 self.inner = self.inner.send_compressed(encoding);
64 self
65 }
66 #[must_use]
68 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
69 self.inner = self.inner.accept_compressed(encoding);
70 self
71 }
72 #[must_use]
76 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
77 self.inner = self.inner.max_decoding_message_size(limit);
78 self
79 }
80 #[must_use]
84 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
85 self.inner = self.inner.max_encoding_message_size(limit);
86 self
87 }
88 pub async fn params(
89 &mut self,
90 request: impl tonic::IntoRequest<super::QueryParamsRequest>,
91 ) -> core::result::Result<tonic::Response<super::QueryParamsResponse>, tonic::Status>
92 {
93 self.inner.ready().await.map_err(|e| {
94 tonic::Status::new(
95 tonic::Code::Unknown,
96 alloc::format!("Service was not ready: {}", e.into()),
97 )
98 })?;
99 let codec = tonic::codec::ProstCodec::default();
100 let path = http::uri::PathAndQuery::from_static("/side.liquidation.Query/Params");
101 let mut req = request.into_request();
102 req.extensions_mut()
103 .insert(GrpcMethod::new("side.liquidation.Query", "Params"));
104 self.inner.unary(req, path, codec).await
105 }
106 pub async fn liquidation(
107 &mut self,
108 request: impl tonic::IntoRequest<super::QueryLiquidationRequest>,
109 ) -> core::result::Result<tonic::Response<super::QueryLiquidationResponse>, tonic::Status>
110 {
111 self.inner.ready().await.map_err(|e| {
112 tonic::Status::new(
113 tonic::Code::Unknown,
114 alloc::format!("Service was not ready: {}", e.into()),
115 )
116 })?;
117 let codec = tonic::codec::ProstCodec::default();
118 let path = http::uri::PathAndQuery::from_static("/side.liquidation.Query/Liquidation");
119 let mut req = request.into_request();
120 req.extensions_mut()
121 .insert(GrpcMethod::new("side.liquidation.Query", "Liquidation"));
122 self.inner.unary(req, path, codec).await
123 }
124 pub async fn liquidations(
125 &mut self,
126 request: impl tonic::IntoRequest<super::QueryLiquidationsRequest>,
127 ) -> core::result::Result<tonic::Response<super::QueryLiquidationsResponse>, tonic::Status>
128 {
129 self.inner.ready().await.map_err(|e| {
130 tonic::Status::new(
131 tonic::Code::Unknown,
132 alloc::format!("Service was not ready: {}", e.into()),
133 )
134 })?;
135 let codec = tonic::codec::ProstCodec::default();
136 let path = http::uri::PathAndQuery::from_static("/side.liquidation.Query/Liquidations");
137 let mut req = request.into_request();
138 req.extensions_mut()
139 .insert(GrpcMethod::new("side.liquidation.Query", "Liquidations"));
140 self.inner.unary(req, path, codec).await
141 }
142 pub async fn liquidation_record(
143 &mut self,
144 request: impl tonic::IntoRequest<super::QueryLiquidationRecordRequest>,
145 ) -> core::result::Result<
146 tonic::Response<super::QueryLiquidationRecordResponse>,
147 tonic::Status,
148 > {
149 self.inner.ready().await.map_err(|e| {
150 tonic::Status::new(
151 tonic::Code::Unknown,
152 alloc::format!("Service was not ready: {}", e.into()),
153 )
154 })?;
155 let codec = tonic::codec::ProstCodec::default();
156 let path =
157 http::uri::PathAndQuery::from_static("/side.liquidation.Query/LiquidationRecord");
158 let mut req = request.into_request();
159 req.extensions_mut().insert(GrpcMethod::new(
160 "side.liquidation.Query",
161 "LiquidationRecord",
162 ));
163 self.inner.unary(req, path, codec).await
164 }
165 pub async fn liquidation_records(
166 &mut self,
167 request: impl tonic::IntoRequest<super::QueryLiquidationRecordsRequest>,
168 ) -> core::result::Result<
169 tonic::Response<super::QueryLiquidationRecordsResponse>,
170 tonic::Status,
171 > {
172 self.inner.ready().await.map_err(|e| {
173 tonic::Status::new(
174 tonic::Code::Unknown,
175 alloc::format!("Service was not ready: {}", e.into()),
176 )
177 })?;
178 let codec = tonic::codec::ProstCodec::default();
179 let path =
180 http::uri::PathAndQuery::from_static("/side.liquidation.Query/LiquidationRecords");
181 let mut req = request.into_request();
182 req.extensions_mut().insert(GrpcMethod::new(
183 "side.liquidation.Query",
184 "LiquidationRecords",
185 ));
186 self.inner.unary(req, path, codec).await
187 }
188 }
189}
190#[cfg(feature = "grpc")]
192pub mod query_server {
193 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
194 use tonic::codegen::*;
195 #[async_trait]
197 pub trait Query: Send + Sync + 'static {
198 async fn params(
199 &self,
200 request: tonic::Request<super::QueryParamsRequest>,
201 ) -> core::result::Result<tonic::Response<super::QueryParamsResponse>, tonic::Status>;
202 async fn liquidation(
203 &self,
204 request: tonic::Request<super::QueryLiquidationRequest>,
205 ) -> core::result::Result<tonic::Response<super::QueryLiquidationResponse>, tonic::Status>;
206 async fn liquidations(
207 &self,
208 request: tonic::Request<super::QueryLiquidationsRequest>,
209 ) -> core::result::Result<tonic::Response<super::QueryLiquidationsResponse>, tonic::Status>;
210 async fn liquidation_record(
211 &self,
212 request: tonic::Request<super::QueryLiquidationRecordRequest>,
213 ) -> core::result::Result<
214 tonic::Response<super::QueryLiquidationRecordResponse>,
215 tonic::Status,
216 >;
217 async fn liquidation_records(
218 &self,
219 request: tonic::Request<super::QueryLiquidationRecordsRequest>,
220 ) -> core::result::Result<
221 tonic::Response<super::QueryLiquidationRecordsResponse>,
222 tonic::Status,
223 >;
224 }
225 #[derive(Debug)]
226 pub struct QueryServer<T: Query> {
227 inner: _Inner<T>,
228 accept_compression_encodings: EnabledCompressionEncodings,
229 send_compression_encodings: EnabledCompressionEncodings,
230 max_decoding_message_size: Option<usize>,
231 max_encoding_message_size: Option<usize>,
232 }
233 struct _Inner<T>(Arc<T>);
234 impl<T: Query> QueryServer<T> {
235 pub fn new(inner: T) -> Self {
236 Self::from_arc(Arc::new(inner))
237 }
238 pub fn from_arc(inner: Arc<T>) -> Self {
239 let inner = _Inner(inner);
240 Self {
241 inner,
242 accept_compression_encodings: Default::default(),
243 send_compression_encodings: Default::default(),
244 max_decoding_message_size: None,
245 max_encoding_message_size: None,
246 }
247 }
248 pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
249 where
250 F: tonic::service::Interceptor,
251 {
252 InterceptedService::new(Self::new(inner), interceptor)
253 }
254 #[must_use]
256 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
257 self.accept_compression_encodings.enable(encoding);
258 self
259 }
260 #[must_use]
262 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
263 self.send_compression_encodings.enable(encoding);
264 self
265 }
266 #[must_use]
270 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
271 self.max_decoding_message_size = Some(limit);
272 self
273 }
274 #[must_use]
278 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
279 self.max_encoding_message_size = Some(limit);
280 self
281 }
282 }
283 impl<T, B> tonic::codegen::Service<http::Request<B>> for QueryServer<T>
284 where
285 T: Query,
286 B: Body + Send + 'static,
287 B::Error: Into<StdError> + Send + 'static,
288 {
289 type Response = http::Response<tonic::body::BoxBody>;
290 type Error = std::convert::Infallible;
291 type Future = BoxFuture<Self::Response, Self::Error>;
292 fn poll_ready(
293 &mut self,
294 _cx: &mut Context<'_>,
295 ) -> Poll<core::result::Result<(), Self::Error>> {
296 Poll::Ready(Ok(()))
297 }
298 fn call(&mut self, req: http::Request<B>) -> Self::Future {
299 let inner = self.inner.clone();
300 match req.uri().path() {
301 "/side.liquidation.Query/Params" => {
302 #[allow(non_camel_case_types)]
303 struct ParamsSvc<T: Query>(pub Arc<T>);
304 impl<T: Query> tonic::server::UnaryService<super::QueryParamsRequest> for ParamsSvc<T> {
305 type Response = super::QueryParamsResponse;
306 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
307 fn call(
308 &mut self,
309 request: tonic::Request<super::QueryParamsRequest>,
310 ) -> Self::Future {
311 let inner = Arc::clone(&self.0);
312 let fut = async move { (*inner).params(request).await };
313 Box::pin(fut)
314 }
315 }
316 let accept_compression_encodings = self.accept_compression_encodings;
317 let send_compression_encodings = self.send_compression_encodings;
318 let max_decoding_message_size = self.max_decoding_message_size;
319 let max_encoding_message_size = self.max_encoding_message_size;
320 let inner = self.inner.clone();
321 let fut = async move {
322 let inner = inner.0;
323 let method = ParamsSvc(inner);
324 let codec = tonic::codec::ProstCodec::default();
325 let mut grpc = tonic::server::Grpc::new(codec)
326 .apply_compression_config(
327 accept_compression_encodings,
328 send_compression_encodings,
329 )
330 .apply_max_message_size_config(
331 max_decoding_message_size,
332 max_encoding_message_size,
333 );
334 let res = grpc.unary(method, req).await;
335 Ok(res)
336 };
337 Box::pin(fut)
338 }
339 "/side.liquidation.Query/Liquidation" => {
340 #[allow(non_camel_case_types)]
341 struct LiquidationSvc<T: Query>(pub Arc<T>);
342 impl<T: Query> tonic::server::UnaryService<super::QueryLiquidationRequest> for LiquidationSvc<T> {
343 type Response = super::QueryLiquidationResponse;
344 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
345 fn call(
346 &mut self,
347 request: tonic::Request<super::QueryLiquidationRequest>,
348 ) -> Self::Future {
349 let inner = Arc::clone(&self.0);
350 let fut = async move { (*inner).liquidation(request).await };
351 Box::pin(fut)
352 }
353 }
354 let accept_compression_encodings = self.accept_compression_encodings;
355 let send_compression_encodings = self.send_compression_encodings;
356 let max_decoding_message_size = self.max_decoding_message_size;
357 let max_encoding_message_size = self.max_encoding_message_size;
358 let inner = self.inner.clone();
359 let fut = async move {
360 let inner = inner.0;
361 let method = LiquidationSvc(inner);
362 let codec = tonic::codec::ProstCodec::default();
363 let mut grpc = tonic::server::Grpc::new(codec)
364 .apply_compression_config(
365 accept_compression_encodings,
366 send_compression_encodings,
367 )
368 .apply_max_message_size_config(
369 max_decoding_message_size,
370 max_encoding_message_size,
371 );
372 let res = grpc.unary(method, req).await;
373 Ok(res)
374 };
375 Box::pin(fut)
376 }
377 "/side.liquidation.Query/Liquidations" => {
378 #[allow(non_camel_case_types)]
379 struct LiquidationsSvc<T: Query>(pub Arc<T>);
380 impl<T: Query> tonic::server::UnaryService<super::QueryLiquidationsRequest> for LiquidationsSvc<T> {
381 type Response = super::QueryLiquidationsResponse;
382 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
383 fn call(
384 &mut self,
385 request: tonic::Request<super::QueryLiquidationsRequest>,
386 ) -> Self::Future {
387 let inner = Arc::clone(&self.0);
388 let fut = async move { (*inner).liquidations(request).await };
389 Box::pin(fut)
390 }
391 }
392 let accept_compression_encodings = self.accept_compression_encodings;
393 let send_compression_encodings = self.send_compression_encodings;
394 let max_decoding_message_size = self.max_decoding_message_size;
395 let max_encoding_message_size = self.max_encoding_message_size;
396 let inner = self.inner.clone();
397 let fut = async move {
398 let inner = inner.0;
399 let method = LiquidationsSvc(inner);
400 let codec = tonic::codec::ProstCodec::default();
401 let mut grpc = tonic::server::Grpc::new(codec)
402 .apply_compression_config(
403 accept_compression_encodings,
404 send_compression_encodings,
405 )
406 .apply_max_message_size_config(
407 max_decoding_message_size,
408 max_encoding_message_size,
409 );
410 let res = grpc.unary(method, req).await;
411 Ok(res)
412 };
413 Box::pin(fut)
414 }
415 "/side.liquidation.Query/LiquidationRecord" => {
416 #[allow(non_camel_case_types)]
417 struct LiquidationRecordSvc<T: Query>(pub Arc<T>);
418 impl<T: Query> tonic::server::UnaryService<super::QueryLiquidationRecordRequest>
419 for LiquidationRecordSvc<T>
420 {
421 type Response = super::QueryLiquidationRecordResponse;
422 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
423 fn call(
424 &mut self,
425 request: tonic::Request<super::QueryLiquidationRecordRequest>,
426 ) -> Self::Future {
427 let inner = Arc::clone(&self.0);
428 let fut = async move { (*inner).liquidation_record(request).await };
429 Box::pin(fut)
430 }
431 }
432 let accept_compression_encodings = self.accept_compression_encodings;
433 let send_compression_encodings = self.send_compression_encodings;
434 let max_decoding_message_size = self.max_decoding_message_size;
435 let max_encoding_message_size = self.max_encoding_message_size;
436 let inner = self.inner.clone();
437 let fut = async move {
438 let inner = inner.0;
439 let method = LiquidationRecordSvc(inner);
440 let codec = tonic::codec::ProstCodec::default();
441 let mut grpc = tonic::server::Grpc::new(codec)
442 .apply_compression_config(
443 accept_compression_encodings,
444 send_compression_encodings,
445 )
446 .apply_max_message_size_config(
447 max_decoding_message_size,
448 max_encoding_message_size,
449 );
450 let res = grpc.unary(method, req).await;
451 Ok(res)
452 };
453 Box::pin(fut)
454 }
455 "/side.liquidation.Query/LiquidationRecords" => {
456 #[allow(non_camel_case_types)]
457 struct LiquidationRecordsSvc<T: Query>(pub Arc<T>);
458 impl<T: Query>
459 tonic::server::UnaryService<super::QueryLiquidationRecordsRequest>
460 for LiquidationRecordsSvc<T>
461 {
462 type Response = super::QueryLiquidationRecordsResponse;
463 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
464 fn call(
465 &mut self,
466 request: tonic::Request<super::QueryLiquidationRecordsRequest>,
467 ) -> Self::Future {
468 let inner = Arc::clone(&self.0);
469 let fut = async move { (*inner).liquidation_records(request).await };
470 Box::pin(fut)
471 }
472 }
473 let accept_compression_encodings = self.accept_compression_encodings;
474 let send_compression_encodings = self.send_compression_encodings;
475 let max_decoding_message_size = self.max_decoding_message_size;
476 let max_encoding_message_size = self.max_encoding_message_size;
477 let inner = self.inner.clone();
478 let fut = async move {
479 let inner = inner.0;
480 let method = LiquidationRecordsSvc(inner);
481 let codec = tonic::codec::ProstCodec::default();
482 let mut grpc = tonic::server::Grpc::new(codec)
483 .apply_compression_config(
484 accept_compression_encodings,
485 send_compression_encodings,
486 )
487 .apply_max_message_size_config(
488 max_decoding_message_size,
489 max_encoding_message_size,
490 );
491 let res = grpc.unary(method, req).await;
492 Ok(res)
493 };
494 Box::pin(fut)
495 }
496 _ => Box::pin(async move {
497 Ok(http::Response::builder()
498 .status(200)
499 .header("grpc-status", "12")
500 .header("content-type", "application/grpc")
501 .body(empty_body())
502 .unwrap())
503 }),
504 }
505 }
506 }
507 impl<T: Query> Clone for QueryServer<T> {
508 fn clone(&self) -> Self {
509 let inner = self.inner.clone();
510 Self {
511 inner,
512 accept_compression_encodings: self.accept_compression_encodings,
513 send_compression_encodings: self.send_compression_encodings,
514 max_decoding_message_size: self.max_decoding_message_size,
515 max_encoding_message_size: self.max_encoding_message_size,
516 }
517 }
518 }
519 impl<T: Query> Clone for _Inner<T> {
520 fn clone(&self) -> Self {
521 Self(Arc::clone(&self.0))
522 }
523 }
524 impl<T: core::fmt::Debug> core::fmt::Debug for _Inner<T> {
525 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
526 write!(f, "{:?}", self.0)
527 }
528 }
529 impl<T: Query> tonic::server::NamedService for QueryServer<T> {
530 const NAME: &'static str = "side.liquidation.Query";
531 }
532}
533#[cfg(feature = "grpc")]
535pub mod msg_client {
536 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
537 use tonic::codegen::http::Uri;
538 use tonic::codegen::*;
539 #[derive(Debug, Clone)]
540 pub struct MsgClient<T> {
541 inner: tonic::client::Grpc<T>,
542 }
543 #[cfg(feature = "grpc-transport")]
544 impl MsgClient<tonic::transport::Channel> {
545 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
547 where
548 D: TryInto<tonic::transport::Endpoint>,
549 D::Error: Into<StdError>,
550 {
551 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
552 Ok(Self::new(conn))
553 }
554 }
555 impl<T> MsgClient<T>
556 where
557 T: tonic::client::GrpcService<tonic::body::BoxBody>,
558 T::Error: Into<StdError>,
559 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
560 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
561 {
562 pub fn new(inner: T) -> Self {
563 let inner = tonic::client::Grpc::new(inner);
564 Self { inner }
565 }
566 pub fn with_origin(inner: T, origin: Uri) -> Self {
567 let inner = tonic::client::Grpc::with_origin(inner, origin);
568 Self { inner }
569 }
570 pub fn with_interceptor<F>(inner: T, interceptor: F) -> MsgClient<InterceptedService<T, F>>
571 where
572 F: tonic::service::Interceptor,
573 T::ResponseBody: Default,
574 T: tonic::codegen::Service<
575 http::Request<tonic::body::BoxBody>,
576 Response = http::Response<
577 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
578 >,
579 >,
580 <T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error:
581 Into<StdError> + Send + Sync,
582 {
583 MsgClient::new(InterceptedService::new(inner, interceptor))
584 }
585 #[must_use]
590 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
591 self.inner = self.inner.send_compressed(encoding);
592 self
593 }
594 #[must_use]
596 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
597 self.inner = self.inner.accept_compressed(encoding);
598 self
599 }
600 #[must_use]
604 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
605 self.inner = self.inner.max_decoding_message_size(limit);
606 self
607 }
608 #[must_use]
612 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
613 self.inner = self.inner.max_encoding_message_size(limit);
614 self
615 }
616 pub async fn liquidate(
617 &mut self,
618 request: impl tonic::IntoRequest<super::MsgLiquidate>,
619 ) -> core::result::Result<tonic::Response<super::MsgLiquidateResponse>, tonic::Status>
620 {
621 self.inner.ready().await.map_err(|e| {
622 tonic::Status::new(
623 tonic::Code::Unknown,
624 alloc::format!("Service was not ready: {}", e.into()),
625 )
626 })?;
627 let codec = tonic::codec::ProstCodec::default();
628 let path = http::uri::PathAndQuery::from_static("/side.liquidation.Msg/Liquidate");
629 let mut req = request.into_request();
630 req.extensions_mut()
631 .insert(GrpcMethod::new("side.liquidation.Msg", "Liquidate"));
632 self.inner.unary(req, path, codec).await
633 }
634 pub async fn update_params(
635 &mut self,
636 request: impl tonic::IntoRequest<super::MsgUpdateParams>,
637 ) -> core::result::Result<tonic::Response<super::MsgUpdateParamsResponse>, tonic::Status>
638 {
639 self.inner.ready().await.map_err(|e| {
640 tonic::Status::new(
641 tonic::Code::Unknown,
642 alloc::format!("Service was not ready: {}", e.into()),
643 )
644 })?;
645 let codec = tonic::codec::ProstCodec::default();
646 let path = http::uri::PathAndQuery::from_static("/side.liquidation.Msg/UpdateParams");
647 let mut req = request.into_request();
648 req.extensions_mut()
649 .insert(GrpcMethod::new("side.liquidation.Msg", "UpdateParams"));
650 self.inner.unary(req, path, codec).await
651 }
652 }
653}
654#[cfg(feature = "grpc")]
656pub mod msg_server {
657 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
658 use tonic::codegen::*;
659 #[async_trait]
661 pub trait Msg: Send + Sync + 'static {
662 async fn liquidate(
663 &self,
664 request: tonic::Request<super::MsgLiquidate>,
665 ) -> core::result::Result<tonic::Response<super::MsgLiquidateResponse>, tonic::Status>;
666 async fn update_params(
667 &self,
668 request: tonic::Request<super::MsgUpdateParams>,
669 ) -> core::result::Result<tonic::Response<super::MsgUpdateParamsResponse>, tonic::Status>;
670 }
671 #[derive(Debug)]
672 pub struct MsgServer<T: Msg> {
673 inner: _Inner<T>,
674 accept_compression_encodings: EnabledCompressionEncodings,
675 send_compression_encodings: EnabledCompressionEncodings,
676 max_decoding_message_size: Option<usize>,
677 max_encoding_message_size: Option<usize>,
678 }
679 struct _Inner<T>(Arc<T>);
680 impl<T: Msg> MsgServer<T> {
681 pub fn new(inner: T) -> Self {
682 Self::from_arc(Arc::new(inner))
683 }
684 pub fn from_arc(inner: Arc<T>) -> Self {
685 let inner = _Inner(inner);
686 Self {
687 inner,
688 accept_compression_encodings: Default::default(),
689 send_compression_encodings: Default::default(),
690 max_decoding_message_size: None,
691 max_encoding_message_size: None,
692 }
693 }
694 pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
695 where
696 F: tonic::service::Interceptor,
697 {
698 InterceptedService::new(Self::new(inner), interceptor)
699 }
700 #[must_use]
702 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
703 self.accept_compression_encodings.enable(encoding);
704 self
705 }
706 #[must_use]
708 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
709 self.send_compression_encodings.enable(encoding);
710 self
711 }
712 #[must_use]
716 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
717 self.max_decoding_message_size = Some(limit);
718 self
719 }
720 #[must_use]
724 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
725 self.max_encoding_message_size = Some(limit);
726 self
727 }
728 }
729 impl<T, B> tonic::codegen::Service<http::Request<B>> for MsgServer<T>
730 where
731 T: Msg,
732 B: Body + Send + 'static,
733 B::Error: Into<StdError> + Send + 'static,
734 {
735 type Response = http::Response<tonic::body::BoxBody>;
736 type Error = std::convert::Infallible;
737 type Future = BoxFuture<Self::Response, Self::Error>;
738 fn poll_ready(
739 &mut self,
740 _cx: &mut Context<'_>,
741 ) -> Poll<core::result::Result<(), Self::Error>> {
742 Poll::Ready(Ok(()))
743 }
744 fn call(&mut self, req: http::Request<B>) -> Self::Future {
745 let inner = self.inner.clone();
746 match req.uri().path() {
747 "/side.liquidation.Msg/Liquidate" => {
748 #[allow(non_camel_case_types)]
749 struct LiquidateSvc<T: Msg>(pub Arc<T>);
750 impl<T: Msg> tonic::server::UnaryService<super::MsgLiquidate> for LiquidateSvc<T> {
751 type Response = super::MsgLiquidateResponse;
752 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
753 fn call(
754 &mut self,
755 request: tonic::Request<super::MsgLiquidate>,
756 ) -> Self::Future {
757 let inner = Arc::clone(&self.0);
758 let fut = async move { (*inner).liquidate(request).await };
759 Box::pin(fut)
760 }
761 }
762 let accept_compression_encodings = self.accept_compression_encodings;
763 let send_compression_encodings = self.send_compression_encodings;
764 let max_decoding_message_size = self.max_decoding_message_size;
765 let max_encoding_message_size = self.max_encoding_message_size;
766 let inner = self.inner.clone();
767 let fut = async move {
768 let inner = inner.0;
769 let method = LiquidateSvc(inner);
770 let codec = tonic::codec::ProstCodec::default();
771 let mut grpc = tonic::server::Grpc::new(codec)
772 .apply_compression_config(
773 accept_compression_encodings,
774 send_compression_encodings,
775 )
776 .apply_max_message_size_config(
777 max_decoding_message_size,
778 max_encoding_message_size,
779 );
780 let res = grpc.unary(method, req).await;
781 Ok(res)
782 };
783 Box::pin(fut)
784 }
785 "/side.liquidation.Msg/UpdateParams" => {
786 #[allow(non_camel_case_types)]
787 struct UpdateParamsSvc<T: Msg>(pub Arc<T>);
788 impl<T: Msg> tonic::server::UnaryService<super::MsgUpdateParams> for UpdateParamsSvc<T> {
789 type Response = super::MsgUpdateParamsResponse;
790 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
791 fn call(
792 &mut self,
793 request: tonic::Request<super::MsgUpdateParams>,
794 ) -> Self::Future {
795 let inner = Arc::clone(&self.0);
796 let fut = async move { (*inner).update_params(request).await };
797 Box::pin(fut)
798 }
799 }
800 let accept_compression_encodings = self.accept_compression_encodings;
801 let send_compression_encodings = self.send_compression_encodings;
802 let max_decoding_message_size = self.max_decoding_message_size;
803 let max_encoding_message_size = self.max_encoding_message_size;
804 let inner = self.inner.clone();
805 let fut = async move {
806 let inner = inner.0;
807 let method = UpdateParamsSvc(inner);
808 let codec = tonic::codec::ProstCodec::default();
809 let mut grpc = tonic::server::Grpc::new(codec)
810 .apply_compression_config(
811 accept_compression_encodings,
812 send_compression_encodings,
813 )
814 .apply_max_message_size_config(
815 max_decoding_message_size,
816 max_encoding_message_size,
817 );
818 let res = grpc.unary(method, req).await;
819 Ok(res)
820 };
821 Box::pin(fut)
822 }
823 _ => Box::pin(async move {
824 Ok(http::Response::builder()
825 .status(200)
826 .header("grpc-status", "12")
827 .header("content-type", "application/grpc")
828 .body(empty_body())
829 .unwrap())
830 }),
831 }
832 }
833 }
834 impl<T: Msg> Clone for MsgServer<T> {
835 fn clone(&self) -> Self {
836 let inner = self.inner.clone();
837 Self {
838 inner,
839 accept_compression_encodings: self.accept_compression_encodings,
840 send_compression_encodings: self.send_compression_encodings,
841 max_decoding_message_size: self.max_decoding_message_size,
842 max_encoding_message_size: self.max_encoding_message_size,
843 }
844 }
845 }
846 impl<T: Msg> Clone for _Inner<T> {
847 fn clone(&self) -> Self {
848 Self(Arc::clone(&self.0))
849 }
850 }
851 impl<T: core::fmt::Debug> core::fmt::Debug for _Inner<T> {
852 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
853 write!(f, "{:?}", self.0)
854 }
855 }
856 impl<T: Msg> tonic::server::NamedService for MsgServer<T> {
857 const NAME: &'static str = "side.liquidation.Msg";
858 }
859}