quartz_proto/prost/
quartz.rs

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