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