miden_node_proto/generated/
validator.rs

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