1#[cfg(not(target_arch = "wasm32"))]
4pub mod settings_client {
5 #![allow(
6 unused_variables,
7 dead_code,
8 missing_docs,
9 clippy::wildcard_imports,
10 clippy::let_unit_value,
11 )]
12 use tonic::codegen::*;
13 use tonic::codegen::http::Uri;
14 #[derive(Debug, Clone)]
16 pub struct SettingsClient<T> {
17 inner: tonic::client::Grpc<T>,
18 }
19 impl SettingsClient<tonic::transport::Channel> {
20 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
22 where
23 D: TryInto<tonic::transport::Endpoint>,
24 D::Error: Into<StdError>,
25 {
26 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
27 Ok(Self::new(conn))
28 }
29 }
30 impl<T> SettingsClient<T>
31 where
32 T: tonic::client::GrpcService<tonic::body::Body>,
33 T::Error: Into<StdError>,
34 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
35 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
36 {
37 pub fn new(inner: T) -> Self {
38 let inner = tonic::client::Grpc::new(inner);
39 Self { inner }
40 }
41 pub fn with_origin(inner: T, origin: Uri) -> Self {
42 let inner = tonic::client::Grpc::with_origin(inner, origin);
43 Self { inner }
44 }
45 pub fn with_interceptor<F>(
46 inner: T,
47 interceptor: F,
48 ) -> SettingsClient<InterceptedService<T, F>>
49 where
50 F: tonic::service::Interceptor,
51 T::ResponseBody: Default,
52 T: tonic::codegen::Service<
53 http::Request<tonic::body::Body>,
54 Response = http::Response<
55 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
56 >,
57 >,
58 <T as tonic::codegen::Service<
59 http::Request<tonic::body::Body>,
60 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
61 {
62 SettingsClient::new(InterceptedService::new(inner, interceptor))
63 }
64 #[must_use]
69 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
70 self.inner = self.inner.send_compressed(encoding);
71 self
72 }
73 #[must_use]
75 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
76 self.inner = self.inner.accept_compressed(encoding);
77 self
78 }
79 #[must_use]
83 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
84 self.inner = self.inner.max_decoding_message_size(limit);
85 self
86 }
87 #[must_use]
91 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
92 self.inner = self.inner.max_encoding_message_size(limit);
93 self
94 }
95 pub async fn list(
97 &mut self,
98 request: impl tonic::IntoRequest<crate::host::plugins::SettingsListRequest>,
99 ) -> std::result::Result<
100 tonic::Response<crate::host::plugins::SettingsListResponse>,
101 tonic::Status,
102 > {
103 self.inner
104 .ready()
105 .await
106 .map_err(|e| {
107 tonic::Status::unknown(
108 format!("Service was not ready: {}", e.into()),
109 )
110 })?;
111 let codec = tonic_prost::ProstCodec::default();
112 let path = http::uri::PathAndQuery::from_static(
113 "/harmos.plugin.v1.plugins.Settings/List",
114 );
115 let mut req = request.into_request();
116 req.extensions_mut()
117 .insert(GrpcMethod::new("harmos.plugin.v1.plugins.Settings", "List"));
118 self.inner.unary(req, path, codec).await
119 }
120 }
121}
122#[cfg(not(target_arch = "wasm32"))]
124pub mod settings_server {
125 #![allow(
126 unused_variables,
127 dead_code,
128 missing_docs,
129 clippy::wildcard_imports,
130 clippy::let_unit_value,
131 )]
132 use tonic::codegen::*;
133 #[async_trait]
135 pub trait Settings: std::marker::Send + std::marker::Sync + 'static {
136 async fn list(
138 &self,
139 request: tonic::Request<crate::host::plugins::SettingsListRequest>,
140 ) -> std::result::Result<
141 tonic::Response<crate::host::plugins::SettingsListResponse>,
142 tonic::Status,
143 >;
144 }
145 #[derive(Debug)]
147 pub struct SettingsServer<T> {
148 inner: Arc<T>,
149 accept_compression_encodings: EnabledCompressionEncodings,
150 send_compression_encodings: EnabledCompressionEncodings,
151 max_decoding_message_size: Option<usize>,
152 max_encoding_message_size: Option<usize>,
153 }
154 impl<T> SettingsServer<T> {
155 pub fn new(inner: T) -> Self {
156 Self::from_arc(Arc::new(inner))
157 }
158 pub fn from_arc(inner: Arc<T>) -> Self {
159 Self {
160 inner,
161 accept_compression_encodings: Default::default(),
162 send_compression_encodings: Default::default(),
163 max_decoding_message_size: None,
164 max_encoding_message_size: None,
165 }
166 }
167 pub fn with_interceptor<F>(
168 inner: T,
169 interceptor: F,
170 ) -> InterceptedService<Self, F>
171 where
172 F: tonic::service::Interceptor,
173 {
174 InterceptedService::new(Self::new(inner), interceptor)
175 }
176 #[must_use]
178 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
179 self.accept_compression_encodings.enable(encoding);
180 self
181 }
182 #[must_use]
184 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
185 self.send_compression_encodings.enable(encoding);
186 self
187 }
188 #[must_use]
192 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
193 self.max_decoding_message_size = Some(limit);
194 self
195 }
196 #[must_use]
200 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
201 self.max_encoding_message_size = Some(limit);
202 self
203 }
204 }
205 impl<T, B> tonic::codegen::Service<http::Request<B>> for SettingsServer<T>
206 where
207 T: Settings,
208 B: Body + std::marker::Send + 'static,
209 B::Error: Into<StdError> + std::marker::Send + 'static,
210 {
211 type Response = http::Response<tonic::body::Body>;
212 type Error = std::convert::Infallible;
213 type Future = BoxFuture<Self::Response, Self::Error>;
214 fn poll_ready(
215 &mut self,
216 _cx: &mut Context<'_>,
217 ) -> Poll<std::result::Result<(), Self::Error>> {
218 Poll::Ready(Ok(()))
219 }
220 fn call(&mut self, req: http::Request<B>) -> Self::Future {
221 match req.uri().path() {
222 "/harmos.plugin.v1.plugins.Settings/List" => {
223 #[allow(non_camel_case_types)]
224 struct ListSvc<T: Settings>(pub Arc<T>);
225 impl<
226 T: Settings,
227 > tonic::server::UnaryService<
228 crate::host::plugins::SettingsListRequest,
229 > for ListSvc<T> {
230 type Response = crate::host::plugins::SettingsListResponse;
231 type Future = BoxFuture<
232 tonic::Response<Self::Response>,
233 tonic::Status,
234 >;
235 fn call(
236 &mut self,
237 request: tonic::Request<
238 crate::host::plugins::SettingsListRequest,
239 >,
240 ) -> Self::Future {
241 let inner = Arc::clone(&self.0);
242 let fut = async move {
243 <T as Settings>::list(&inner, request).await
244 };
245 Box::pin(fut)
246 }
247 }
248 let accept_compression_encodings = self.accept_compression_encodings;
249 let send_compression_encodings = self.send_compression_encodings;
250 let max_decoding_message_size = self.max_decoding_message_size;
251 let max_encoding_message_size = self.max_encoding_message_size;
252 let inner = self.inner.clone();
253 let fut = async move {
254 let method = ListSvc(inner);
255 let codec = tonic_prost::ProstCodec::default();
256 let mut grpc = tonic::server::Grpc::new(codec)
257 .apply_compression_config(
258 accept_compression_encodings,
259 send_compression_encodings,
260 )
261 .apply_max_message_size_config(
262 max_decoding_message_size,
263 max_encoding_message_size,
264 );
265 let res = grpc.unary(method, req).await;
266 Ok(res)
267 };
268 Box::pin(fut)
269 }
270 _ => {
271 Box::pin(async move {
272 let mut response = http::Response::new(
273 tonic::body::Body::default(),
274 );
275 let headers = response.headers_mut();
276 headers
277 .insert(
278 tonic::Status::GRPC_STATUS,
279 (tonic::Code::Unimplemented as i32).into(),
280 );
281 headers
282 .insert(
283 http::header::CONTENT_TYPE,
284 tonic::metadata::GRPC_CONTENT_TYPE,
285 );
286 Ok(response)
287 })
288 }
289 }
290 }
291 }
292 impl<T> Clone for SettingsServer<T> {
293 fn clone(&self) -> Self {
294 let inner = self.inner.clone();
295 Self {
296 inner,
297 accept_compression_encodings: self.accept_compression_encodings,
298 send_compression_encodings: self.send_compression_encodings,
299 max_decoding_message_size: self.max_decoding_message_size,
300 max_encoding_message_size: self.max_encoding_message_size,
301 }
302 }
303 }
304 pub const SERVICE_NAME: &str = "harmos.plugin.v1.plugins.Settings";
306 impl<T> tonic::server::NamedService for SettingsServer<T> {
307 const NAME: &'static str = SERVICE_NAME;
308 }
309}
310#[cfg(not(target_arch = "wasm32"))]
312pub mod state_client {
313 #![allow(
314 unused_variables,
315 dead_code,
316 missing_docs,
317 clippy::wildcard_imports,
318 clippy::let_unit_value,
319 )]
320 use tonic::codegen::*;
321 use tonic::codegen::http::Uri;
322 #[derive(Debug, Clone)]
324 pub struct StateClient<T> {
325 inner: tonic::client::Grpc<T>,
326 }
327 impl StateClient<tonic::transport::Channel> {
328 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
330 where
331 D: TryInto<tonic::transport::Endpoint>,
332 D::Error: Into<StdError>,
333 {
334 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
335 Ok(Self::new(conn))
336 }
337 }
338 impl<T> StateClient<T>
339 where
340 T: tonic::client::GrpcService<tonic::body::Body>,
341 T::Error: Into<StdError>,
342 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
343 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
344 {
345 pub fn new(inner: T) -> Self {
346 let inner = tonic::client::Grpc::new(inner);
347 Self { inner }
348 }
349 pub fn with_origin(inner: T, origin: Uri) -> Self {
350 let inner = tonic::client::Grpc::with_origin(inner, origin);
351 Self { inner }
352 }
353 pub fn with_interceptor<F>(
354 inner: T,
355 interceptor: F,
356 ) -> StateClient<InterceptedService<T, F>>
357 where
358 F: tonic::service::Interceptor,
359 T::ResponseBody: Default,
360 T: tonic::codegen::Service<
361 http::Request<tonic::body::Body>,
362 Response = http::Response<
363 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
364 >,
365 >,
366 <T as tonic::codegen::Service<
367 http::Request<tonic::body::Body>,
368 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
369 {
370 StateClient::new(InterceptedService::new(inner, interceptor))
371 }
372 #[must_use]
377 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
378 self.inner = self.inner.send_compressed(encoding);
379 self
380 }
381 #[must_use]
383 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
384 self.inner = self.inner.accept_compressed(encoding);
385 self
386 }
387 #[must_use]
391 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
392 self.inner = self.inner.max_decoding_message_size(limit);
393 self
394 }
395 #[must_use]
399 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
400 self.inner = self.inner.max_encoding_message_size(limit);
401 self
402 }
403 pub async fn get(
405 &mut self,
406 request: impl tonic::IntoRequest<crate::host::plugins::StateGetRequest>,
407 ) -> std::result::Result<
408 tonic::Response<crate::host::plugins::StateGetResponse>,
409 tonic::Status,
410 > {
411 self.inner
412 .ready()
413 .await
414 .map_err(|e| {
415 tonic::Status::unknown(
416 format!("Service was not ready: {}", e.into()),
417 )
418 })?;
419 let codec = tonic_prost::ProstCodec::default();
420 let path = http::uri::PathAndQuery::from_static(
421 "/harmos.plugin.v1.plugins.State/Get",
422 );
423 let mut req = request.into_request();
424 req.extensions_mut()
425 .insert(GrpcMethod::new("harmos.plugin.v1.plugins.State", "Get"));
426 self.inner.unary(req, path, codec).await
427 }
428 pub async fn put(
430 &mut self,
431 request: impl tonic::IntoRequest<crate::host::plugins::StatePutRequest>,
432 ) -> std::result::Result<
433 tonic::Response<crate::host::plugins::StatePutResponse>,
434 tonic::Status,
435 > {
436 self.inner
437 .ready()
438 .await
439 .map_err(|e| {
440 tonic::Status::unknown(
441 format!("Service was not ready: {}", e.into()),
442 )
443 })?;
444 let codec = tonic_prost::ProstCodec::default();
445 let path = http::uri::PathAndQuery::from_static(
446 "/harmos.plugin.v1.plugins.State/Put",
447 );
448 let mut req = request.into_request();
449 req.extensions_mut()
450 .insert(GrpcMethod::new("harmos.plugin.v1.plugins.State", "Put"));
451 self.inner.unary(req, path, codec).await
452 }
453 }
454}
455#[cfg(not(target_arch = "wasm32"))]
457pub mod state_server {
458 #![allow(
459 unused_variables,
460 dead_code,
461 missing_docs,
462 clippy::wildcard_imports,
463 clippy::let_unit_value,
464 )]
465 use tonic::codegen::*;
466 #[async_trait]
468 pub trait State: std::marker::Send + std::marker::Sync + 'static {
469 async fn get(
471 &self,
472 request: tonic::Request<crate::host::plugins::StateGetRequest>,
473 ) -> std::result::Result<
474 tonic::Response<crate::host::plugins::StateGetResponse>,
475 tonic::Status,
476 >;
477 async fn put(
479 &self,
480 request: tonic::Request<crate::host::plugins::StatePutRequest>,
481 ) -> std::result::Result<
482 tonic::Response<crate::host::plugins::StatePutResponse>,
483 tonic::Status,
484 >;
485 }
486 #[derive(Debug)]
488 pub struct StateServer<T> {
489 inner: Arc<T>,
490 accept_compression_encodings: EnabledCompressionEncodings,
491 send_compression_encodings: EnabledCompressionEncodings,
492 max_decoding_message_size: Option<usize>,
493 max_encoding_message_size: Option<usize>,
494 }
495 impl<T> StateServer<T> {
496 pub fn new(inner: T) -> Self {
497 Self::from_arc(Arc::new(inner))
498 }
499 pub fn from_arc(inner: Arc<T>) -> Self {
500 Self {
501 inner,
502 accept_compression_encodings: Default::default(),
503 send_compression_encodings: Default::default(),
504 max_decoding_message_size: None,
505 max_encoding_message_size: None,
506 }
507 }
508 pub fn with_interceptor<F>(
509 inner: T,
510 interceptor: F,
511 ) -> InterceptedService<Self, F>
512 where
513 F: tonic::service::Interceptor,
514 {
515 InterceptedService::new(Self::new(inner), interceptor)
516 }
517 #[must_use]
519 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
520 self.accept_compression_encodings.enable(encoding);
521 self
522 }
523 #[must_use]
525 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
526 self.send_compression_encodings.enable(encoding);
527 self
528 }
529 #[must_use]
533 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
534 self.max_decoding_message_size = Some(limit);
535 self
536 }
537 #[must_use]
541 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
542 self.max_encoding_message_size = Some(limit);
543 self
544 }
545 }
546 impl<T, B> tonic::codegen::Service<http::Request<B>> for StateServer<T>
547 where
548 T: State,
549 B: Body + std::marker::Send + 'static,
550 B::Error: Into<StdError> + std::marker::Send + 'static,
551 {
552 type Response = http::Response<tonic::body::Body>;
553 type Error = std::convert::Infallible;
554 type Future = BoxFuture<Self::Response, Self::Error>;
555 fn poll_ready(
556 &mut self,
557 _cx: &mut Context<'_>,
558 ) -> Poll<std::result::Result<(), Self::Error>> {
559 Poll::Ready(Ok(()))
560 }
561 fn call(&mut self, req: http::Request<B>) -> Self::Future {
562 match req.uri().path() {
563 "/harmos.plugin.v1.plugins.State/Get" => {
564 #[allow(non_camel_case_types)]
565 struct GetSvc<T: State>(pub Arc<T>);
566 impl<
567 T: State,
568 > tonic::server::UnaryService<crate::host::plugins::StateGetRequest>
569 for GetSvc<T> {
570 type Response = crate::host::plugins::StateGetResponse;
571 type Future = BoxFuture<
572 tonic::Response<Self::Response>,
573 tonic::Status,
574 >;
575 fn call(
576 &mut self,
577 request: tonic::Request<
578 crate::host::plugins::StateGetRequest,
579 >,
580 ) -> Self::Future {
581 let inner = Arc::clone(&self.0);
582 let fut = async move {
583 <T as State>::get(&inner, request).await
584 };
585 Box::pin(fut)
586 }
587 }
588 let accept_compression_encodings = self.accept_compression_encodings;
589 let send_compression_encodings = self.send_compression_encodings;
590 let max_decoding_message_size = self.max_decoding_message_size;
591 let max_encoding_message_size = self.max_encoding_message_size;
592 let inner = self.inner.clone();
593 let fut = async move {
594 let method = GetSvc(inner);
595 let codec = tonic_prost::ProstCodec::default();
596 let mut grpc = tonic::server::Grpc::new(codec)
597 .apply_compression_config(
598 accept_compression_encodings,
599 send_compression_encodings,
600 )
601 .apply_max_message_size_config(
602 max_decoding_message_size,
603 max_encoding_message_size,
604 );
605 let res = grpc.unary(method, req).await;
606 Ok(res)
607 };
608 Box::pin(fut)
609 }
610 "/harmos.plugin.v1.plugins.State/Put" => {
611 #[allow(non_camel_case_types)]
612 struct PutSvc<T: State>(pub Arc<T>);
613 impl<
614 T: State,
615 > tonic::server::UnaryService<crate::host::plugins::StatePutRequest>
616 for PutSvc<T> {
617 type Response = crate::host::plugins::StatePutResponse;
618 type Future = BoxFuture<
619 tonic::Response<Self::Response>,
620 tonic::Status,
621 >;
622 fn call(
623 &mut self,
624 request: tonic::Request<
625 crate::host::plugins::StatePutRequest,
626 >,
627 ) -> Self::Future {
628 let inner = Arc::clone(&self.0);
629 let fut = async move {
630 <T as State>::put(&inner, request).await
631 };
632 Box::pin(fut)
633 }
634 }
635 let accept_compression_encodings = self.accept_compression_encodings;
636 let send_compression_encodings = self.send_compression_encodings;
637 let max_decoding_message_size = self.max_decoding_message_size;
638 let max_encoding_message_size = self.max_encoding_message_size;
639 let inner = self.inner.clone();
640 let fut = async move {
641 let method = PutSvc(inner);
642 let codec = tonic_prost::ProstCodec::default();
643 let mut grpc = tonic::server::Grpc::new(codec)
644 .apply_compression_config(
645 accept_compression_encodings,
646 send_compression_encodings,
647 )
648 .apply_max_message_size_config(
649 max_decoding_message_size,
650 max_encoding_message_size,
651 );
652 let res = grpc.unary(method, req).await;
653 Ok(res)
654 };
655 Box::pin(fut)
656 }
657 _ => {
658 Box::pin(async move {
659 let mut response = http::Response::new(
660 tonic::body::Body::default(),
661 );
662 let headers = response.headers_mut();
663 headers
664 .insert(
665 tonic::Status::GRPC_STATUS,
666 (tonic::Code::Unimplemented as i32).into(),
667 );
668 headers
669 .insert(
670 http::header::CONTENT_TYPE,
671 tonic::metadata::GRPC_CONTENT_TYPE,
672 );
673 Ok(response)
674 })
675 }
676 }
677 }
678 }
679 impl<T> Clone for StateServer<T> {
680 fn clone(&self) -> Self {
681 let inner = self.inner.clone();
682 Self {
683 inner,
684 accept_compression_encodings: self.accept_compression_encodings,
685 send_compression_encodings: self.send_compression_encodings,
686 max_decoding_message_size: self.max_decoding_message_size,
687 max_encoding_message_size: self.max_encoding_message_size,
688 }
689 }
690 }
691 pub const SERVICE_NAME: &str = "harmos.plugin.v1.plugins.State";
693 impl<T> tonic::server::NamedService for StateServer<T> {
694 const NAME: &'static str = SERVICE_NAME;
695 }
696}