avalanche_proto/gen/
aliasreader.tonic.rs

1// @generated
2/// Generated client implementations.
3pub mod alias_reader_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 AliasReaderClient<T> {
9        inner: tonic::client::Grpc<T>,
10    }
11    impl AliasReaderClient<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> AliasReaderClient<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        ) -> AliasReaderClient<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            AliasReaderClient::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 lookup(
72            &mut self,
73            request: impl tonic::IntoRequest<super::Alias>,
74        ) -> Result<tonic::Response<super::Id>, 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                "/aliasreader.AliasReader/Lookup",
87            );
88            self.inner.unary(request.into_request(), path, codec).await
89        }
90        pub async fn primary_alias(
91            &mut self,
92            request: impl tonic::IntoRequest<super::Id>,
93        ) -> Result<tonic::Response<super::Alias>, 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                "/aliasreader.AliasReader/PrimaryAlias",
106            );
107            self.inner.unary(request.into_request(), path, codec).await
108        }
109        pub async fn aliases(
110            &mut self,
111            request: impl tonic::IntoRequest<super::Id>,
112        ) -> Result<tonic::Response<super::AliasList>, 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                "/aliasreader.AliasReader/Aliases",
125            );
126            self.inner.unary(request.into_request(), path, codec).await
127        }
128    }
129}
130/// Generated server implementations.
131pub mod alias_reader_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 AliasReaderServer.
135    #[async_trait]
136    pub trait AliasReader: Send + Sync + 'static {
137        async fn lookup(
138            &self,
139            request: tonic::Request<super::Alias>,
140        ) -> Result<tonic::Response<super::Id>, tonic::Status>;
141        async fn primary_alias(
142            &self,
143            request: tonic::Request<super::Id>,
144        ) -> Result<tonic::Response<super::Alias>, tonic::Status>;
145        async fn aliases(
146            &self,
147            request: tonic::Request<super::Id>,
148        ) -> Result<tonic::Response<super::AliasList>, tonic::Status>;
149    }
150    #[derive(Debug)]
151    pub struct AliasReaderServer<T: AliasReader> {
152        inner: _Inner<T>,
153        accept_compression_encodings: EnabledCompressionEncodings,
154        send_compression_encodings: EnabledCompressionEncodings,
155    }
156    struct _Inner<T>(Arc<T>);
157    impl<T: AliasReader> AliasReaderServer<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 AliasReaderServer<T>
192    where
193        T: AliasReader,
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                "/aliasreader.AliasReader/Lookup" => {
210                    #[allow(non_camel_case_types)]
211                    struct LookupSvc<T: AliasReader>(pub Arc<T>);
212                    impl<T: AliasReader> tonic::server::UnaryService<super::Alias>
213                    for LookupSvc<T> {
214                        type Response = super::Id;
215                        type Future = BoxFuture<
216                            tonic::Response<Self::Response>,
217                            tonic::Status,
218                        >;
219                        fn call(
220                            &mut self,
221                            request: tonic::Request<super::Alias>,
222                        ) -> Self::Future {
223                            let inner = self.0.clone();
224                            let fut = async move { (*inner).lookup(request).await };
225                            Box::pin(fut)
226                        }
227                    }
228                    let accept_compression_encodings = self.accept_compression_encodings;
229                    let send_compression_encodings = self.send_compression_encodings;
230                    let inner = self.inner.clone();
231                    let fut = async move {
232                        let inner = inner.0;
233                        let method = LookupSvc(inner);
234                        let codec = tonic::codec::ProstCodec::default();
235                        let mut grpc = tonic::server::Grpc::new(codec)
236                            .apply_compression_config(
237                                accept_compression_encodings,
238                                send_compression_encodings,
239                            );
240                        let res = grpc.unary(method, req).await;
241                        Ok(res)
242                    };
243                    Box::pin(fut)
244                }
245                "/aliasreader.AliasReader/PrimaryAlias" => {
246                    #[allow(non_camel_case_types)]
247                    struct PrimaryAliasSvc<T: AliasReader>(pub Arc<T>);
248                    impl<T: AliasReader> tonic::server::UnaryService<super::Id>
249                    for PrimaryAliasSvc<T> {
250                        type Response = super::Alias;
251                        type Future = BoxFuture<
252                            tonic::Response<Self::Response>,
253                            tonic::Status,
254                        >;
255                        fn call(
256                            &mut self,
257                            request: tonic::Request<super::Id>,
258                        ) -> Self::Future {
259                            let inner = self.0.clone();
260                            let fut = async move {
261                                (*inner).primary_alias(request).await
262                            };
263                            Box::pin(fut)
264                        }
265                    }
266                    let accept_compression_encodings = self.accept_compression_encodings;
267                    let send_compression_encodings = self.send_compression_encodings;
268                    let inner = self.inner.clone();
269                    let fut = async move {
270                        let inner = inner.0;
271                        let method = PrimaryAliasSvc(inner);
272                        let codec = tonic::codec::ProstCodec::default();
273                        let mut grpc = tonic::server::Grpc::new(codec)
274                            .apply_compression_config(
275                                accept_compression_encodings,
276                                send_compression_encodings,
277                            );
278                        let res = grpc.unary(method, req).await;
279                        Ok(res)
280                    };
281                    Box::pin(fut)
282                }
283                "/aliasreader.AliasReader/Aliases" => {
284                    #[allow(non_camel_case_types)]
285                    struct AliasesSvc<T: AliasReader>(pub Arc<T>);
286                    impl<T: AliasReader> tonic::server::UnaryService<super::Id>
287                    for AliasesSvc<T> {
288                        type Response = super::AliasList;
289                        type Future = BoxFuture<
290                            tonic::Response<Self::Response>,
291                            tonic::Status,
292                        >;
293                        fn call(
294                            &mut self,
295                            request: tonic::Request<super::Id>,
296                        ) -> Self::Future {
297                            let inner = self.0.clone();
298                            let fut = async move { (*inner).aliases(request).await };
299                            Box::pin(fut)
300                        }
301                    }
302                    let accept_compression_encodings = self.accept_compression_encodings;
303                    let send_compression_encodings = self.send_compression_encodings;
304                    let inner = self.inner.clone();
305                    let fut = async move {
306                        let inner = inner.0;
307                        let method = AliasesSvc(inner);
308                        let codec = tonic::codec::ProstCodec::default();
309                        let mut grpc = tonic::server::Grpc::new(codec)
310                            .apply_compression_config(
311                                accept_compression_encodings,
312                                send_compression_encodings,
313                            );
314                        let res = grpc.unary(method, req).await;
315                        Ok(res)
316                    };
317                    Box::pin(fut)
318                }
319                _ => {
320                    Box::pin(async move {
321                        Ok(
322                            http::Response::builder()
323                                .status(200)
324                                .header("grpc-status", "12")
325                                .header("content-type", "application/grpc")
326                                .body(empty_body())
327                                .unwrap(),
328                        )
329                    })
330                }
331            }
332        }
333    }
334    impl<T: AliasReader> Clone for AliasReaderServer<T> {
335        fn clone(&self) -> Self {
336            let inner = self.inner.clone();
337            Self {
338                inner,
339                accept_compression_encodings: self.accept_compression_encodings,
340                send_compression_encodings: self.send_compression_encodings,
341            }
342        }
343    }
344    impl<T: AliasReader> Clone for _Inner<T> {
345        fn clone(&self) -> Self {
346            Self(self.0.clone())
347        }
348    }
349    impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
350        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
351            write!(f, "{:?}", self.0)
352        }
353    }
354    impl<T: AliasReader> tonic::server::NamedService for AliasReaderServer<T> {
355        const NAME: &'static str = "aliasreader.AliasReader";
356    }
357}