mav_sdk/grpc/
mavsdk.rpc.core.rs

1#[derive(Clone, PartialEq, ::prost::Message)]
2pub struct SubscribeConnectionStateRequest {}
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct ConnectionStateResponse {
5    /// Connection state
6    #[prost(message, optional, tag = "1")]
7    pub connection_state: ::core::option::Option<ConnectionState>,
8}
9#[derive(Clone, PartialEq, ::prost::Message)]
10pub struct ListRunningPluginsRequest {}
11#[derive(Clone, PartialEq, ::prost::Message)]
12pub struct ListRunningPluginsResponse {
13    /// Plugin info
14    #[prost(message, repeated, tag = "1")]
15    pub plugin_info: ::prost::alloc::vec::Vec<PluginInfo>,
16}
17/// Connection state type.
18#[derive(Clone, PartialEq, ::prost::Message)]
19pub struct ConnectionState {
20    /// UUID of the vehicle
21    #[prost(uint64, tag = "1")]
22    pub uuid: u64,
23    /// Whether the vehicle got connected or disconnected
24    #[prost(bool, tag = "2")]
25    pub is_connected: bool,
26}
27/// Plugin info type.
28#[derive(Clone, PartialEq, ::prost::Message)]
29pub struct PluginInfo {
30    /// Name of the plugin
31    #[prost(string, tag = "1")]
32    pub name: ::prost::alloc::string::String,
33    /// Address where the plugin is running
34    #[prost(string, tag = "2")]
35    pub address: ::prost::alloc::string::String,
36    /// Port where the plugin is running
37    #[prost(int32, tag = "3")]
38    pub port: i32,
39}
40#[doc = r" Generated client implementations."]
41pub mod core_service_client {
42    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
43    use tonic::codegen::*;
44    #[doc = " Access to the connection state and running plugins."]
45    #[derive(Debug, Clone)]
46    pub struct CoreServiceClient<T> {
47        inner: tonic::client::Grpc<T>,
48    }
49    impl CoreServiceClient<tonic::transport::Channel> {
50        #[doc = r" Attempt to create a new client by connecting to a given endpoint."]
51        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
52        where
53            D: std::convert::TryInto<tonic::transport::Endpoint>,
54            D::Error: Into<StdError>,
55        {
56            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
57            Ok(Self::new(conn))
58        }
59    }
60    impl<T> CoreServiceClient<T>
61    where
62        T: tonic::client::GrpcService<tonic::body::BoxBody>,
63        T::ResponseBody: Body + Send + Sync + 'static,
64        T::Error: Into<StdError>,
65        <T::ResponseBody as Body>::Error: Into<StdError> + Send,
66    {
67        pub fn new(inner: T) -> Self {
68            let inner = tonic::client::Grpc::new(inner);
69            Self { inner }
70        }
71        pub fn with_interceptor<F>(
72            inner: T,
73            interceptor: F,
74        ) -> CoreServiceClient<InterceptedService<T, F>>
75        where
76            F: tonic::service::Interceptor,
77            T: tonic::codegen::Service<
78                http::Request<tonic::body::BoxBody>,
79                Response = http::Response<
80                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
81                >,
82            >,
83            <T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error:
84                Into<StdError> + Send + Sync,
85        {
86            CoreServiceClient::new(InterceptedService::new(inner, interceptor))
87        }
88        #[doc = r" Compress requests with `gzip`."]
89        #[doc = r""]
90        #[doc = r" This requires the server to support it otherwise it might respond with an"]
91        #[doc = r" error."]
92        pub fn send_gzip(mut self) -> Self {
93            self.inner = self.inner.send_gzip();
94            self
95        }
96        #[doc = r" Enable decompressing responses with `gzip`."]
97        pub fn accept_gzip(mut self) -> Self {
98            self.inner = self.inner.accept_gzip();
99            self
100        }
101        #[doc = " Subscribe to 'connection state' updates."]
102        pub async fn subscribe_connection_state(
103            &mut self,
104            request: impl tonic::IntoRequest<super::SubscribeConnectionStateRequest>,
105        ) -> Result<
106            tonic::Response<tonic::codec::Streaming<super::ConnectionStateResponse>>,
107            tonic::Status,
108        > {
109            self.inner.ready().await.map_err(|e| {
110                tonic::Status::new(
111                    tonic::Code::Unknown,
112                    format!("Service was not ready: {}", e.into()),
113                )
114            })?;
115            let codec = tonic::codec::ProstCodec::default();
116            let path = http::uri::PathAndQuery::from_static(
117                "/mavsdk.rpc.core.CoreService/SubscribeConnectionState",
118            );
119            self.inner
120                .server_streaming(request.into_request(), path, codec)
121                .await
122        }
123        #[doc = " Get a list of currently running plugins."]
124        pub async fn list_running_plugins(
125            &mut self,
126            request: impl tonic::IntoRequest<super::ListRunningPluginsRequest>,
127        ) -> Result<tonic::Response<super::ListRunningPluginsResponse>, tonic::Status> {
128            self.inner.ready().await.map_err(|e| {
129                tonic::Status::new(
130                    tonic::Code::Unknown,
131                    format!("Service was not ready: {}", e.into()),
132                )
133            })?;
134            let codec = tonic::codec::ProstCodec::default();
135            let path = http::uri::PathAndQuery::from_static(
136                "/mavsdk.rpc.core.CoreService/ListRunningPlugins",
137            );
138            self.inner.unary(request.into_request(), path, codec).await
139        }
140    }
141}
142#[doc = r" Generated server implementations."]
143pub mod core_service_server {
144    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
145    use tonic::codegen::*;
146    #[doc = "Generated trait containing gRPC methods that should be implemented for use with CoreServiceServer."]
147    #[async_trait]
148    pub trait CoreService: Send + Sync + 'static {
149        #[doc = "Server streaming response type for the SubscribeConnectionState method."]
150        type SubscribeConnectionStateStream: futures_core::Stream<Item = Result<super::ConnectionStateResponse, tonic::Status>>
151            + Send
152            + Sync
153            + 'static;
154        #[doc = " Subscribe to 'connection state' updates."]
155        async fn subscribe_connection_state(
156            &self,
157            request: tonic::Request<super::SubscribeConnectionStateRequest>,
158        ) -> Result<tonic::Response<Self::SubscribeConnectionStateStream>, tonic::Status>;
159        #[doc = " Get a list of currently running plugins."]
160        async fn list_running_plugins(
161            &self,
162            request: tonic::Request<super::ListRunningPluginsRequest>,
163        ) -> Result<tonic::Response<super::ListRunningPluginsResponse>, tonic::Status>;
164    }
165    #[doc = " Access to the connection state and running plugins."]
166    #[derive(Debug)]
167    pub struct CoreServiceServer<T: CoreService> {
168        inner: _Inner<T>,
169        accept_compression_encodings: (),
170        send_compression_encodings: (),
171    }
172    struct _Inner<T>(Arc<T>);
173    impl<T: CoreService> CoreServiceServer<T> {
174        pub fn new(inner: T) -> Self {
175            let inner = Arc::new(inner);
176            let inner = _Inner(inner);
177            Self {
178                inner,
179                accept_compression_encodings: Default::default(),
180                send_compression_encodings: Default::default(),
181            }
182        }
183        pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
184        where
185            F: tonic::service::Interceptor,
186        {
187            InterceptedService::new(Self::new(inner), interceptor)
188        }
189    }
190    impl<T, B> tonic::codegen::Service<http::Request<B>> for CoreServiceServer<T>
191    where
192        T: CoreService,
193        B: Body + Send + Sync + 'static,
194        B::Error: Into<StdError> + Send + 'static,
195    {
196        type Response = http::Response<tonic::body::BoxBody>;
197        type Error = Never;
198        type Future = BoxFuture<Self::Response, Self::Error>;
199        fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
200            Poll::Ready(Ok(()))
201        }
202        fn call(&mut self, req: http::Request<B>) -> Self::Future {
203            let inner = self.inner.clone();
204            match req.uri().path() {
205                "/mavsdk.rpc.core.CoreService/SubscribeConnectionState" => {
206                    #[allow(non_camel_case_types)]
207                    struct SubscribeConnectionStateSvc<T: CoreService>(pub Arc<T>);
208                    impl<T: CoreService>
209                        tonic::server::ServerStreamingService<
210                            super::SubscribeConnectionStateRequest,
211                        > for SubscribeConnectionStateSvc<T>
212                    {
213                        type Response = super::ConnectionStateResponse;
214                        type ResponseStream = T::SubscribeConnectionStateStream;
215                        type Future =
216                            BoxFuture<tonic::Response<Self::ResponseStream>, tonic::Status>;
217                        fn call(
218                            &mut self,
219                            request: tonic::Request<super::SubscribeConnectionStateRequest>,
220                        ) -> Self::Future {
221                            let inner = self.0.clone();
222                            let fut =
223                                async move { (*inner).subscribe_connection_state(request).await };
224                            Box::pin(fut)
225                        }
226                    }
227                    let accept_compression_encodings = self.accept_compression_encodings;
228                    let send_compression_encodings = self.send_compression_encodings;
229                    let inner = self.inner.clone();
230                    let fut = async move {
231                        let inner = inner.0;
232                        let method = SubscribeConnectionStateSvc(inner);
233                        let codec = tonic::codec::ProstCodec::default();
234                        let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
235                            accept_compression_encodings,
236                            send_compression_encodings,
237                        );
238                        let res = grpc.server_streaming(method, req).await;
239                        Ok(res)
240                    };
241                    Box::pin(fut)
242                }
243                "/mavsdk.rpc.core.CoreService/ListRunningPlugins" => {
244                    #[allow(non_camel_case_types)]
245                    struct ListRunningPluginsSvc<T: CoreService>(pub Arc<T>);
246                    impl<T: CoreService>
247                        tonic::server::UnaryService<super::ListRunningPluginsRequest>
248                        for ListRunningPluginsSvc<T>
249                    {
250                        type Response = super::ListRunningPluginsResponse;
251                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
252                        fn call(
253                            &mut self,
254                            request: tonic::Request<super::ListRunningPluginsRequest>,
255                        ) -> Self::Future {
256                            let inner = self.0.clone();
257                            let fut = async move { (*inner).list_running_plugins(request).await };
258                            Box::pin(fut)
259                        }
260                    }
261                    let accept_compression_encodings = self.accept_compression_encodings;
262                    let send_compression_encodings = self.send_compression_encodings;
263                    let inner = self.inner.clone();
264                    let fut = async move {
265                        let inner = inner.0;
266                        let method = ListRunningPluginsSvc(inner);
267                        let codec = tonic::codec::ProstCodec::default();
268                        let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
269                            accept_compression_encodings,
270                            send_compression_encodings,
271                        );
272                        let res = grpc.unary(method, req).await;
273                        Ok(res)
274                    };
275                    Box::pin(fut)
276                }
277                _ => Box::pin(async move {
278                    Ok(http::Response::builder()
279                        .status(200)
280                        .header("grpc-status", "12")
281                        .header("content-type", "application/grpc")
282                        .body(empty_body())
283                        .unwrap())
284                }),
285            }
286        }
287    }
288    impl<T: CoreService> Clone for CoreServiceServer<T> {
289        fn clone(&self) -> Self {
290            let inner = self.inner.clone();
291            Self {
292                inner,
293                accept_compression_encodings: self.accept_compression_encodings,
294                send_compression_encodings: self.send_compression_encodings,
295            }
296        }
297    }
298    impl<T: CoreService> Clone for _Inner<T> {
299        fn clone(&self) -> Self {
300            Self(self.0.clone())
301        }
302    }
303    impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
304        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
305            write!(f, "{:?}", self.0)
306        }
307    }
308    impl<T: CoreService> tonic::transport::NamedService for CoreServiceServer<T> {
309        const NAME: &'static str = "mavsdk.rpc.core.CoreService";
310    }
311}