Skip to main content

devtools_wire_format/generated/
rs.devtools.tauri.rs

1// This file is @generated by prost-build.
2#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
3pub struct VersionsRequest {}
4#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
5pub struct Versions {
6    /// / Tauri version, follows SemVer.
7    #[prost(string, tag = "1")]
8    pub tauri: ::prost::alloc::string::String,
9    /// / Version of the OS'es webview.
10    /// / The format of this is freeform and changes depending on the OS.
11    #[prost(string, optional, tag = "2")]
12    pub webview: ::core::option::Option<::prost::alloc::string::String>,
13}
14#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
15pub struct ConfigRequest {}
16#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
17pub struct MetricsRequest {}
18#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
19pub struct Config {
20    /// / The raw JSON string of the configuration
21    #[prost(string, tag = "1")]
22    pub raw: ::prost::alloc::string::String,
23}
24#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
25pub struct Metrics {
26    /// / Tauri application initialization time
27    #[prost(message, optional, tag = "1")]
28    pub initialized_at: ::core::option::Option<::prost_types::Timestamp>,
29    /// / Tauri application reported `AppReady` time
30    #[prost(message, optional, tag = "2")]
31    pub ready_at: ::core::option::Option<::prost_types::Timestamp>,
32}
33/// Generated server implementations.
34#[allow(clippy::all)]
35pub mod tauri_server {
36    #![allow(
37        unused_variables,
38        dead_code,
39        missing_docs,
40        clippy::wildcard_imports,
41        clippy::let_unit_value,
42    )]
43    use tonic::codegen::*;
44    /// Generated trait containing gRPC methods that should be implemented for use with TauriServer.
45    #[async_trait]
46    pub trait Tauri: std::marker::Send + std::marker::Sync + 'static {
47        async fn get_versions(
48            &self,
49            request: tonic::Request<super::VersionsRequest>,
50        ) -> std::result::Result<tonic::Response<super::Versions>, tonic::Status>;
51        async fn get_config(
52            &self,
53            request: tonic::Request<super::ConfigRequest>,
54        ) -> std::result::Result<tonic::Response<super::Config>, tonic::Status>;
55        async fn get_metrics(
56            &self,
57            request: tonic::Request<super::MetricsRequest>,
58        ) -> std::result::Result<tonic::Response<super::Metrics>, tonic::Status>;
59    }
60    #[derive(Debug)]
61    pub struct TauriServer<T> {
62        inner: Arc<T>,
63        accept_compression_encodings: EnabledCompressionEncodings,
64        send_compression_encodings: EnabledCompressionEncodings,
65        max_decoding_message_size: Option<usize>,
66        max_encoding_message_size: Option<usize>,
67    }
68    impl<T> TauriServer<T> {
69        pub fn new(inner: T) -> Self {
70            Self::from_arc(Arc::new(inner))
71        }
72        pub fn from_arc(inner: Arc<T>) -> Self {
73            Self {
74                inner,
75                accept_compression_encodings: Default::default(),
76                send_compression_encodings: Default::default(),
77                max_decoding_message_size: None,
78                max_encoding_message_size: None,
79            }
80        }
81        pub fn with_interceptor<F>(
82            inner: T,
83            interceptor: F,
84        ) -> InterceptedService<Self, F>
85        where
86            F: tonic::service::Interceptor,
87        {
88            InterceptedService::new(Self::new(inner), interceptor)
89        }
90        /// Enable decompressing requests with the given encoding.
91        #[must_use]
92        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
93            self.accept_compression_encodings.enable(encoding);
94            self
95        }
96        /// Compress responses with the given encoding, if the client supports it.
97        #[must_use]
98        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
99            self.send_compression_encodings.enable(encoding);
100            self
101        }
102        /// Limits the maximum size of a decoded message.
103        ///
104        /// Default: `4MB`
105        #[must_use]
106        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
107            self.max_decoding_message_size = Some(limit);
108            self
109        }
110        /// Limits the maximum size of an encoded message.
111        ///
112        /// Default: `usize::MAX`
113        #[must_use]
114        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
115            self.max_encoding_message_size = Some(limit);
116            self
117        }
118    }
119    impl<T, B> tonic::codegen::Service<http::Request<B>> for TauriServer<T>
120    where
121        T: Tauri,
122        B: Body + std::marker::Send + 'static,
123        B::Error: Into<StdError> + std::marker::Send + 'static,
124    {
125        type Response = http::Response<tonic::body::Body>;
126        type Error = std::convert::Infallible;
127        type Future = BoxFuture<Self::Response, Self::Error>;
128        fn poll_ready(
129            &mut self,
130            _cx: &mut Context<'_>,
131        ) -> Poll<std::result::Result<(), Self::Error>> {
132            Poll::Ready(Ok(()))
133        }
134        fn call(&mut self, req: http::Request<B>) -> Self::Future {
135            match req.uri().path() {
136                "/rs.devtools.tauri.Tauri/GetVersions" => {
137                    #[allow(non_camel_case_types)]
138                    struct GetVersionsSvc<T: Tauri>(pub Arc<T>);
139                    impl<T: Tauri> tonic::server::UnaryService<super::VersionsRequest>
140                    for GetVersionsSvc<T> {
141                        type Response = super::Versions;
142                        type Future = BoxFuture<
143                            tonic::Response<Self::Response>,
144                            tonic::Status,
145                        >;
146                        fn call(
147                            &mut self,
148                            request: tonic::Request<super::VersionsRequest>,
149                        ) -> Self::Future {
150                            let inner = Arc::clone(&self.0);
151                            let fut = async move {
152                                <T as Tauri>::get_versions(&inner, request).await
153                            };
154                            Box::pin(fut)
155                        }
156                    }
157                    let accept_compression_encodings = self.accept_compression_encodings;
158                    let send_compression_encodings = self.send_compression_encodings;
159                    let max_decoding_message_size = self.max_decoding_message_size;
160                    let max_encoding_message_size = self.max_encoding_message_size;
161                    let inner = self.inner.clone();
162                    let fut = async move {
163                        let method = GetVersionsSvc(inner);
164                        let codec = tonic_prost::ProstCodec::default();
165                        let mut grpc = tonic::server::Grpc::new(codec)
166                            .apply_compression_config(
167                                accept_compression_encodings,
168                                send_compression_encodings,
169                            )
170                            .apply_max_message_size_config(
171                                max_decoding_message_size,
172                                max_encoding_message_size,
173                            );
174                        let res = grpc.unary(method, req).await;
175                        Ok(res)
176                    };
177                    Box::pin(fut)
178                }
179                "/rs.devtools.tauri.Tauri/GetConfig" => {
180                    #[allow(non_camel_case_types)]
181                    struct GetConfigSvc<T: Tauri>(pub Arc<T>);
182                    impl<T: Tauri> tonic::server::UnaryService<super::ConfigRequest>
183                    for GetConfigSvc<T> {
184                        type Response = super::Config;
185                        type Future = BoxFuture<
186                            tonic::Response<Self::Response>,
187                            tonic::Status,
188                        >;
189                        fn call(
190                            &mut self,
191                            request: tonic::Request<super::ConfigRequest>,
192                        ) -> Self::Future {
193                            let inner = Arc::clone(&self.0);
194                            let fut = async move {
195                                <T as Tauri>::get_config(&inner, request).await
196                            };
197                            Box::pin(fut)
198                        }
199                    }
200                    let accept_compression_encodings = self.accept_compression_encodings;
201                    let send_compression_encodings = self.send_compression_encodings;
202                    let max_decoding_message_size = self.max_decoding_message_size;
203                    let max_encoding_message_size = self.max_encoding_message_size;
204                    let inner = self.inner.clone();
205                    let fut = async move {
206                        let method = GetConfigSvc(inner);
207                        let codec = tonic_prost::ProstCodec::default();
208                        let mut grpc = tonic::server::Grpc::new(codec)
209                            .apply_compression_config(
210                                accept_compression_encodings,
211                                send_compression_encodings,
212                            )
213                            .apply_max_message_size_config(
214                                max_decoding_message_size,
215                                max_encoding_message_size,
216                            );
217                        let res = grpc.unary(method, req).await;
218                        Ok(res)
219                    };
220                    Box::pin(fut)
221                }
222                "/rs.devtools.tauri.Tauri/GetMetrics" => {
223                    #[allow(non_camel_case_types)]
224                    struct GetMetricsSvc<T: Tauri>(pub Arc<T>);
225                    impl<T: Tauri> tonic::server::UnaryService<super::MetricsRequest>
226                    for GetMetricsSvc<T> {
227                        type Response = super::Metrics;
228                        type Future = BoxFuture<
229                            tonic::Response<Self::Response>,
230                            tonic::Status,
231                        >;
232                        fn call(
233                            &mut self,
234                            request: tonic::Request<super::MetricsRequest>,
235                        ) -> Self::Future {
236                            let inner = Arc::clone(&self.0);
237                            let fut = async move {
238                                <T as Tauri>::get_metrics(&inner, request).await
239                            };
240                            Box::pin(fut)
241                        }
242                    }
243                    let accept_compression_encodings = self.accept_compression_encodings;
244                    let send_compression_encodings = self.send_compression_encodings;
245                    let max_decoding_message_size = self.max_decoding_message_size;
246                    let max_encoding_message_size = self.max_encoding_message_size;
247                    let inner = self.inner.clone();
248                    let fut = async move {
249                        let method = GetMetricsSvc(inner);
250                        let codec = tonic_prost::ProstCodec::default();
251                        let mut grpc = tonic::server::Grpc::new(codec)
252                            .apply_compression_config(
253                                accept_compression_encodings,
254                                send_compression_encodings,
255                            )
256                            .apply_max_message_size_config(
257                                max_decoding_message_size,
258                                max_encoding_message_size,
259                            );
260                        let res = grpc.unary(method, req).await;
261                        Ok(res)
262                    };
263                    Box::pin(fut)
264                }
265                _ => {
266                    Box::pin(async move {
267                        let mut response = http::Response::new(
268                            tonic::body::Body::default(),
269                        );
270                        let headers = response.headers_mut();
271                        headers
272                            .insert(
273                                tonic::Status::GRPC_STATUS,
274                                (tonic::Code::Unimplemented as i32).into(),
275                            );
276                        headers
277                            .insert(
278                                http::header::CONTENT_TYPE,
279                                tonic::metadata::GRPC_CONTENT_TYPE,
280                            );
281                        Ok(response)
282                    })
283                }
284            }
285        }
286    }
287    impl<T> Clone for TauriServer<T> {
288        fn clone(&self) -> Self {
289            let inner = self.inner.clone();
290            Self {
291                inner,
292                accept_compression_encodings: self.accept_compression_encodings,
293                send_compression_encodings: self.send_compression_encodings,
294                max_decoding_message_size: self.max_decoding_message_size,
295                max_encoding_message_size: self.max_encoding_message_size,
296            }
297        }
298    }
299    /// Generated gRPC service name
300    pub const SERVICE_NAME: &str = "rs.devtools.tauri.Tauri";
301    impl<T> tonic::server::NamedService for TauriServer<T> {
302        const NAME: &'static str = SERVICE_NAME;
303    }
304}