1#[derive(Clone, PartialEq, ::prost::Message)]
5pub struct AstarteDoubleArray {
6 #[prost(double, repeated, tag = "1")]
7 pub values: ::prost::alloc::vec::Vec<f64>,
8}
9#[derive(Clone, PartialEq, ::prost::Message)]
12pub struct AstarteIntegerArray {
13 #[prost(int32, repeated, tag = "1")]
14 pub values: ::prost::alloc::vec::Vec<i32>,
15}
16#[derive(Clone, PartialEq, ::prost::Message)]
19pub struct AstarteBooleanArray {
20 #[prost(bool, repeated, tag = "1")]
21 pub values: ::prost::alloc::vec::Vec<bool>,
22}
23#[derive(Clone, PartialEq, ::prost::Message)]
26pub struct AstarteLongIntegerArray {
27 #[prost(int64, repeated, tag = "1")]
28 pub values: ::prost::alloc::vec::Vec<i64>,
29}
30#[derive(Clone, PartialEq, ::prost::Message)]
33pub struct AstarteStringArray {
34 #[prost(string, repeated, tag = "1")]
35 pub values: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
36}
37#[derive(Clone, PartialEq, ::prost::Message)]
40pub struct AstarteBinaryBlobArray {
41 #[prost(bytes = "vec", repeated, tag = "1")]
42 pub values: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
43}
44#[derive(Clone, PartialEq, ::prost::Message)]
47pub struct AstarteDateTimeArray {
48 #[prost(message, repeated, tag = "1")]
49 pub values: ::prost::alloc::vec::Vec<::pbjson_types::Timestamp>,
50}
51#[derive(Clone, PartialEq, ::prost::Message)]
53pub struct AstarteData {
54 #[prost(
55 oneof = "astarte_data::AstarteData",
56 tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14"
57 )]
58 pub astarte_data: ::core::option::Option<astarte_data::AstarteData>,
59}
60pub mod astarte_data {
62 #[derive(Clone, PartialEq, ::prost::Oneof)]
63 pub enum AstarteData {
64 #[prost(double, tag = "1")]
65 Double(f64),
66 #[prost(int32, tag = "2")]
67 Integer(i32),
68 #[prost(bool, tag = "3")]
69 Boolean(bool),
70 #[prost(int64, tag = "4")]
71 LongInteger(i64),
72 #[prost(string, tag = "5")]
73 String(::prost::alloc::string::String),
74 #[prost(bytes, tag = "6")]
75 BinaryBlob(::prost::alloc::vec::Vec<u8>),
76 #[prost(message, tag = "7")]
77 DateTime(::pbjson_types::Timestamp),
78 #[prost(message, tag = "8")]
79 DoubleArray(super::AstarteDoubleArray),
80 #[prost(message, tag = "9")]
81 IntegerArray(super::AstarteIntegerArray),
82 #[prost(message, tag = "10")]
83 BooleanArray(super::AstarteBooleanArray),
84 #[prost(message, tag = "11")]
85 LongIntegerArray(super::AstarteLongIntegerArray),
86 #[prost(message, tag = "12")]
87 StringArray(super::AstarteStringArray),
88 #[prost(message, tag = "13")]
89 BinaryBlobArray(super::AstarteBinaryBlobArray),
90 #[prost(message, tag = "14")]
91 DateTimeArray(super::AstarteDateTimeArray),
92 }
93}
94#[derive(Clone, PartialEq, ::prost::Message)]
97pub struct AstarteDatastreamIndividual {
98 #[prost(message, optional, tag = "1")]
99 pub data: ::core::option::Option<AstarteData>,
100 #[prost(message, optional, tag = "2")]
102 pub timestamp: ::core::option::Option<::pbjson_types::Timestamp>,
103}
104#[derive(Clone, PartialEq, ::prost::Message)]
107pub struct AstarteDatastreamObject {
108 #[prost(map = "string, message", tag = "1")]
109 pub data: ::std::collections::HashMap<::prost::alloc::string::String, AstarteData>,
110 #[prost(message, optional, tag = "2")]
112 pub timestamp: ::core::option::Option<::pbjson_types::Timestamp>,
113}
114#[derive(Clone, PartialEq, ::prost::Message)]
118pub struct AstartePropertyIndividual {
119 #[prost(message, optional, tag = "1")]
120 pub data: ::core::option::Option<AstarteData>,
121}
122#[derive(Clone, PartialEq, ::prost::Message)]
124pub struct MessageHubError {
125 #[prost(string, tag = "1")]
127 pub description: ::prost::alloc::string::String,
128 #[prost(string, repeated, tag = "2")]
130 pub source: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
131}
132#[derive(Clone, PartialEq, ::prost::Message)]
137pub struct MessageHubEvent {
138 #[prost(oneof = "message_hub_event::Event", tags = "1, 2")]
139 pub event: ::core::option::Option<message_hub_event::Event>,
140}
141pub mod message_hub_event {
143 #[derive(Clone, PartialEq, ::prost::Oneof)]
144 pub enum Event {
145 #[prost(message, tag = "1")]
147 Message(super::AstarteMessage),
148 #[prost(message, tag = "2")]
150 Error(super::MessageHubError),
151 }
152}
153#[derive(Clone, PartialEq, ::prost::Message)]
155pub struct AstarteMessage {
156 #[prost(string, tag = "1")]
158 pub interface_name: ::prost::alloc::string::String,
159 #[prost(string, tag = "2")]
161 pub path: ::prost::alloc::string::String,
162 #[prost(oneof = "astarte_message::Payload", tags = "3, 4, 5")]
164 pub payload: ::core::option::Option<astarte_message::Payload>,
165}
166pub mod astarte_message {
168 #[derive(Clone, PartialEq, ::prost::Oneof)]
170 pub enum Payload {
171 #[prost(message, tag = "3")]
173 DatastreamIndividual(super::AstarteDatastreamIndividual),
174 #[prost(message, tag = "4")]
176 DatastreamObject(super::AstarteDatastreamObject),
177 #[prost(message, tag = "5")]
179 PropertyIndividual(super::AstartePropertyIndividual),
180 }
181}
182#[derive(Clone, PartialEq, ::prost::Message)]
184pub struct Node {
185 #[prost(string, repeated, tag = "2")]
187 pub interfaces_json: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
188}
189#[derive(Clone, PartialEq, ::prost::Message)]
191pub struct InterfacesJson {
192 #[prost(string, repeated, tag = "1")]
194 pub interfaces_json: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
195}
196#[derive(Clone, PartialEq, ::prost::Message)]
198pub struct InterfacesName {
199 #[prost(string, repeated, tag = "1")]
201 pub names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
202}
203#[derive(Clone, PartialEq, ::prost::Message)]
206pub struct InterfaceName {
207 #[prost(string, tag = "1")]
209 pub name: ::prost::alloc::string::String,
210}
211#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
213#[repr(i32)]
214pub enum Ownership {
215 Device = 0,
216 Server = 1,
217}
218impl Ownership {
219 pub fn as_str_name(&self) -> &'static str {
224 match self {
225 Self::Device => "DEVICE",
226 Self::Server => "SERVER",
227 }
228 }
229 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
231 match value {
232 "DEVICE" => Some(Self::Device),
233 "SERVER" => Some(Self::Server),
234 _ => None,
235 }
236 }
237}
238#[derive(Clone, PartialEq, ::prost::Message)]
240pub struct Property {
241 #[prost(string, tag = "1")]
243 pub interface_name: ::prost::alloc::string::String,
244 #[prost(string, tag = "2")]
246 pub path: ::prost::alloc::string::String,
247 #[prost(int32, tag = "3")]
249 pub version_major: i32,
250 #[prost(enumeration = "Ownership", tag = "4")]
252 pub ownership: i32,
253 #[prost(message, optional, tag = "5")]
255 pub data: ::core::option::Option<AstarteData>,
256}
257#[derive(Clone, PartialEq, ::prost::Message)]
259pub struct StoredProperties {
260 #[prost(message, repeated, tag = "1")]
262 pub properties: ::prost::alloc::vec::Vec<Property>,
263}
264#[derive(Clone, Copy, PartialEq, ::prost::Message)]
268pub struct PropertyFilter {
269 #[prost(enumeration = "Ownership", optional, tag = "1")]
271 pub ownership: ::core::option::Option<i32>,
272}
273#[derive(Clone, PartialEq, ::prost::Message)]
275pub struct PropertyIdentifier {
276 #[prost(string, tag = "1")]
278 pub interface_name: ::prost::alloc::string::String,
279 #[prost(string, tag = "2")]
281 pub path: ::prost::alloc::string::String,
282}
283pub mod message_hub_client {
285 #![allow(
286 unused_variables,
287 dead_code,
288 missing_docs,
289 clippy::wildcard_imports,
290 clippy::let_unit_value,
291 )]
292 use tonic::codegen::*;
293 use tonic::codegen::http::Uri;
294 #[derive(Debug, Clone)]
295 pub struct MessageHubClient<T> {
296 inner: tonic::client::Grpc<T>,
297 }
298 impl MessageHubClient<tonic::transport::Channel> {
299 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
301 where
302 D: TryInto<tonic::transport::Endpoint>,
303 D::Error: Into<StdError>,
304 {
305 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
306 Ok(Self::new(conn))
307 }
308 }
309 impl<T> MessageHubClient<T>
310 where
311 T: tonic::client::GrpcService<tonic::body::BoxBody>,
312 T::Error: Into<StdError>,
313 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
314 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
315 {
316 pub fn new(inner: T) -> Self {
317 let inner = tonic::client::Grpc::new(inner);
318 Self { inner }
319 }
320 pub fn with_origin(inner: T, origin: Uri) -> Self {
321 let inner = tonic::client::Grpc::with_origin(inner, origin);
322 Self { inner }
323 }
324 pub fn with_interceptor<F>(
325 inner: T,
326 interceptor: F,
327 ) -> MessageHubClient<InterceptedService<T, F>>
328 where
329 F: tonic::service::Interceptor,
330 T::ResponseBody: Default,
331 T: tonic::codegen::Service<
332 http::Request<tonic::body::BoxBody>,
333 Response = http::Response<
334 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
335 >,
336 >,
337 <T as tonic::codegen::Service<
338 http::Request<tonic::body::BoxBody>,
339 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
340 {
341 MessageHubClient::new(InterceptedService::new(inner, interceptor))
342 }
343 #[must_use]
348 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
349 self.inner = self.inner.send_compressed(encoding);
350 self
351 }
352 #[must_use]
354 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
355 self.inner = self.inner.accept_compressed(encoding);
356 self
357 }
358 #[must_use]
362 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
363 self.inner = self.inner.max_decoding_message_size(limit);
364 self
365 }
366 #[must_use]
370 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
371 self.inner = self.inner.max_encoding_message_size(limit);
372 self
373 }
374 pub async fn attach(
377 &mut self,
378 request: impl tonic::IntoRequest<super::Node>,
379 ) -> std::result::Result<
380 tonic::Response<tonic::codec::Streaming<super::MessageHubEvent>>,
381 tonic::Status,
382 > {
383 self.inner
384 .ready()
385 .await
386 .map_err(|e| {
387 tonic::Status::unknown(
388 format!("Service was not ready: {}", e.into()),
389 )
390 })?;
391 let codec = tonic::codec::ProstCodec::default();
392 let path = http::uri::PathAndQuery::from_static(
393 "/astarteplatform.msghub.MessageHub/Attach",
394 );
395 let mut req = request.into_request();
396 req.extensions_mut()
397 .insert(GrpcMethod::new("astarteplatform.msghub.MessageHub", "Attach"));
398 self.inner.server_streaming(req, path, codec).await
399 }
400 pub async fn send(
402 &mut self,
403 request: impl tonic::IntoRequest<super::AstarteMessage>,
404 ) -> std::result::Result<tonic::Response<::pbjson_types::Empty>, tonic::Status> {
405 self.inner
406 .ready()
407 .await
408 .map_err(|e| {
409 tonic::Status::unknown(
410 format!("Service was not ready: {}", e.into()),
411 )
412 })?;
413 let codec = tonic::codec::ProstCodec::default();
414 let path = http::uri::PathAndQuery::from_static(
415 "/astarteplatform.msghub.MessageHub/Send",
416 );
417 let mut req = request.into_request();
418 req.extensions_mut()
419 .insert(GrpcMethod::new("astarteplatform.msghub.MessageHub", "Send"));
420 self.inner.unary(req, path, codec).await
421 }
422 pub async fn detach(
424 &mut self,
425 request: impl tonic::IntoRequest<::pbjson_types::Empty>,
426 ) -> std::result::Result<tonic::Response<::pbjson_types::Empty>, tonic::Status> {
427 self.inner
428 .ready()
429 .await
430 .map_err(|e| {
431 tonic::Status::unknown(
432 format!("Service was not ready: {}", e.into()),
433 )
434 })?;
435 let codec = tonic::codec::ProstCodec::default();
436 let path = http::uri::PathAndQuery::from_static(
437 "/astarteplatform.msghub.MessageHub/Detach",
438 );
439 let mut req = request.into_request();
440 req.extensions_mut()
441 .insert(GrpcMethod::new("astarteplatform.msghub.MessageHub", "Detach"));
442 self.inner.unary(req, path, codec).await
443 }
444 pub async fn add_interfaces(
446 &mut self,
447 request: impl tonic::IntoRequest<super::InterfacesJson>,
448 ) -> std::result::Result<tonic::Response<::pbjson_types::Empty>, tonic::Status> {
449 self.inner
450 .ready()
451 .await
452 .map_err(|e| {
453 tonic::Status::unknown(
454 format!("Service was not ready: {}", e.into()),
455 )
456 })?;
457 let codec = tonic::codec::ProstCodec::default();
458 let path = http::uri::PathAndQuery::from_static(
459 "/astarteplatform.msghub.MessageHub/AddInterfaces",
460 );
461 let mut req = request.into_request();
462 req.extensions_mut()
463 .insert(
464 GrpcMethod::new("astarteplatform.msghub.MessageHub", "AddInterfaces"),
465 );
466 self.inner.unary(req, path, codec).await
467 }
468 pub async fn remove_interfaces(
470 &mut self,
471 request: impl tonic::IntoRequest<super::InterfacesName>,
472 ) -> std::result::Result<tonic::Response<::pbjson_types::Empty>, tonic::Status> {
473 self.inner
474 .ready()
475 .await
476 .map_err(|e| {
477 tonic::Status::unknown(
478 format!("Service was not ready: {}", e.into()),
479 )
480 })?;
481 let codec = tonic::codec::ProstCodec::default();
482 let path = http::uri::PathAndQuery::from_static(
483 "/astarteplatform.msghub.MessageHub/RemoveInterfaces",
484 );
485 let mut req = request.into_request();
486 req.extensions_mut()
487 .insert(
488 GrpcMethod::new(
489 "astarteplatform.msghub.MessageHub",
490 "RemoveInterfaces",
491 ),
492 );
493 self.inner.unary(req, path, codec).await
494 }
495 pub async fn get_properties(
497 &mut self,
498 request: impl tonic::IntoRequest<super::InterfaceName>,
499 ) -> std::result::Result<
500 tonic::Response<super::StoredProperties>,
501 tonic::Status,
502 > {
503 self.inner
504 .ready()
505 .await
506 .map_err(|e| {
507 tonic::Status::unknown(
508 format!("Service was not ready: {}", e.into()),
509 )
510 })?;
511 let codec = tonic::codec::ProstCodec::default();
512 let path = http::uri::PathAndQuery::from_static(
513 "/astarteplatform.msghub.MessageHub/GetProperties",
514 );
515 let mut req = request.into_request();
516 req.extensions_mut()
517 .insert(
518 GrpcMethod::new("astarteplatform.msghub.MessageHub", "GetProperties"),
519 );
520 self.inner.unary(req, path, codec).await
521 }
522 pub async fn get_all_properties(
524 &mut self,
525 request: impl tonic::IntoRequest<super::PropertyFilter>,
526 ) -> std::result::Result<
527 tonic::Response<super::StoredProperties>,
528 tonic::Status,
529 > {
530 self.inner
531 .ready()
532 .await
533 .map_err(|e| {
534 tonic::Status::unknown(
535 format!("Service was not ready: {}", e.into()),
536 )
537 })?;
538 let codec = tonic::codec::ProstCodec::default();
539 let path = http::uri::PathAndQuery::from_static(
540 "/astarteplatform.msghub.MessageHub/GetAllProperties",
541 );
542 let mut req = request.into_request();
543 req.extensions_mut()
544 .insert(
545 GrpcMethod::new(
546 "astarteplatform.msghub.MessageHub",
547 "GetAllProperties",
548 ),
549 );
550 self.inner.unary(req, path, codec).await
551 }
552 pub async fn get_property(
554 &mut self,
555 request: impl tonic::IntoRequest<super::PropertyIdentifier>,
556 ) -> std::result::Result<
557 tonic::Response<super::AstartePropertyIndividual>,
558 tonic::Status,
559 > {
560 self.inner
561 .ready()
562 .await
563 .map_err(|e| {
564 tonic::Status::unknown(
565 format!("Service was not ready: {}", e.into()),
566 )
567 })?;
568 let codec = tonic::codec::ProstCodec::default();
569 let path = http::uri::PathAndQuery::from_static(
570 "/astarteplatform.msghub.MessageHub/GetProperty",
571 );
572 let mut req = request.into_request();
573 req.extensions_mut()
574 .insert(
575 GrpcMethod::new("astarteplatform.msghub.MessageHub", "GetProperty"),
576 );
577 self.inner.unary(req, path, codec).await
578 }
579 }
580}
581pub mod message_hub_server {
583 #![allow(
584 unused_variables,
585 dead_code,
586 missing_docs,
587 clippy::wildcard_imports,
588 clippy::let_unit_value,
589 )]
590 use tonic::codegen::*;
591 #[async_trait]
593 pub trait MessageHub: std::marker::Send + std::marker::Sync + 'static {
594 type AttachStream: tonic::codegen::tokio_stream::Stream<
596 Item = std::result::Result<super::MessageHubEvent, tonic::Status>,
597 >
598 + std::marker::Send
599 + 'static;
600 async fn attach(
603 &self,
604 request: tonic::Request<super::Node>,
605 ) -> std::result::Result<tonic::Response<Self::AttachStream>, tonic::Status>;
606 async fn send(
608 &self,
609 request: tonic::Request<super::AstarteMessage>,
610 ) -> std::result::Result<tonic::Response<::pbjson_types::Empty>, tonic::Status>;
611 async fn detach(
613 &self,
614 request: tonic::Request<::pbjson_types::Empty>,
615 ) -> std::result::Result<tonic::Response<::pbjson_types::Empty>, tonic::Status>;
616 async fn add_interfaces(
618 &self,
619 request: tonic::Request<super::InterfacesJson>,
620 ) -> std::result::Result<tonic::Response<::pbjson_types::Empty>, tonic::Status>;
621 async fn remove_interfaces(
623 &self,
624 request: tonic::Request<super::InterfacesName>,
625 ) -> std::result::Result<tonic::Response<::pbjson_types::Empty>, tonic::Status>;
626 async fn get_properties(
628 &self,
629 request: tonic::Request<super::InterfaceName>,
630 ) -> std::result::Result<
631 tonic::Response<super::StoredProperties>,
632 tonic::Status,
633 >;
634 async fn get_all_properties(
636 &self,
637 request: tonic::Request<super::PropertyFilter>,
638 ) -> std::result::Result<
639 tonic::Response<super::StoredProperties>,
640 tonic::Status,
641 >;
642 async fn get_property(
644 &self,
645 request: tonic::Request<super::PropertyIdentifier>,
646 ) -> std::result::Result<
647 tonic::Response<super::AstartePropertyIndividual>,
648 tonic::Status,
649 >;
650 }
651 #[derive(Debug)]
652 pub struct MessageHubServer<T> {
653 inner: Arc<T>,
654 accept_compression_encodings: EnabledCompressionEncodings,
655 send_compression_encodings: EnabledCompressionEncodings,
656 max_decoding_message_size: Option<usize>,
657 max_encoding_message_size: Option<usize>,
658 }
659 impl<T> MessageHubServer<T> {
660 pub fn new(inner: T) -> Self {
661 Self::from_arc(Arc::new(inner))
662 }
663 pub fn from_arc(inner: Arc<T>) -> Self {
664 Self {
665 inner,
666 accept_compression_encodings: Default::default(),
667 send_compression_encodings: Default::default(),
668 max_decoding_message_size: None,
669 max_encoding_message_size: None,
670 }
671 }
672 pub fn with_interceptor<F>(
673 inner: T,
674 interceptor: F,
675 ) -> InterceptedService<Self, F>
676 where
677 F: tonic::service::Interceptor,
678 {
679 InterceptedService::new(Self::new(inner), interceptor)
680 }
681 #[must_use]
683 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
684 self.accept_compression_encodings.enable(encoding);
685 self
686 }
687 #[must_use]
689 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
690 self.send_compression_encodings.enable(encoding);
691 self
692 }
693 #[must_use]
697 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
698 self.max_decoding_message_size = Some(limit);
699 self
700 }
701 #[must_use]
705 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
706 self.max_encoding_message_size = Some(limit);
707 self
708 }
709 }
710 impl<T, B> tonic::codegen::Service<http::Request<B>> for MessageHubServer<T>
711 where
712 T: MessageHub,
713 B: Body + std::marker::Send + 'static,
714 B::Error: Into<StdError> + std::marker::Send + 'static,
715 {
716 type Response = http::Response<tonic::body::BoxBody>;
717 type Error = std::convert::Infallible;
718 type Future = BoxFuture<Self::Response, Self::Error>;
719 fn poll_ready(
720 &mut self,
721 _cx: &mut Context<'_>,
722 ) -> Poll<std::result::Result<(), Self::Error>> {
723 Poll::Ready(Ok(()))
724 }
725 fn call(&mut self, req: http::Request<B>) -> Self::Future {
726 match req.uri().path() {
727 "/astarteplatform.msghub.MessageHub/Attach" => {
728 #[allow(non_camel_case_types)]
729 struct AttachSvc<T: MessageHub>(pub Arc<T>);
730 impl<
731 T: MessageHub,
732 > tonic::server::ServerStreamingService<super::Node>
733 for AttachSvc<T> {
734 type Response = super::MessageHubEvent;
735 type ResponseStream = T::AttachStream;
736 type Future = BoxFuture<
737 tonic::Response<Self::ResponseStream>,
738 tonic::Status,
739 >;
740 fn call(
741 &mut self,
742 request: tonic::Request<super::Node>,
743 ) -> Self::Future {
744 let inner = Arc::clone(&self.0);
745 let fut = async move {
746 <T as MessageHub>::attach(&inner, request).await
747 };
748 Box::pin(fut)
749 }
750 }
751 let accept_compression_encodings = self.accept_compression_encodings;
752 let send_compression_encodings = self.send_compression_encodings;
753 let max_decoding_message_size = self.max_decoding_message_size;
754 let max_encoding_message_size = self.max_encoding_message_size;
755 let inner = self.inner.clone();
756 let fut = async move {
757 let method = AttachSvc(inner);
758 let codec = tonic::codec::ProstCodec::default();
759 let mut grpc = tonic::server::Grpc::new(codec)
760 .apply_compression_config(
761 accept_compression_encodings,
762 send_compression_encodings,
763 )
764 .apply_max_message_size_config(
765 max_decoding_message_size,
766 max_encoding_message_size,
767 );
768 let res = grpc.server_streaming(method, req).await;
769 Ok(res)
770 };
771 Box::pin(fut)
772 }
773 "/astarteplatform.msghub.MessageHub/Send" => {
774 #[allow(non_camel_case_types)]
775 struct SendSvc<T: MessageHub>(pub Arc<T>);
776 impl<
777 T: MessageHub,
778 > tonic::server::UnaryService<super::AstarteMessage> for SendSvc<T> {
779 type Response = ::pbjson_types::Empty;
780 type Future = BoxFuture<
781 tonic::Response<Self::Response>,
782 tonic::Status,
783 >;
784 fn call(
785 &mut self,
786 request: tonic::Request<super::AstarteMessage>,
787 ) -> Self::Future {
788 let inner = Arc::clone(&self.0);
789 let fut = async move {
790 <T as MessageHub>::send(&inner, request).await
791 };
792 Box::pin(fut)
793 }
794 }
795 let accept_compression_encodings = self.accept_compression_encodings;
796 let send_compression_encodings = self.send_compression_encodings;
797 let max_decoding_message_size = self.max_decoding_message_size;
798 let max_encoding_message_size = self.max_encoding_message_size;
799 let inner = self.inner.clone();
800 let fut = async move {
801 let method = SendSvc(inner);
802 let codec = tonic::codec::ProstCodec::default();
803 let mut grpc = tonic::server::Grpc::new(codec)
804 .apply_compression_config(
805 accept_compression_encodings,
806 send_compression_encodings,
807 )
808 .apply_max_message_size_config(
809 max_decoding_message_size,
810 max_encoding_message_size,
811 );
812 let res = grpc.unary(method, req).await;
813 Ok(res)
814 };
815 Box::pin(fut)
816 }
817 "/astarteplatform.msghub.MessageHub/Detach" => {
818 #[allow(non_camel_case_types)]
819 struct DetachSvc<T: MessageHub>(pub Arc<T>);
820 impl<
821 T: MessageHub,
822 > tonic::server::UnaryService<::pbjson_types::Empty>
823 for DetachSvc<T> {
824 type Response = ::pbjson_types::Empty;
825 type Future = BoxFuture<
826 tonic::Response<Self::Response>,
827 tonic::Status,
828 >;
829 fn call(
830 &mut self,
831 request: tonic::Request<::pbjson_types::Empty>,
832 ) -> Self::Future {
833 let inner = Arc::clone(&self.0);
834 let fut = async move {
835 <T as MessageHub>::detach(&inner, request).await
836 };
837 Box::pin(fut)
838 }
839 }
840 let accept_compression_encodings = self.accept_compression_encodings;
841 let send_compression_encodings = self.send_compression_encodings;
842 let max_decoding_message_size = self.max_decoding_message_size;
843 let max_encoding_message_size = self.max_encoding_message_size;
844 let inner = self.inner.clone();
845 let fut = async move {
846 let method = DetachSvc(inner);
847 let codec = tonic::codec::ProstCodec::default();
848 let mut grpc = tonic::server::Grpc::new(codec)
849 .apply_compression_config(
850 accept_compression_encodings,
851 send_compression_encodings,
852 )
853 .apply_max_message_size_config(
854 max_decoding_message_size,
855 max_encoding_message_size,
856 );
857 let res = grpc.unary(method, req).await;
858 Ok(res)
859 };
860 Box::pin(fut)
861 }
862 "/astarteplatform.msghub.MessageHub/AddInterfaces" => {
863 #[allow(non_camel_case_types)]
864 struct AddInterfacesSvc<T: MessageHub>(pub Arc<T>);
865 impl<
866 T: MessageHub,
867 > tonic::server::UnaryService<super::InterfacesJson>
868 for AddInterfacesSvc<T> {
869 type Response = ::pbjson_types::Empty;
870 type Future = BoxFuture<
871 tonic::Response<Self::Response>,
872 tonic::Status,
873 >;
874 fn call(
875 &mut self,
876 request: tonic::Request<super::InterfacesJson>,
877 ) -> Self::Future {
878 let inner = Arc::clone(&self.0);
879 let fut = async move {
880 <T as MessageHub>::add_interfaces(&inner, request).await
881 };
882 Box::pin(fut)
883 }
884 }
885 let accept_compression_encodings = self.accept_compression_encodings;
886 let send_compression_encodings = self.send_compression_encodings;
887 let max_decoding_message_size = self.max_decoding_message_size;
888 let max_encoding_message_size = self.max_encoding_message_size;
889 let inner = self.inner.clone();
890 let fut = async move {
891 let method = AddInterfacesSvc(inner);
892 let codec = tonic::codec::ProstCodec::default();
893 let mut grpc = tonic::server::Grpc::new(codec)
894 .apply_compression_config(
895 accept_compression_encodings,
896 send_compression_encodings,
897 )
898 .apply_max_message_size_config(
899 max_decoding_message_size,
900 max_encoding_message_size,
901 );
902 let res = grpc.unary(method, req).await;
903 Ok(res)
904 };
905 Box::pin(fut)
906 }
907 "/astarteplatform.msghub.MessageHub/RemoveInterfaces" => {
908 #[allow(non_camel_case_types)]
909 struct RemoveInterfacesSvc<T: MessageHub>(pub Arc<T>);
910 impl<
911 T: MessageHub,
912 > tonic::server::UnaryService<super::InterfacesName>
913 for RemoveInterfacesSvc<T> {
914 type Response = ::pbjson_types::Empty;
915 type Future = BoxFuture<
916 tonic::Response<Self::Response>,
917 tonic::Status,
918 >;
919 fn call(
920 &mut self,
921 request: tonic::Request<super::InterfacesName>,
922 ) -> Self::Future {
923 let inner = Arc::clone(&self.0);
924 let fut = async move {
925 <T as MessageHub>::remove_interfaces(&inner, request).await
926 };
927 Box::pin(fut)
928 }
929 }
930 let accept_compression_encodings = self.accept_compression_encodings;
931 let send_compression_encodings = self.send_compression_encodings;
932 let max_decoding_message_size = self.max_decoding_message_size;
933 let max_encoding_message_size = self.max_encoding_message_size;
934 let inner = self.inner.clone();
935 let fut = async move {
936 let method = RemoveInterfacesSvc(inner);
937 let codec = tonic::codec::ProstCodec::default();
938 let mut grpc = tonic::server::Grpc::new(codec)
939 .apply_compression_config(
940 accept_compression_encodings,
941 send_compression_encodings,
942 )
943 .apply_max_message_size_config(
944 max_decoding_message_size,
945 max_encoding_message_size,
946 );
947 let res = grpc.unary(method, req).await;
948 Ok(res)
949 };
950 Box::pin(fut)
951 }
952 "/astarteplatform.msghub.MessageHub/GetProperties" => {
953 #[allow(non_camel_case_types)]
954 struct GetPropertiesSvc<T: MessageHub>(pub Arc<T>);
955 impl<T: MessageHub> tonic::server::UnaryService<super::InterfaceName>
956 for GetPropertiesSvc<T> {
957 type Response = super::StoredProperties;
958 type Future = BoxFuture<
959 tonic::Response<Self::Response>,
960 tonic::Status,
961 >;
962 fn call(
963 &mut self,
964 request: tonic::Request<super::InterfaceName>,
965 ) -> Self::Future {
966 let inner = Arc::clone(&self.0);
967 let fut = async move {
968 <T as MessageHub>::get_properties(&inner, request).await
969 };
970 Box::pin(fut)
971 }
972 }
973 let accept_compression_encodings = self.accept_compression_encodings;
974 let send_compression_encodings = self.send_compression_encodings;
975 let max_decoding_message_size = self.max_decoding_message_size;
976 let max_encoding_message_size = self.max_encoding_message_size;
977 let inner = self.inner.clone();
978 let fut = async move {
979 let method = GetPropertiesSvc(inner);
980 let codec = tonic::codec::ProstCodec::default();
981 let mut grpc = tonic::server::Grpc::new(codec)
982 .apply_compression_config(
983 accept_compression_encodings,
984 send_compression_encodings,
985 )
986 .apply_max_message_size_config(
987 max_decoding_message_size,
988 max_encoding_message_size,
989 );
990 let res = grpc.unary(method, req).await;
991 Ok(res)
992 };
993 Box::pin(fut)
994 }
995 "/astarteplatform.msghub.MessageHub/GetAllProperties" => {
996 #[allow(non_camel_case_types)]
997 struct GetAllPropertiesSvc<T: MessageHub>(pub Arc<T>);
998 impl<
999 T: MessageHub,
1000 > tonic::server::UnaryService<super::PropertyFilter>
1001 for GetAllPropertiesSvc<T> {
1002 type Response = super::StoredProperties;
1003 type Future = BoxFuture<
1004 tonic::Response<Self::Response>,
1005 tonic::Status,
1006 >;
1007 fn call(
1008 &mut self,
1009 request: tonic::Request<super::PropertyFilter>,
1010 ) -> Self::Future {
1011 let inner = Arc::clone(&self.0);
1012 let fut = async move {
1013 <T as MessageHub>::get_all_properties(&inner, request).await
1014 };
1015 Box::pin(fut)
1016 }
1017 }
1018 let accept_compression_encodings = self.accept_compression_encodings;
1019 let send_compression_encodings = self.send_compression_encodings;
1020 let max_decoding_message_size = self.max_decoding_message_size;
1021 let max_encoding_message_size = self.max_encoding_message_size;
1022 let inner = self.inner.clone();
1023 let fut = async move {
1024 let method = GetAllPropertiesSvc(inner);
1025 let codec = tonic::codec::ProstCodec::default();
1026 let mut grpc = tonic::server::Grpc::new(codec)
1027 .apply_compression_config(
1028 accept_compression_encodings,
1029 send_compression_encodings,
1030 )
1031 .apply_max_message_size_config(
1032 max_decoding_message_size,
1033 max_encoding_message_size,
1034 );
1035 let res = grpc.unary(method, req).await;
1036 Ok(res)
1037 };
1038 Box::pin(fut)
1039 }
1040 "/astarteplatform.msghub.MessageHub/GetProperty" => {
1041 #[allow(non_camel_case_types)]
1042 struct GetPropertySvc<T: MessageHub>(pub Arc<T>);
1043 impl<
1044 T: MessageHub,
1045 > tonic::server::UnaryService<super::PropertyIdentifier>
1046 for GetPropertySvc<T> {
1047 type Response = super::AstartePropertyIndividual;
1048 type Future = BoxFuture<
1049 tonic::Response<Self::Response>,
1050 tonic::Status,
1051 >;
1052 fn call(
1053 &mut self,
1054 request: tonic::Request<super::PropertyIdentifier>,
1055 ) -> Self::Future {
1056 let inner = Arc::clone(&self.0);
1057 let fut = async move {
1058 <T as MessageHub>::get_property(&inner, request).await
1059 };
1060 Box::pin(fut)
1061 }
1062 }
1063 let accept_compression_encodings = self.accept_compression_encodings;
1064 let send_compression_encodings = self.send_compression_encodings;
1065 let max_decoding_message_size = self.max_decoding_message_size;
1066 let max_encoding_message_size = self.max_encoding_message_size;
1067 let inner = self.inner.clone();
1068 let fut = async move {
1069 let method = GetPropertySvc(inner);
1070 let codec = tonic::codec::ProstCodec::default();
1071 let mut grpc = tonic::server::Grpc::new(codec)
1072 .apply_compression_config(
1073 accept_compression_encodings,
1074 send_compression_encodings,
1075 )
1076 .apply_max_message_size_config(
1077 max_decoding_message_size,
1078 max_encoding_message_size,
1079 );
1080 let res = grpc.unary(method, req).await;
1081 Ok(res)
1082 };
1083 Box::pin(fut)
1084 }
1085 _ => {
1086 Box::pin(async move {
1087 let mut response = http::Response::new(empty_body());
1088 let headers = response.headers_mut();
1089 headers
1090 .insert(
1091 tonic::Status::GRPC_STATUS,
1092 (tonic::Code::Unimplemented as i32).into(),
1093 );
1094 headers
1095 .insert(
1096 http::header::CONTENT_TYPE,
1097 tonic::metadata::GRPC_CONTENT_TYPE,
1098 );
1099 Ok(response)
1100 })
1101 }
1102 }
1103 }
1104 }
1105 impl<T> Clone for MessageHubServer<T> {
1106 fn clone(&self) -> Self {
1107 let inner = self.inner.clone();
1108 Self {
1109 inner,
1110 accept_compression_encodings: self.accept_compression_encodings,
1111 send_compression_encodings: self.send_compression_encodings,
1112 max_decoding_message_size: self.max_decoding_message_size,
1113 max_encoding_message_size: self.max_encoding_message_size,
1114 }
1115 }
1116 }
1117 pub const SERVICE_NAME: &str = "astarteplatform.msghub.MessageHub";
1119 impl<T> tonic::server::NamedService for MessageHubServer<T> {
1120 const NAME: &'static str = SERVICE_NAME;
1121 }
1122}
1123#[derive(Clone, PartialEq, ::prost::Message)]
1125pub struct ConfigMessage {
1126 #[prost(string, tag = "1")]
1127 pub realm: ::prost::alloc::string::String,
1128 #[prost(string, optional, tag = "2")]
1129 pub device_id: ::core::option::Option<::prost::alloc::string::String>,
1130 #[prost(string, optional, tag = "3")]
1131 pub credentials_secret: ::core::option::Option<::prost::alloc::string::String>,
1132 #[prost(string, tag = "4")]
1133 pub pairing_url: ::prost::alloc::string::String,
1134 #[prost(string, optional, tag = "5")]
1135 pub pairing_token: ::core::option::Option<::prost::alloc::string::String>,
1136 #[prost(uint32, optional, tag = "6")]
1137 pub grpc_socket_port: ::core::option::Option<u32>,
1138 #[prost(string, optional, tag = "7")]
1139 pub grpc_socket_host: ::core::option::Option<::prost::alloc::string::String>,
1140}
1141pub mod message_hub_config_client {
1143 #![allow(
1144 unused_variables,
1145 dead_code,
1146 missing_docs,
1147 clippy::wildcard_imports,
1148 clippy::let_unit_value,
1149 )]
1150 use tonic::codegen::*;
1151 use tonic::codegen::http::Uri;
1152 #[derive(Debug, Clone)]
1153 pub struct MessageHubConfigClient<T> {
1154 inner: tonic::client::Grpc<T>,
1155 }
1156 impl MessageHubConfigClient<tonic::transport::Channel> {
1157 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
1159 where
1160 D: TryInto<tonic::transport::Endpoint>,
1161 D::Error: Into<StdError>,
1162 {
1163 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
1164 Ok(Self::new(conn))
1165 }
1166 }
1167 impl<T> MessageHubConfigClient<T>
1168 where
1169 T: tonic::client::GrpcService<tonic::body::BoxBody>,
1170 T::Error: Into<StdError>,
1171 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
1172 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
1173 {
1174 pub fn new(inner: T) -> Self {
1175 let inner = tonic::client::Grpc::new(inner);
1176 Self { inner }
1177 }
1178 pub fn with_origin(inner: T, origin: Uri) -> Self {
1179 let inner = tonic::client::Grpc::with_origin(inner, origin);
1180 Self { inner }
1181 }
1182 pub fn with_interceptor<F>(
1183 inner: T,
1184 interceptor: F,
1185 ) -> MessageHubConfigClient<InterceptedService<T, F>>
1186 where
1187 F: tonic::service::Interceptor,
1188 T::ResponseBody: Default,
1189 T: tonic::codegen::Service<
1190 http::Request<tonic::body::BoxBody>,
1191 Response = http::Response<
1192 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
1193 >,
1194 >,
1195 <T as tonic::codegen::Service<
1196 http::Request<tonic::body::BoxBody>,
1197 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
1198 {
1199 MessageHubConfigClient::new(InterceptedService::new(inner, interceptor))
1200 }
1201 #[must_use]
1206 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
1207 self.inner = self.inner.send_compressed(encoding);
1208 self
1209 }
1210 #[must_use]
1212 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
1213 self.inner = self.inner.accept_compressed(encoding);
1214 self
1215 }
1216 #[must_use]
1220 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
1221 self.inner = self.inner.max_decoding_message_size(limit);
1222 self
1223 }
1224 #[must_use]
1228 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
1229 self.inner = self.inner.max_encoding_message_size(limit);
1230 self
1231 }
1232 pub async fn set_config(
1234 &mut self,
1235 request: impl tonic::IntoRequest<super::ConfigMessage>,
1236 ) -> std::result::Result<tonic::Response<::pbjson_types::Empty>, tonic::Status> {
1237 self.inner
1238 .ready()
1239 .await
1240 .map_err(|e| {
1241 tonic::Status::unknown(
1242 format!("Service was not ready: {}", e.into()),
1243 )
1244 })?;
1245 let codec = tonic::codec::ProstCodec::default();
1246 let path = http::uri::PathAndQuery::from_static(
1247 "/astarteplatform.msghub.MessageHubConfig/SetConfig",
1248 );
1249 let mut req = request.into_request();
1250 req.extensions_mut()
1251 .insert(
1252 GrpcMethod::new(
1253 "astarteplatform.msghub.MessageHubConfig",
1254 "SetConfig",
1255 ),
1256 );
1257 self.inner.unary(req, path, codec).await
1258 }
1259 }
1260}
1261pub mod message_hub_config_server {
1263 #![allow(
1264 unused_variables,
1265 dead_code,
1266 missing_docs,
1267 clippy::wildcard_imports,
1268 clippy::let_unit_value,
1269 )]
1270 use tonic::codegen::*;
1271 #[async_trait]
1273 pub trait MessageHubConfig: std::marker::Send + std::marker::Sync + 'static {
1274 async fn set_config(
1276 &self,
1277 request: tonic::Request<super::ConfigMessage>,
1278 ) -> std::result::Result<tonic::Response<::pbjson_types::Empty>, tonic::Status>;
1279 }
1280 #[derive(Debug)]
1281 pub struct MessageHubConfigServer<T> {
1282 inner: Arc<T>,
1283 accept_compression_encodings: EnabledCompressionEncodings,
1284 send_compression_encodings: EnabledCompressionEncodings,
1285 max_decoding_message_size: Option<usize>,
1286 max_encoding_message_size: Option<usize>,
1287 }
1288 impl<T> MessageHubConfigServer<T> {
1289 pub fn new(inner: T) -> Self {
1290 Self::from_arc(Arc::new(inner))
1291 }
1292 pub fn from_arc(inner: Arc<T>) -> Self {
1293 Self {
1294 inner,
1295 accept_compression_encodings: Default::default(),
1296 send_compression_encodings: Default::default(),
1297 max_decoding_message_size: None,
1298 max_encoding_message_size: None,
1299 }
1300 }
1301 pub fn with_interceptor<F>(
1302 inner: T,
1303 interceptor: F,
1304 ) -> InterceptedService<Self, F>
1305 where
1306 F: tonic::service::Interceptor,
1307 {
1308 InterceptedService::new(Self::new(inner), interceptor)
1309 }
1310 #[must_use]
1312 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
1313 self.accept_compression_encodings.enable(encoding);
1314 self
1315 }
1316 #[must_use]
1318 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
1319 self.send_compression_encodings.enable(encoding);
1320 self
1321 }
1322 #[must_use]
1326 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
1327 self.max_decoding_message_size = Some(limit);
1328 self
1329 }
1330 #[must_use]
1334 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
1335 self.max_encoding_message_size = Some(limit);
1336 self
1337 }
1338 }
1339 impl<T, B> tonic::codegen::Service<http::Request<B>> for MessageHubConfigServer<T>
1340 where
1341 T: MessageHubConfig,
1342 B: Body + std::marker::Send + 'static,
1343 B::Error: Into<StdError> + std::marker::Send + 'static,
1344 {
1345 type Response = http::Response<tonic::body::BoxBody>;
1346 type Error = std::convert::Infallible;
1347 type Future = BoxFuture<Self::Response, Self::Error>;
1348 fn poll_ready(
1349 &mut self,
1350 _cx: &mut Context<'_>,
1351 ) -> Poll<std::result::Result<(), Self::Error>> {
1352 Poll::Ready(Ok(()))
1353 }
1354 fn call(&mut self, req: http::Request<B>) -> Self::Future {
1355 match req.uri().path() {
1356 "/astarteplatform.msghub.MessageHubConfig/SetConfig" => {
1357 #[allow(non_camel_case_types)]
1358 struct SetConfigSvc<T: MessageHubConfig>(pub Arc<T>);
1359 impl<
1360 T: MessageHubConfig,
1361 > tonic::server::UnaryService<super::ConfigMessage>
1362 for SetConfigSvc<T> {
1363 type Response = ::pbjson_types::Empty;
1364 type Future = BoxFuture<
1365 tonic::Response<Self::Response>,
1366 tonic::Status,
1367 >;
1368 fn call(
1369 &mut self,
1370 request: tonic::Request<super::ConfigMessage>,
1371 ) -> Self::Future {
1372 let inner = Arc::clone(&self.0);
1373 let fut = async move {
1374 <T as MessageHubConfig>::set_config(&inner, request).await
1375 };
1376 Box::pin(fut)
1377 }
1378 }
1379 let accept_compression_encodings = self.accept_compression_encodings;
1380 let send_compression_encodings = self.send_compression_encodings;
1381 let max_decoding_message_size = self.max_decoding_message_size;
1382 let max_encoding_message_size = self.max_encoding_message_size;
1383 let inner = self.inner.clone();
1384 let fut = async move {
1385 let method = SetConfigSvc(inner);
1386 let codec = tonic::codec::ProstCodec::default();
1387 let mut grpc = tonic::server::Grpc::new(codec)
1388 .apply_compression_config(
1389 accept_compression_encodings,
1390 send_compression_encodings,
1391 )
1392 .apply_max_message_size_config(
1393 max_decoding_message_size,
1394 max_encoding_message_size,
1395 );
1396 let res = grpc.unary(method, req).await;
1397 Ok(res)
1398 };
1399 Box::pin(fut)
1400 }
1401 _ => {
1402 Box::pin(async move {
1403 let mut response = http::Response::new(empty_body());
1404 let headers = response.headers_mut();
1405 headers
1406 .insert(
1407 tonic::Status::GRPC_STATUS,
1408 (tonic::Code::Unimplemented as i32).into(),
1409 );
1410 headers
1411 .insert(
1412 http::header::CONTENT_TYPE,
1413 tonic::metadata::GRPC_CONTENT_TYPE,
1414 );
1415 Ok(response)
1416 })
1417 }
1418 }
1419 }
1420 }
1421 impl<T> Clone for MessageHubConfigServer<T> {
1422 fn clone(&self) -> Self {
1423 let inner = self.inner.clone();
1424 Self {
1425 inner,
1426 accept_compression_encodings: self.accept_compression_encodings,
1427 send_compression_encodings: self.send_compression_encodings,
1428 max_decoding_message_size: self.max_decoding_message_size,
1429 max_encoding_message_size: self.max_encoding_message_size,
1430 }
1431 }
1432 }
1433 pub const SERVICE_NAME: &str = "astarteplatform.msghub.MessageHubConfig";
1435 impl<T> tonic::server::NamedService for MessageHubConfigServer<T> {
1436 const NAME: &'static str = SERVICE_NAME;
1437 }
1438}