1#[allow(clippy::derive_partial_eq_without_eq)]
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct SignGenericRequest {
4 #[prost(string, tag = "1")]
6 pub public_key: ::prost::alloc::string::String,
7 #[prost(bytes = "vec", tag = "2")]
9 pub data: ::prost::alloc::vec::Vec<u8>,
10 #[prost(string, tag = "3")]
12 pub password: ::prost::alloc::string::String,
13}
14#[allow(clippy::derive_partial_eq_without_eq)]
15#[derive(Clone, PartialEq, ::prost::Message)]
16pub struct SignGenericResponse {
17 #[prost(bytes = "vec", tag = "1")]
19 pub signature: ::prost::alloc::vec::Vec<u8>,
20}
21pub mod signer_client {
23 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
24 use tonic::codegen::*;
25 use tonic::codegen::http::Uri;
26 #[derive(Debug, Clone)]
27 pub struct SignerClient<T> {
28 inner: tonic::client::Grpc<T>,
29 }
30 impl SignerClient<tonic::transport::Channel> {
31 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
33 where
34 D: TryInto<tonic::transport::Endpoint>,
35 D::Error: Into<StdError>,
36 {
37 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
38 Ok(Self::new(conn))
39 }
40 }
41 impl<T> SignerClient<T>
42 where
43 T: tonic::client::GrpcService<tonic::body::BoxBody>,
44 T::Error: Into<StdError>,
45 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
46 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
47 {
48 pub fn new(inner: T) -> Self {
49 let inner = tonic::client::Grpc::new(inner);
50 Self { inner }
51 }
52 pub fn with_origin(inner: T, origin: Uri) -> Self {
53 let inner = tonic::client::Grpc::with_origin(inner, origin);
54 Self { inner }
55 }
56 pub fn with_interceptor<F>(
57 inner: T,
58 interceptor: F,
59 ) -> SignerClient<InterceptedService<T, F>>
60 where
61 F: tonic::service::Interceptor,
62 T::ResponseBody: Default,
63 T: tonic::codegen::Service<
64 http::Request<tonic::body::BoxBody>,
65 Response = http::Response<
66 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
67 >,
68 >,
69 <T as tonic::codegen::Service<
70 http::Request<tonic::body::BoxBody>,
71 >>::Error: Into<StdError> + Send + Sync,
72 {
73 SignerClient::new(InterceptedService::new(inner, interceptor))
74 }
75 #[must_use]
80 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
81 self.inner = self.inner.send_compressed(encoding);
82 self
83 }
84 #[must_use]
86 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
87 self.inner = self.inner.accept_compressed(encoding);
88 self
89 }
90 #[must_use]
94 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
95 self.inner = self.inner.max_decoding_message_size(limit);
96 self
97 }
98 #[must_use]
102 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
103 self.inner = self.inner.max_encoding_message_size(limit);
104 self
105 }
106 pub async fn sign_generic(
107 &mut self,
108 request: impl tonic::IntoRequest<super::SignGenericRequest>,
109 ) -> std::result::Result<
110 tonic::Response<super::SignGenericResponse>,
111 tonic::Status,
112 > {
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 "/signer.v1.Signer/SignGeneric",
125 );
126 let mut req = request.into_request();
127 req.extensions_mut()
128 .insert(GrpcMethod::new("signer.v1.Signer", "SignGeneric"));
129 self.inner.unary(req, path, codec).await
130 }
131 }
132}
133pub mod signer_server {
135 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
136 use tonic::codegen::*;
137 #[async_trait]
139 pub trait Signer: Send + Sync + 'static {
140 async fn sign_generic(
141 &self,
142 request: tonic::Request<super::SignGenericRequest>,
143 ) -> std::result::Result<
144 tonic::Response<super::SignGenericResponse>,
145 tonic::Status,
146 >;
147 }
148 #[derive(Debug)]
149 pub struct SignerServer<T: Signer> {
150 inner: _Inner<T>,
151 accept_compression_encodings: EnabledCompressionEncodings,
152 send_compression_encodings: EnabledCompressionEncodings,
153 max_decoding_message_size: Option<usize>,
154 max_encoding_message_size: Option<usize>,
155 }
156 struct _Inner<T>(Arc<T>);
157 impl<T: Signer> SignerServer<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 max_decoding_message_size: None,
168 max_encoding_message_size: None,
169 }
170 }
171 pub fn with_interceptor<F>(
172 inner: T,
173 interceptor: F,
174 ) -> InterceptedService<Self, F>
175 where
176 F: tonic::service::Interceptor,
177 {
178 InterceptedService::new(Self::new(inner), interceptor)
179 }
180 #[must_use]
182 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
183 self.accept_compression_encodings.enable(encoding);
184 self
185 }
186 #[must_use]
188 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
189 self.send_compression_encodings.enable(encoding);
190 self
191 }
192 #[must_use]
196 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
197 self.max_decoding_message_size = Some(limit);
198 self
199 }
200 #[must_use]
204 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
205 self.max_encoding_message_size = Some(limit);
206 self
207 }
208 }
209 impl<T, B> tonic::codegen::Service<http::Request<B>> for SignerServer<T>
210 where
211 T: Signer,
212 B: Body + Send + 'static,
213 B::Error: Into<StdError> + Send + 'static,
214 {
215 type Response = http::Response<tonic::body::BoxBody>;
216 type Error = std::convert::Infallible;
217 type Future = BoxFuture<Self::Response, Self::Error>;
218 fn poll_ready(
219 &mut self,
220 _cx: &mut Context<'_>,
221 ) -> Poll<std::result::Result<(), Self::Error>> {
222 Poll::Ready(Ok(()))
223 }
224 fn call(&mut self, req: http::Request<B>) -> Self::Future {
225 let inner = self.inner.clone();
226 match req.uri().path() {
227 "/signer.v1.Signer/SignGeneric" => {
228 #[allow(non_camel_case_types)]
229 struct SignGenericSvc<T: Signer>(pub Arc<T>);
230 impl<
231 T: Signer,
232 > tonic::server::UnaryService<super::SignGenericRequest>
233 for SignGenericSvc<T> {
234 type Response = super::SignGenericResponse;
235 type Future = BoxFuture<
236 tonic::Response<Self::Response>,
237 tonic::Status,
238 >;
239 fn call(
240 &mut self,
241 request: tonic::Request<super::SignGenericRequest>,
242 ) -> Self::Future {
243 let inner = Arc::clone(&self.0);
244 let fut = async move {
245 (*inner).sign_generic(request).await
246 };
247 Box::pin(fut)
248 }
249 }
250 let accept_compression_encodings = self.accept_compression_encodings;
251 let send_compression_encodings = self.send_compression_encodings;
252 let max_decoding_message_size = self.max_decoding_message_size;
253 let max_encoding_message_size = self.max_encoding_message_size;
254 let inner = self.inner.clone();
255 let fut = async move {
256 let inner = inner.0;
257 let method = SignGenericSvc(inner);
258 let codec = tonic::codec::ProstCodec::default();
259 let mut grpc = tonic::server::Grpc::new(codec)
260 .apply_compression_config(
261 accept_compression_encodings,
262 send_compression_encodings,
263 )
264 .apply_max_message_size_config(
265 max_decoding_message_size,
266 max_encoding_message_size,
267 );
268 let res = grpc.unary(method, req).await;
269 Ok(res)
270 };
271 Box::pin(fut)
272 }
273 _ => {
274 Box::pin(async move {
275 Ok(
276 http::Response::builder()
277 .status(200)
278 .header("grpc-status", "12")
279 .header("content-type", "application/grpc")
280 .body(empty_body())
281 .unwrap(),
282 )
283 })
284 }
285 }
286 }
287 }
288 impl<T: Signer> Clone for SignerServer<T> {
289 fn clone(&self) -> Self {
290 let inner = self.inner.clone();
291 Self {
292 inner,
293 accept_compression_encodings: self.accept_compression_encodings,
294 send_compression_encodings: self.send_compression_encodings,
295 max_decoding_message_size: self.max_decoding_message_size,
296 max_encoding_message_size: self.max_encoding_message_size,
297 }
298 }
299 }
300 impl<T: Signer> Clone for _Inner<T> {
301 fn clone(&self) -> Self {
302 Self(Arc::clone(&self.0))
303 }
304 }
305 impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
306 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
307 write!(f, "{:?}", self.0)
308 }
309 }
310 impl<T: Signer> tonic::server::NamedService for SignerServer<T> {
311 const NAME: &'static str = "signer.v1.Signer";
312 }
313}