slim_controller/api/gen/
controller.proto.v1.rs

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