tendermint_proto/prost/v0_37/
tendermint.rpc.grpc.rs

1// This file is @generated by prost-build.
2#[allow(clippy::derive_partial_eq_without_eq)]
3#[derive(Clone, Copy, PartialEq, ::prost::Message)]
4pub struct RequestPing {}
5#[allow(clippy::derive_partial_eq_without_eq)]
6#[derive(Clone, PartialEq, ::prost::Message)]
7pub struct RequestBroadcastTx {
8    #[prost(bytes = "vec", tag = "1")]
9    pub tx: ::prost::alloc::vec::Vec<u8>,
10}
11#[allow(clippy::derive_partial_eq_without_eq)]
12#[derive(Clone, Copy, PartialEq, ::prost::Message)]
13pub struct ResponsePing {}
14#[allow(clippy::derive_partial_eq_without_eq)]
15#[derive(Clone, PartialEq, ::prost::Message)]
16pub struct ResponseBroadcastTx {
17    #[prost(message, optional, tag = "1")]
18    pub check_tx: ::core::option::Option<super::super::abci::ResponseCheckTx>,
19    #[prost(message, optional, tag = "2")]
20    pub deliver_tx: ::core::option::Option<super::super::abci::ResponseDeliverTx>,
21}
22/// Generated server implementations.
23#[cfg(feature = "grpc-server")]
24pub mod broadcast_api_server {
25    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
26    use tonic::codegen::*;
27    /// Generated trait containing gRPC methods that should be implemented for use with BroadcastApiServer.
28    #[async_trait]
29    pub trait BroadcastApi: Send + Sync + 'static {
30        async fn ping(
31            &self,
32            request: tonic::Request<super::RequestPing>,
33        ) -> std::result::Result<tonic::Response<super::ResponsePing>, tonic::Status>;
34        async fn broadcast_tx(
35            &self,
36            request: tonic::Request<super::RequestBroadcastTx>,
37        ) -> std::result::Result<
38            tonic::Response<super::ResponseBroadcastTx>,
39            tonic::Status,
40        >;
41    }
42    #[derive(Debug)]
43    pub struct BroadcastApiServer<T: BroadcastApi> {
44        inner: Arc<T>,
45        accept_compression_encodings: EnabledCompressionEncodings,
46        send_compression_encodings: EnabledCompressionEncodings,
47        max_decoding_message_size: Option<usize>,
48        max_encoding_message_size: Option<usize>,
49    }
50    impl<T: BroadcastApi> BroadcastApiServer<T> {
51        pub fn new(inner: T) -> Self {
52            Self::from_arc(Arc::new(inner))
53        }
54        pub fn from_arc(inner: Arc<T>) -> Self {
55            Self {
56                inner,
57                accept_compression_encodings: Default::default(),
58                send_compression_encodings: Default::default(),
59                max_decoding_message_size: None,
60                max_encoding_message_size: None,
61            }
62        }
63        pub fn with_interceptor<F>(
64            inner: T,
65            interceptor: F,
66        ) -> InterceptedService<Self, F>
67        where
68            F: tonic::service::Interceptor,
69        {
70            InterceptedService::new(Self::new(inner), interceptor)
71        }
72        /// Enable decompressing requests with the given encoding.
73        #[must_use]
74        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
75            self.accept_compression_encodings.enable(encoding);
76            self
77        }
78        /// Compress responses with the given encoding, if the client supports it.
79        #[must_use]
80        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
81            self.send_compression_encodings.enable(encoding);
82            self
83        }
84        /// Limits the maximum size of a decoded message.
85        ///
86        /// Default: `4MB`
87        #[must_use]
88        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
89            self.max_decoding_message_size = Some(limit);
90            self
91        }
92        /// Limits the maximum size of an encoded message.
93        ///
94        /// Default: `usize::MAX`
95        #[must_use]
96        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
97            self.max_encoding_message_size = Some(limit);
98            self
99        }
100    }
101    impl<T, B> tonic::codegen::Service<http::Request<B>> for BroadcastApiServer<T>
102    where
103        T: BroadcastApi,
104        B: Body + Send + 'static,
105        B::Error: Into<StdError> + Send + 'static,
106    {
107        type Response = http::Response<tonic::body::BoxBody>;
108        type Error = std::convert::Infallible;
109        type Future = BoxFuture<Self::Response, Self::Error>;
110        fn poll_ready(
111            &mut self,
112            _cx: &mut Context<'_>,
113        ) -> Poll<std::result::Result<(), Self::Error>> {
114            Poll::Ready(Ok(()))
115        }
116        fn call(&mut self, req: http::Request<B>) -> Self::Future {
117            match req.uri().path() {
118                "/tendermint.rpc.grpc.BroadcastAPI/Ping" => {
119                    #[allow(non_camel_case_types)]
120                    struct PingSvc<T: BroadcastApi>(pub Arc<T>);
121                    impl<T: BroadcastApi> tonic::server::UnaryService<super::RequestPing>
122                    for PingSvc<T> {
123                        type Response = super::ResponsePing;
124                        type Future = BoxFuture<
125                            tonic::Response<Self::Response>,
126                            tonic::Status,
127                        >;
128                        fn call(
129                            &mut self,
130                            request: tonic::Request<super::RequestPing>,
131                        ) -> Self::Future {
132                            let inner = Arc::clone(&self.0);
133                            let fut = async move {
134                                <T as BroadcastApi>::ping(&inner, request).await
135                            };
136                            Box::pin(fut)
137                        }
138                    }
139                    let accept_compression_encodings = self.accept_compression_encodings;
140                    let send_compression_encodings = self.send_compression_encodings;
141                    let max_decoding_message_size = self.max_decoding_message_size;
142                    let max_encoding_message_size = self.max_encoding_message_size;
143                    let inner = self.inner.clone();
144                    let fut = async move {
145                        let method = PingSvc(inner);
146                        let codec = tonic::codec::ProstCodec::default();
147                        let mut grpc = tonic::server::Grpc::new(codec)
148                            .apply_compression_config(
149                                accept_compression_encodings,
150                                send_compression_encodings,
151                            )
152                            .apply_max_message_size_config(
153                                max_decoding_message_size,
154                                max_encoding_message_size,
155                            );
156                        let res = grpc.unary(method, req).await;
157                        Ok(res)
158                    };
159                    Box::pin(fut)
160                }
161                "/tendermint.rpc.grpc.BroadcastAPI/BroadcastTx" => {
162                    #[allow(non_camel_case_types)]
163                    struct BroadcastTxSvc<T: BroadcastApi>(pub Arc<T>);
164                    impl<
165                        T: BroadcastApi,
166                    > tonic::server::UnaryService<super::RequestBroadcastTx>
167                    for BroadcastTxSvc<T> {
168                        type Response = super::ResponseBroadcastTx;
169                        type Future = BoxFuture<
170                            tonic::Response<Self::Response>,
171                            tonic::Status,
172                        >;
173                        fn call(
174                            &mut self,
175                            request: tonic::Request<super::RequestBroadcastTx>,
176                        ) -> Self::Future {
177                            let inner = Arc::clone(&self.0);
178                            let fut = async move {
179                                <T as BroadcastApi>::broadcast_tx(&inner, request).await
180                            };
181                            Box::pin(fut)
182                        }
183                    }
184                    let accept_compression_encodings = self.accept_compression_encodings;
185                    let send_compression_encodings = self.send_compression_encodings;
186                    let max_decoding_message_size = self.max_decoding_message_size;
187                    let max_encoding_message_size = self.max_encoding_message_size;
188                    let inner = self.inner.clone();
189                    let fut = async move {
190                        let method = BroadcastTxSvc(inner);
191                        let codec = tonic::codec::ProstCodec::default();
192                        let mut grpc = tonic::server::Grpc::new(codec)
193                            .apply_compression_config(
194                                accept_compression_encodings,
195                                send_compression_encodings,
196                            )
197                            .apply_max_message_size_config(
198                                max_decoding_message_size,
199                                max_encoding_message_size,
200                            );
201                        let res = grpc.unary(method, req).await;
202                        Ok(res)
203                    };
204                    Box::pin(fut)
205                }
206                _ => {
207                    Box::pin(async move {
208                        Ok(
209                            http::Response::builder()
210                                .status(200)
211                                .header("grpc-status", tonic::Code::Unimplemented as i32)
212                                .header(
213                                    http::header::CONTENT_TYPE,
214                                    tonic::metadata::GRPC_CONTENT_TYPE,
215                                )
216                                .body(empty_body())
217                                .unwrap(),
218                        )
219                    })
220                }
221            }
222        }
223    }
224    impl<T: BroadcastApi> Clone for BroadcastApiServer<T> {
225        fn clone(&self) -> Self {
226            let inner = self.inner.clone();
227            Self {
228                inner,
229                accept_compression_encodings: self.accept_compression_encodings,
230                send_compression_encodings: self.send_compression_encodings,
231                max_decoding_message_size: self.max_decoding_message_size,
232                max_encoding_message_size: self.max_encoding_message_size,
233            }
234        }
235    }
236    impl<T: BroadcastApi> tonic::server::NamedService for BroadcastApiServer<T> {
237        const NAME: &'static str = "tendermint.rpc.grpc.BroadcastAPI";
238    }
239}