avalanche_proto/gen/
validatorstate.tonic.rs

1// @generated
2/// Generated client implementations.
3pub mod validator_state_client {
4    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
5    use tonic::codegen::*;
6    use tonic::codegen::http::Uri;
7    #[derive(Debug, Clone)]
8    pub struct ValidatorStateClient<T> {
9        inner: tonic::client::Grpc<T>,
10    }
11    impl ValidatorStateClient<tonic::transport::Channel> {
12        /// Attempt to create a new client by connecting to a given endpoint.
13        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
14        where
15            D: std::convert::TryInto<tonic::transport::Endpoint>,
16            D::Error: Into<StdError>,
17        {
18            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
19            Ok(Self::new(conn))
20        }
21    }
22    impl<T> ValidatorStateClient<T>
23    where
24        T: tonic::client::GrpcService<tonic::body::BoxBody>,
25        T::Error: Into<StdError>,
26        T::ResponseBody: Body<Data = Bytes> + Send + 'static,
27        <T::ResponseBody as Body>::Error: Into<StdError> + Send,
28    {
29        pub fn new(inner: T) -> Self {
30            let inner = tonic::client::Grpc::new(inner);
31            Self { inner }
32        }
33        pub fn with_origin(inner: T, origin: Uri) -> Self {
34            let inner = tonic::client::Grpc::with_origin(inner, origin);
35            Self { inner }
36        }
37        pub fn with_interceptor<F>(
38            inner: T,
39            interceptor: F,
40        ) -> ValidatorStateClient<InterceptedService<T, F>>
41        where
42            F: tonic::service::Interceptor,
43            T::ResponseBody: Default,
44            T: tonic::codegen::Service<
45                http::Request<tonic::body::BoxBody>,
46                Response = http::Response<
47                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
48                >,
49            >,
50            <T as tonic::codegen::Service<
51                http::Request<tonic::body::BoxBody>,
52            >>::Error: Into<StdError> + Send + Sync,
53        {
54            ValidatorStateClient::new(InterceptedService::new(inner, interceptor))
55        }
56        /// Compress requests with the given encoding.
57        ///
58        /// This requires the server to support it otherwise it might respond with an
59        /// error.
60        #[must_use]
61        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
62            self.inner = self.inner.send_compressed(encoding);
63            self
64        }
65        /// Enable decompressing responses.
66        #[must_use]
67        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
68            self.inner = self.inner.accept_compressed(encoding);
69            self
70        }
71        pub async fn get_minimum_height(
72            &mut self,
73            request: impl tonic::IntoRequest<super::super::google::protobuf::Empty>,
74        ) -> Result<tonic::Response<super::GetMinimumHeightResponse>, tonic::Status> {
75            self.inner
76                .ready()
77                .await
78                .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 = http::uri::PathAndQuery::from_static(
86                "/validatorstate.ValidatorState/GetMinimumHeight",
87            );
88            self.inner.unary(request.into_request(), path, codec).await
89        }
90        pub async fn get_current_height(
91            &mut self,
92            request: impl tonic::IntoRequest<super::super::google::protobuf::Empty>,
93        ) -> Result<tonic::Response<super::GetCurrentHeightResponse>, tonic::Status> {
94            self.inner
95                .ready()
96                .await
97                .map_err(|e| {
98                    tonic::Status::new(
99                        tonic::Code::Unknown,
100                        format!("Service was not ready: {}", e.into()),
101                    )
102                })?;
103            let codec = tonic::codec::ProstCodec::default();
104            let path = http::uri::PathAndQuery::from_static(
105                "/validatorstate.ValidatorState/GetCurrentHeight",
106            );
107            self.inner.unary(request.into_request(), path, codec).await
108        }
109        pub async fn get_validator_set(
110            &mut self,
111            request: impl tonic::IntoRequest<super::GetValidatorSetRequest>,
112        ) -> Result<tonic::Response<super::GetValidatorSetResponse>, tonic::Status> {
113            self.inner
114                .ready()
115                .await
116                .map_err(|e| {
117                    tonic::Status::new(
118                        tonic::Code::Unknown,
119                        format!("Service was not ready: {}", e.into()),
120                    )
121                })?;
122            let codec = tonic::codec::ProstCodec::default();
123            let path = http::uri::PathAndQuery::from_static(
124                "/validatorstate.ValidatorState/GetValidatorSet",
125            );
126            self.inner.unary(request.into_request(), path, codec).await
127        }
128    }
129}
130/// Generated server implementations.
131pub mod validator_state_server {
132    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
133    use tonic::codegen::*;
134    ///Generated trait containing gRPC methods that should be implemented for use with ValidatorStateServer.
135    #[async_trait]
136    pub trait ValidatorState: Send + Sync + 'static {
137        async fn get_minimum_height(
138            &self,
139            request: tonic::Request<super::super::google::protobuf::Empty>,
140        ) -> Result<tonic::Response<super::GetMinimumHeightResponse>, tonic::Status>;
141        async fn get_current_height(
142            &self,
143            request: tonic::Request<super::super::google::protobuf::Empty>,
144        ) -> Result<tonic::Response<super::GetCurrentHeightResponse>, tonic::Status>;
145        async fn get_validator_set(
146            &self,
147            request: tonic::Request<super::GetValidatorSetRequest>,
148        ) -> Result<tonic::Response<super::GetValidatorSetResponse>, tonic::Status>;
149    }
150    #[derive(Debug)]
151    pub struct ValidatorStateServer<T: ValidatorState> {
152        inner: _Inner<T>,
153        accept_compression_encodings: EnabledCompressionEncodings,
154        send_compression_encodings: EnabledCompressionEncodings,
155    }
156    struct _Inner<T>(Arc<T>);
157    impl<T: ValidatorState> ValidatorStateServer<T> {
158        pub fn new(inner: T) -> Self {
159            Self::from_arc(Arc::new(inner))
160        }
161        pub fn from_arc(inner: Arc<T>) -> Self {
162            let inner = _Inner(inner);
163            Self {
164                inner,
165                accept_compression_encodings: Default::default(),
166                send_compression_encodings: Default::default(),
167            }
168        }
169        pub fn with_interceptor<F>(
170            inner: T,
171            interceptor: F,
172        ) -> InterceptedService<Self, F>
173        where
174            F: tonic::service::Interceptor,
175        {
176            InterceptedService::new(Self::new(inner), interceptor)
177        }
178        /// Enable decompressing requests with the given encoding.
179        #[must_use]
180        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
181            self.accept_compression_encodings.enable(encoding);
182            self
183        }
184        /// Compress responses with the given encoding, if the client supports it.
185        #[must_use]
186        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
187            self.send_compression_encodings.enable(encoding);
188            self
189        }
190    }
191    impl<T, B> tonic::codegen::Service<http::Request<B>> for ValidatorStateServer<T>
192    where
193        T: ValidatorState,
194        B: Body + Send + 'static,
195        B::Error: Into<StdError> + Send + 'static,
196    {
197        type Response = http::Response<tonic::body::BoxBody>;
198        type Error = std::convert::Infallible;
199        type Future = BoxFuture<Self::Response, Self::Error>;
200        fn poll_ready(
201            &mut self,
202            _cx: &mut Context<'_>,
203        ) -> Poll<Result<(), Self::Error>> {
204            Poll::Ready(Ok(()))
205        }
206        fn call(&mut self, req: http::Request<B>) -> Self::Future {
207            let inner = self.inner.clone();
208            match req.uri().path() {
209                "/validatorstate.ValidatorState/GetMinimumHeight" => {
210                    #[allow(non_camel_case_types)]
211                    struct GetMinimumHeightSvc<T: ValidatorState>(pub Arc<T>);
212                    impl<
213                        T: ValidatorState,
214                    > tonic::server::UnaryService<super::super::google::protobuf::Empty>
215                    for GetMinimumHeightSvc<T> {
216                        type Response = super::GetMinimumHeightResponse;
217                        type Future = BoxFuture<
218                            tonic::Response<Self::Response>,
219                            tonic::Status,
220                        >;
221                        fn call(
222                            &mut self,
223                            request: tonic::Request<
224                                super::super::google::protobuf::Empty,
225                            >,
226                        ) -> Self::Future {
227                            let inner = self.0.clone();
228                            let fut = async move {
229                                (*inner).get_minimum_height(request).await
230                            };
231                            Box::pin(fut)
232                        }
233                    }
234                    let accept_compression_encodings = self.accept_compression_encodings;
235                    let send_compression_encodings = self.send_compression_encodings;
236                    let inner = self.inner.clone();
237                    let fut = async move {
238                        let inner = inner.0;
239                        let method = GetMinimumHeightSvc(inner);
240                        let codec = tonic::codec::ProstCodec::default();
241                        let mut grpc = tonic::server::Grpc::new(codec)
242                            .apply_compression_config(
243                                accept_compression_encodings,
244                                send_compression_encodings,
245                            );
246                        let res = grpc.unary(method, req).await;
247                        Ok(res)
248                    };
249                    Box::pin(fut)
250                }
251                "/validatorstate.ValidatorState/GetCurrentHeight" => {
252                    #[allow(non_camel_case_types)]
253                    struct GetCurrentHeightSvc<T: ValidatorState>(pub Arc<T>);
254                    impl<
255                        T: ValidatorState,
256                    > tonic::server::UnaryService<super::super::google::protobuf::Empty>
257                    for GetCurrentHeightSvc<T> {
258                        type Response = super::GetCurrentHeightResponse;
259                        type Future = BoxFuture<
260                            tonic::Response<Self::Response>,
261                            tonic::Status,
262                        >;
263                        fn call(
264                            &mut self,
265                            request: tonic::Request<
266                                super::super::google::protobuf::Empty,
267                            >,
268                        ) -> Self::Future {
269                            let inner = self.0.clone();
270                            let fut = async move {
271                                (*inner).get_current_height(request).await
272                            };
273                            Box::pin(fut)
274                        }
275                    }
276                    let accept_compression_encodings = self.accept_compression_encodings;
277                    let send_compression_encodings = self.send_compression_encodings;
278                    let inner = self.inner.clone();
279                    let fut = async move {
280                        let inner = inner.0;
281                        let method = GetCurrentHeightSvc(inner);
282                        let codec = tonic::codec::ProstCodec::default();
283                        let mut grpc = tonic::server::Grpc::new(codec)
284                            .apply_compression_config(
285                                accept_compression_encodings,
286                                send_compression_encodings,
287                            );
288                        let res = grpc.unary(method, req).await;
289                        Ok(res)
290                    };
291                    Box::pin(fut)
292                }
293                "/validatorstate.ValidatorState/GetValidatorSet" => {
294                    #[allow(non_camel_case_types)]
295                    struct GetValidatorSetSvc<T: ValidatorState>(pub Arc<T>);
296                    impl<
297                        T: ValidatorState,
298                    > tonic::server::UnaryService<super::GetValidatorSetRequest>
299                    for GetValidatorSetSvc<T> {
300                        type Response = super::GetValidatorSetResponse;
301                        type Future = BoxFuture<
302                            tonic::Response<Self::Response>,
303                            tonic::Status,
304                        >;
305                        fn call(
306                            &mut self,
307                            request: tonic::Request<super::GetValidatorSetRequest>,
308                        ) -> Self::Future {
309                            let inner = self.0.clone();
310                            let fut = async move {
311                                (*inner).get_validator_set(request).await
312                            };
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 inner = self.inner.clone();
319                    let fut = async move {
320                        let inner = inner.0;
321                        let method = GetValidatorSetSvc(inner);
322                        let codec = tonic::codec::ProstCodec::default();
323                        let mut grpc = tonic::server::Grpc::new(codec)
324                            .apply_compression_config(
325                                accept_compression_encodings,
326                                send_compression_encodings,
327                            );
328                        let res = grpc.unary(method, req).await;
329                        Ok(res)
330                    };
331                    Box::pin(fut)
332                }
333                _ => {
334                    Box::pin(async move {
335                        Ok(
336                            http::Response::builder()
337                                .status(200)
338                                .header("grpc-status", "12")
339                                .header("content-type", "application/grpc")
340                                .body(empty_body())
341                                .unwrap(),
342                        )
343                    })
344                }
345            }
346        }
347    }
348    impl<T: ValidatorState> Clone for ValidatorStateServer<T> {
349        fn clone(&self) -> Self {
350            let inner = self.inner.clone();
351            Self {
352                inner,
353                accept_compression_encodings: self.accept_compression_encodings,
354                send_compression_encodings: self.send_compression_encodings,
355            }
356        }
357    }
358    impl<T: ValidatorState> Clone for _Inner<T> {
359        fn clone(&self) -> Self {
360            Self(self.0.clone())
361        }
362    }
363    impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
364        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
365            write!(f, "{:?}", self.0)
366        }
367    }
368    impl<T: ValidatorState> tonic::server::NamedService for ValidatorStateServer<T> {
369        const NAME: &'static str = "validatorstate.ValidatorState";
370    }
371}