cerberus_api/generated/
keymanager.v1.rs

1#[allow(clippy::derive_partial_eq_without_eq)]
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct GenerateKeyPairRequest {
4    /// Password to encrypt the private key
5    /// This will be only used if the keystore is local filesystem based
6    #[prost(string, tag = "1")]
7    pub password: ::prost::alloc::string::String,
8}
9#[allow(clippy::derive_partial_eq_without_eq)]
10#[derive(Clone, PartialEq, ::prost::Message)]
11pub struct GenerateKeyPairResponse {
12    /// Public key hex of the generated keypair
13    #[prost(string, tag = "1")]
14    pub public_key: ::prost::alloc::string::String,
15    /// Private key hex of the generated keypair
16    #[prost(string, tag = "2")]
17    pub private_key: ::prost::alloc::string::String,
18    /// Mnemonic of the generated keypair
19    #[prost(string, tag = "3")]
20    pub mnemonic: ::prost::alloc::string::String,
21}
22#[allow(clippy::derive_partial_eq_without_eq)]
23#[derive(Clone, PartialEq, ::prost::Message)]
24pub struct ImportKeyRequest {
25    /// Plaintext hex private key of the keypair or BigInteger
26    #[prost(string, tag = "1")]
27    pub private_key: ::prost::alloc::string::String,
28    /// Mnemonic of the keypair to import. One of private_key or mnemonic should be provided
29    #[prost(string, tag = "2")]
30    pub mnemonic: ::prost::alloc::string::String,
31    /// Password to encrypt the private key
32    #[prost(string, tag = "3")]
33    pub password: ::prost::alloc::string::String,
34}
35#[allow(clippy::derive_partial_eq_without_eq)]
36#[derive(Clone, PartialEq, ::prost::Message)]
37pub struct ImportKeyResponse {
38    /// Public key hex of the imported keypair
39    #[prost(string, tag = "1")]
40    pub public_key: ::prost::alloc::string::String,
41}
42#[allow(clippy::derive_partial_eq_without_eq)]
43#[derive(Clone, PartialEq, ::prost::Message)]
44pub struct ListKeysRequest {}
45#[allow(clippy::derive_partial_eq_without_eq)]
46#[derive(Clone, PartialEq, ::prost::Message)]
47pub struct ListKeysResponse {
48    /// List of public keys
49    #[prost(string, repeated, tag = "1")]
50    pub public_keys: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
51}
52/// Generated client implementations.
53pub mod key_manager_client {
54    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
55    use tonic::codegen::*;
56    use tonic::codegen::http::Uri;
57    #[derive(Debug, Clone)]
58    pub struct KeyManagerClient<T> {
59        inner: tonic::client::Grpc<T>,
60    }
61    impl KeyManagerClient<tonic::transport::Channel> {
62        /// Attempt to create a new client by connecting to a given endpoint.
63        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
64        where
65            D: TryInto<tonic::transport::Endpoint>,
66            D::Error: Into<StdError>,
67        {
68            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
69            Ok(Self::new(conn))
70        }
71    }
72    impl<T> KeyManagerClient<T>
73    where
74        T: tonic::client::GrpcService<tonic::body::BoxBody>,
75        T::Error: Into<StdError>,
76        T::ResponseBody: Body<Data = Bytes> + Send + 'static,
77        <T::ResponseBody as Body>::Error: Into<StdError> + Send,
78    {
79        pub fn new(inner: T) -> Self {
80            let inner = tonic::client::Grpc::new(inner);
81            Self { inner }
82        }
83        pub fn with_origin(inner: T, origin: Uri) -> Self {
84            let inner = tonic::client::Grpc::with_origin(inner, origin);
85            Self { inner }
86        }
87        pub fn with_interceptor<F>(
88            inner: T,
89            interceptor: F,
90        ) -> KeyManagerClient<InterceptedService<T, F>>
91        where
92            F: tonic::service::Interceptor,
93            T::ResponseBody: Default,
94            T: tonic::codegen::Service<
95                http::Request<tonic::body::BoxBody>,
96                Response = http::Response<
97                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
98                >,
99            >,
100            <T as tonic::codegen::Service<
101                http::Request<tonic::body::BoxBody>,
102            >>::Error: Into<StdError> + Send + Sync,
103        {
104            KeyManagerClient::new(InterceptedService::new(inner, interceptor))
105        }
106        /// Compress requests with the given encoding.
107        ///
108        /// This requires the server to support it otherwise it might respond with an
109        /// error.
110        #[must_use]
111        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
112            self.inner = self.inner.send_compressed(encoding);
113            self
114        }
115        /// Enable decompressing responses.
116        #[must_use]
117        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
118            self.inner = self.inner.accept_compressed(encoding);
119            self
120        }
121        /// Limits the maximum size of a decoded message.
122        ///
123        /// Default: `4MB`
124        #[must_use]
125        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
126            self.inner = self.inner.max_decoding_message_size(limit);
127            self
128        }
129        /// Limits the maximum size of an encoded message.
130        ///
131        /// Default: `usize::MAX`
132        #[must_use]
133        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
134            self.inner = self.inner.max_encoding_message_size(limit);
135            self
136        }
137        pub async fn generate_key_pair(
138            &mut self,
139            request: impl tonic::IntoRequest<super::GenerateKeyPairRequest>,
140        ) -> std::result::Result<
141            tonic::Response<super::GenerateKeyPairResponse>,
142            tonic::Status,
143        > {
144            self.inner
145                .ready()
146                .await
147                .map_err(|e| {
148                    tonic::Status::new(
149                        tonic::Code::Unknown,
150                        format!("Service was not ready: {}", e.into()),
151                    )
152                })?;
153            let codec = tonic::codec::ProstCodec::default();
154            let path = http::uri::PathAndQuery::from_static(
155                "/keymanager.v1.KeyManager/GenerateKeyPair",
156            );
157            let mut req = request.into_request();
158            req.extensions_mut()
159                .insert(GrpcMethod::new("keymanager.v1.KeyManager", "GenerateKeyPair"));
160            self.inner.unary(req, path, codec).await
161        }
162        pub async fn import_key(
163            &mut self,
164            request: impl tonic::IntoRequest<super::ImportKeyRequest>,
165        ) -> std::result::Result<
166            tonic::Response<super::ImportKeyResponse>,
167            tonic::Status,
168        > {
169            self.inner
170                .ready()
171                .await
172                .map_err(|e| {
173                    tonic::Status::new(
174                        tonic::Code::Unknown,
175                        format!("Service was not ready: {}", e.into()),
176                    )
177                })?;
178            let codec = tonic::codec::ProstCodec::default();
179            let path = http::uri::PathAndQuery::from_static(
180                "/keymanager.v1.KeyManager/ImportKey",
181            );
182            let mut req = request.into_request();
183            req.extensions_mut()
184                .insert(GrpcMethod::new("keymanager.v1.KeyManager", "ImportKey"));
185            self.inner.unary(req, path, codec).await
186        }
187        pub async fn list_keys(
188            &mut self,
189            request: impl tonic::IntoRequest<super::ListKeysRequest>,
190        ) -> std::result::Result<
191            tonic::Response<super::ListKeysResponse>,
192            tonic::Status,
193        > {
194            self.inner
195                .ready()
196                .await
197                .map_err(|e| {
198                    tonic::Status::new(
199                        tonic::Code::Unknown,
200                        format!("Service was not ready: {}", e.into()),
201                    )
202                })?;
203            let codec = tonic::codec::ProstCodec::default();
204            let path = http::uri::PathAndQuery::from_static(
205                "/keymanager.v1.KeyManager/ListKeys",
206            );
207            let mut req = request.into_request();
208            req.extensions_mut()
209                .insert(GrpcMethod::new("keymanager.v1.KeyManager", "ListKeys"));
210            self.inner.unary(req, path, codec).await
211        }
212    }
213}
214/// Generated server implementations.
215pub mod key_manager_server {
216    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
217    use tonic::codegen::*;
218    /// Generated trait containing gRPC methods that should be implemented for use with KeyManagerServer.
219    #[async_trait]
220    pub trait KeyManager: Send + Sync + 'static {
221        async fn generate_key_pair(
222            &self,
223            request: tonic::Request<super::GenerateKeyPairRequest>,
224        ) -> std::result::Result<
225            tonic::Response<super::GenerateKeyPairResponse>,
226            tonic::Status,
227        >;
228        async fn import_key(
229            &self,
230            request: tonic::Request<super::ImportKeyRequest>,
231        ) -> std::result::Result<
232            tonic::Response<super::ImportKeyResponse>,
233            tonic::Status,
234        >;
235        async fn list_keys(
236            &self,
237            request: tonic::Request<super::ListKeysRequest>,
238        ) -> std::result::Result<
239            tonic::Response<super::ListKeysResponse>,
240            tonic::Status,
241        >;
242    }
243    #[derive(Debug)]
244    pub struct KeyManagerServer<T: KeyManager> {
245        inner: _Inner<T>,
246        accept_compression_encodings: EnabledCompressionEncodings,
247        send_compression_encodings: EnabledCompressionEncodings,
248        max_decoding_message_size: Option<usize>,
249        max_encoding_message_size: Option<usize>,
250    }
251    struct _Inner<T>(Arc<T>);
252    impl<T: KeyManager> KeyManagerServer<T> {
253        pub fn new(inner: T) -> Self {
254            Self::from_arc(Arc::new(inner))
255        }
256        pub fn from_arc(inner: Arc<T>) -> Self {
257            let inner = _Inner(inner);
258            Self {
259                inner,
260                accept_compression_encodings: Default::default(),
261                send_compression_encodings: Default::default(),
262                max_decoding_message_size: None,
263                max_encoding_message_size: None,
264            }
265        }
266        pub fn with_interceptor<F>(
267            inner: T,
268            interceptor: F,
269        ) -> InterceptedService<Self, F>
270        where
271            F: tonic::service::Interceptor,
272        {
273            InterceptedService::new(Self::new(inner), interceptor)
274        }
275        /// Enable decompressing requests with the given encoding.
276        #[must_use]
277        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
278            self.accept_compression_encodings.enable(encoding);
279            self
280        }
281        /// Compress responses with the given encoding, if the client supports it.
282        #[must_use]
283        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
284            self.send_compression_encodings.enable(encoding);
285            self
286        }
287        /// Limits the maximum size of a decoded message.
288        ///
289        /// Default: `4MB`
290        #[must_use]
291        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
292            self.max_decoding_message_size = Some(limit);
293            self
294        }
295        /// Limits the maximum size of an encoded message.
296        ///
297        /// Default: `usize::MAX`
298        #[must_use]
299        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
300            self.max_encoding_message_size = Some(limit);
301            self
302        }
303    }
304    impl<T, B> tonic::codegen::Service<http::Request<B>> for KeyManagerServer<T>
305    where
306        T: KeyManager,
307        B: Body + Send + 'static,
308        B::Error: Into<StdError> + Send + 'static,
309    {
310        type Response = http::Response<tonic::body::BoxBody>;
311        type Error = std::convert::Infallible;
312        type Future = BoxFuture<Self::Response, Self::Error>;
313        fn poll_ready(
314            &mut self,
315            _cx: &mut Context<'_>,
316        ) -> Poll<std::result::Result<(), Self::Error>> {
317            Poll::Ready(Ok(()))
318        }
319        fn call(&mut self, req: http::Request<B>) -> Self::Future {
320            let inner = self.inner.clone();
321            match req.uri().path() {
322                "/keymanager.v1.KeyManager/GenerateKeyPair" => {
323                    #[allow(non_camel_case_types)]
324                    struct GenerateKeyPairSvc<T: KeyManager>(pub Arc<T>);
325                    impl<
326                        T: KeyManager,
327                    > tonic::server::UnaryService<super::GenerateKeyPairRequest>
328                    for GenerateKeyPairSvc<T> {
329                        type Response = super::GenerateKeyPairResponse;
330                        type Future = BoxFuture<
331                            tonic::Response<Self::Response>,
332                            tonic::Status,
333                        >;
334                        fn call(
335                            &mut self,
336                            request: tonic::Request<super::GenerateKeyPairRequest>,
337                        ) -> Self::Future {
338                            let inner = Arc::clone(&self.0);
339                            let fut = async move {
340                                (*inner).generate_key_pair(request).await
341                            };
342                            Box::pin(fut)
343                        }
344                    }
345                    let accept_compression_encodings = self.accept_compression_encodings;
346                    let send_compression_encodings = self.send_compression_encodings;
347                    let max_decoding_message_size = self.max_decoding_message_size;
348                    let max_encoding_message_size = self.max_encoding_message_size;
349                    let inner = self.inner.clone();
350                    let fut = async move {
351                        let inner = inner.0;
352                        let method = GenerateKeyPairSvc(inner);
353                        let codec = tonic::codec::ProstCodec::default();
354                        let mut grpc = tonic::server::Grpc::new(codec)
355                            .apply_compression_config(
356                                accept_compression_encodings,
357                                send_compression_encodings,
358                            )
359                            .apply_max_message_size_config(
360                                max_decoding_message_size,
361                                max_encoding_message_size,
362                            );
363                        let res = grpc.unary(method, req).await;
364                        Ok(res)
365                    };
366                    Box::pin(fut)
367                }
368                "/keymanager.v1.KeyManager/ImportKey" => {
369                    #[allow(non_camel_case_types)]
370                    struct ImportKeySvc<T: KeyManager>(pub Arc<T>);
371                    impl<
372                        T: KeyManager,
373                    > tonic::server::UnaryService<super::ImportKeyRequest>
374                    for ImportKeySvc<T> {
375                        type Response = super::ImportKeyResponse;
376                        type Future = BoxFuture<
377                            tonic::Response<Self::Response>,
378                            tonic::Status,
379                        >;
380                        fn call(
381                            &mut self,
382                            request: tonic::Request<super::ImportKeyRequest>,
383                        ) -> Self::Future {
384                            let inner = Arc::clone(&self.0);
385                            let fut = async move { (*inner).import_key(request).await };
386                            Box::pin(fut)
387                        }
388                    }
389                    let accept_compression_encodings = self.accept_compression_encodings;
390                    let send_compression_encodings = self.send_compression_encodings;
391                    let max_decoding_message_size = self.max_decoding_message_size;
392                    let max_encoding_message_size = self.max_encoding_message_size;
393                    let inner = self.inner.clone();
394                    let fut = async move {
395                        let inner = inner.0;
396                        let method = ImportKeySvc(inner);
397                        let codec = tonic::codec::ProstCodec::default();
398                        let mut grpc = tonic::server::Grpc::new(codec)
399                            .apply_compression_config(
400                                accept_compression_encodings,
401                                send_compression_encodings,
402                            )
403                            .apply_max_message_size_config(
404                                max_decoding_message_size,
405                                max_encoding_message_size,
406                            );
407                        let res = grpc.unary(method, req).await;
408                        Ok(res)
409                    };
410                    Box::pin(fut)
411                }
412                "/keymanager.v1.KeyManager/ListKeys" => {
413                    #[allow(non_camel_case_types)]
414                    struct ListKeysSvc<T: KeyManager>(pub Arc<T>);
415                    impl<
416                        T: KeyManager,
417                    > tonic::server::UnaryService<super::ListKeysRequest>
418                    for ListKeysSvc<T> {
419                        type Response = super::ListKeysResponse;
420                        type Future = BoxFuture<
421                            tonic::Response<Self::Response>,
422                            tonic::Status,
423                        >;
424                        fn call(
425                            &mut self,
426                            request: tonic::Request<super::ListKeysRequest>,
427                        ) -> Self::Future {
428                            let inner = Arc::clone(&self.0);
429                            let fut = async move { (*inner).list_keys(request).await };
430                            Box::pin(fut)
431                        }
432                    }
433                    let accept_compression_encodings = self.accept_compression_encodings;
434                    let send_compression_encodings = self.send_compression_encodings;
435                    let max_decoding_message_size = self.max_decoding_message_size;
436                    let max_encoding_message_size = self.max_encoding_message_size;
437                    let inner = self.inner.clone();
438                    let fut = async move {
439                        let inner = inner.0;
440                        let method = ListKeysSvc(inner);
441                        let codec = tonic::codec::ProstCodec::default();
442                        let mut grpc = tonic::server::Grpc::new(codec)
443                            .apply_compression_config(
444                                accept_compression_encodings,
445                                send_compression_encodings,
446                            )
447                            .apply_max_message_size_config(
448                                max_decoding_message_size,
449                                max_encoding_message_size,
450                            );
451                        let res = grpc.unary(method, req).await;
452                        Ok(res)
453                    };
454                    Box::pin(fut)
455                }
456                _ => {
457                    Box::pin(async move {
458                        Ok(
459                            http::Response::builder()
460                                .status(200)
461                                .header("grpc-status", "12")
462                                .header("content-type", "application/grpc")
463                                .body(empty_body())
464                                .unwrap(),
465                        )
466                    })
467                }
468            }
469        }
470    }
471    impl<T: KeyManager> Clone for KeyManagerServer<T> {
472        fn clone(&self) -> Self {
473            let inner = self.inner.clone();
474            Self {
475                inner,
476                accept_compression_encodings: self.accept_compression_encodings,
477                send_compression_encodings: self.send_compression_encodings,
478                max_decoding_message_size: self.max_decoding_message_size,
479                max_encoding_message_size: self.max_encoding_message_size,
480            }
481        }
482    }
483    impl<T: KeyManager> Clone for _Inner<T> {
484        fn clone(&self) -> Self {
485            Self(Arc::clone(&self.0))
486        }
487    }
488    impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
489        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
490            write!(f, "{:?}", self.0)
491        }
492    }
493    impl<T: KeyManager> tonic::server::NamedService for KeyManagerServer<T> {
494        const NAME: &'static str = "keymanager.v1.KeyManager";
495    }
496}