avalanche_proto/gen/
keystore.tonic.rs

1// @generated
2/// Generated client implementations.
3pub mod keystore_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 KeystoreClient<T> {
9        inner: tonic::client::Grpc<T>,
10    }
11    impl KeystoreClient<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> KeystoreClient<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        ) -> KeystoreClient<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            KeystoreClient::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_database(
72            &mut self,
73            request: impl tonic::IntoRequest<super::GetDatabaseRequest>,
74        ) -> Result<tonic::Response<super::GetDatabaseResponse>, 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                "/keystore.Keystore/GetDatabase",
87            );
88            self.inner.unary(request.into_request(), path, codec).await
89        }
90    }
91}
92/// Generated server implementations.
93pub mod keystore_server {
94    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
95    use tonic::codegen::*;
96    ///Generated trait containing gRPC methods that should be implemented for use with KeystoreServer.
97    #[async_trait]
98    pub trait Keystore: Send + Sync + 'static {
99        async fn get_database(
100            &self,
101            request: tonic::Request<super::GetDatabaseRequest>,
102        ) -> Result<tonic::Response<super::GetDatabaseResponse>, tonic::Status>;
103    }
104    #[derive(Debug)]
105    pub struct KeystoreServer<T: Keystore> {
106        inner: _Inner<T>,
107        accept_compression_encodings: EnabledCompressionEncodings,
108        send_compression_encodings: EnabledCompressionEncodings,
109    }
110    struct _Inner<T>(Arc<T>);
111    impl<T: Keystore> KeystoreServer<T> {
112        pub fn new(inner: T) -> Self {
113            Self::from_arc(Arc::new(inner))
114        }
115        pub fn from_arc(inner: Arc<T>) -> Self {
116            let inner = _Inner(inner);
117            Self {
118                inner,
119                accept_compression_encodings: Default::default(),
120                send_compression_encodings: Default::default(),
121            }
122        }
123        pub fn with_interceptor<F>(
124            inner: T,
125            interceptor: F,
126        ) -> InterceptedService<Self, F>
127        where
128            F: tonic::service::Interceptor,
129        {
130            InterceptedService::new(Self::new(inner), interceptor)
131        }
132        /// Enable decompressing requests with the given encoding.
133        #[must_use]
134        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
135            self.accept_compression_encodings.enable(encoding);
136            self
137        }
138        /// Compress responses with the given encoding, if the client supports it.
139        #[must_use]
140        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
141            self.send_compression_encodings.enable(encoding);
142            self
143        }
144    }
145    impl<T, B> tonic::codegen::Service<http::Request<B>> for KeystoreServer<T>
146    where
147        T: Keystore,
148        B: Body + Send + 'static,
149        B::Error: Into<StdError> + Send + 'static,
150    {
151        type Response = http::Response<tonic::body::BoxBody>;
152        type Error = std::convert::Infallible;
153        type Future = BoxFuture<Self::Response, Self::Error>;
154        fn poll_ready(
155            &mut self,
156            _cx: &mut Context<'_>,
157        ) -> Poll<Result<(), Self::Error>> {
158            Poll::Ready(Ok(()))
159        }
160        fn call(&mut self, req: http::Request<B>) -> Self::Future {
161            let inner = self.inner.clone();
162            match req.uri().path() {
163                "/keystore.Keystore/GetDatabase" => {
164                    #[allow(non_camel_case_types)]
165                    struct GetDatabaseSvc<T: Keystore>(pub Arc<T>);
166                    impl<
167                        T: Keystore,
168                    > tonic::server::UnaryService<super::GetDatabaseRequest>
169                    for GetDatabaseSvc<T> {
170                        type Response = super::GetDatabaseResponse;
171                        type Future = BoxFuture<
172                            tonic::Response<Self::Response>,
173                            tonic::Status,
174                        >;
175                        fn call(
176                            &mut self,
177                            request: tonic::Request<super::GetDatabaseRequest>,
178                        ) -> Self::Future {
179                            let inner = self.0.clone();
180                            let fut = async move {
181                                (*inner).get_database(request).await
182                            };
183                            Box::pin(fut)
184                        }
185                    }
186                    let accept_compression_encodings = self.accept_compression_encodings;
187                    let send_compression_encodings = self.send_compression_encodings;
188                    let inner = self.inner.clone();
189                    let fut = async move {
190                        let inner = inner.0;
191                        let method = GetDatabaseSvc(inner);
192                        let codec = tonic::codec::ProstCodec::default();
193                        let mut grpc = tonic::server::Grpc::new(codec)
194                            .apply_compression_config(
195                                accept_compression_encodings,
196                                send_compression_encodings,
197                            );
198                        let res = grpc.unary(method, req).await;
199                        Ok(res)
200                    };
201                    Box::pin(fut)
202                }
203                _ => {
204                    Box::pin(async move {
205                        Ok(
206                            http::Response::builder()
207                                .status(200)
208                                .header("grpc-status", "12")
209                                .header("content-type", "application/grpc")
210                                .body(empty_body())
211                                .unwrap(),
212                        )
213                    })
214                }
215            }
216        }
217    }
218    impl<T: Keystore> Clone for KeystoreServer<T> {
219        fn clone(&self) -> Self {
220            let inner = self.inner.clone();
221            Self {
222                inner,
223                accept_compression_encodings: self.accept_compression_encodings,
224                send_compression_encodings: self.send_compression_encodings,
225            }
226        }
227    }
228    impl<T: Keystore> Clone for _Inner<T> {
229        fn clone(&self) -> Self {
230            Self(self.0.clone())
231        }
232    }
233    impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
234        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
235            write!(f, "{:?}", self.0)
236        }
237    }
238    impl<T: Keystore> tonic::server::NamedService for KeystoreServer<T> {
239        const NAME: &'static str = "keystore.Keystore";
240    }
241}