mav_sdk/grpc/
mavsdk.rpc.param.rs

1#[derive(Clone, PartialEq, ::prost::Message)]
2pub struct GetParamIntRequest {
3    /// Name of the parameter
4    #[prost(string, tag = "1")]
5    pub name: ::prost::alloc::string::String,
6}
7#[derive(Clone, PartialEq, ::prost::Message)]
8pub struct GetParamIntResponse {
9    #[prost(message, optional, tag = "1")]
10    pub param_result: ::core::option::Option<ParamResult>,
11    /// Value of the requested parameter
12    #[prost(int32, tag = "2")]
13    pub value: i32,
14}
15#[derive(Clone, PartialEq, ::prost::Message)]
16pub struct SetParamIntRequest {
17    /// Name of the parameter to set
18    #[prost(string, tag = "1")]
19    pub name: ::prost::alloc::string::String,
20    /// Value the parameter should be set to
21    #[prost(int32, tag = "2")]
22    pub value: i32,
23}
24#[derive(Clone, PartialEq, ::prost::Message)]
25pub struct SetParamIntResponse {
26    #[prost(message, optional, tag = "1")]
27    pub param_result: ::core::option::Option<ParamResult>,
28}
29#[derive(Clone, PartialEq, ::prost::Message)]
30pub struct GetParamFloatRequest {
31    /// Name of the parameter
32    #[prost(string, tag = "1")]
33    pub name: ::prost::alloc::string::String,
34}
35#[derive(Clone, PartialEq, ::prost::Message)]
36pub struct GetParamFloatResponse {
37    #[prost(message, optional, tag = "1")]
38    pub param_result: ::core::option::Option<ParamResult>,
39    /// Value of the requested parameter
40    #[prost(float, tag = "2")]
41    pub value: f32,
42}
43#[derive(Clone, PartialEq, ::prost::Message)]
44pub struct SetParamFloatRequest {
45    /// Name of the parameter to set
46    #[prost(string, tag = "1")]
47    pub name: ::prost::alloc::string::String,
48    /// Value the parameter should be set to
49    #[prost(float, tag = "2")]
50    pub value: f32,
51}
52#[derive(Clone, PartialEq, ::prost::Message)]
53pub struct SetParamFloatResponse {
54    #[prost(message, optional, tag = "1")]
55    pub param_result: ::core::option::Option<ParamResult>,
56}
57#[derive(Clone, PartialEq, ::prost::Message)]
58pub struct GetAllParamsRequest {}
59#[derive(Clone, PartialEq, ::prost::Message)]
60pub struct GetAllParamsResponse {
61    /// Collection of all parameters
62    #[prost(message, optional, tag = "1")]
63    pub params: ::core::option::Option<AllParams>,
64}
65///
66/// Type for integer parameters.
67#[derive(Clone, PartialEq, ::prost::Message)]
68pub struct IntParam {
69    /// Name of the parameter
70    #[prost(string, tag = "1")]
71    pub name: ::prost::alloc::string::String,
72    /// Value of the parameter
73    #[prost(int32, tag = "2")]
74    pub value: i32,
75}
76///
77/// Type for float paramters.
78#[derive(Clone, PartialEq, ::prost::Message)]
79pub struct FloatParam {
80    /// Name of the parameter
81    #[prost(string, tag = "1")]
82    pub name: ::prost::alloc::string::String,
83    /// Value of the parameter
84    #[prost(float, tag = "2")]
85    pub value: f32,
86}
87///
88/// Type collecting all integer and float parameters.
89#[derive(Clone, PartialEq, ::prost::Message)]
90pub struct AllParams {
91    /// Collection of all parameter names and values of type int
92    #[prost(message, repeated, tag = "1")]
93    pub int_params: ::prost::alloc::vec::Vec<IntParam>,
94    /// Collection of all parameter names and values of type float
95    #[prost(message, repeated, tag = "2")]
96    pub float_params: ::prost::alloc::vec::Vec<FloatParam>,
97}
98/// Result type.
99#[derive(Clone, PartialEq, ::prost::Message)]
100pub struct ParamResult {
101    /// Result enum value
102    #[prost(enumeration = "param_result::Result", tag = "1")]
103    pub result: i32,
104    /// Human-readable English string describing the result
105    #[prost(string, tag = "2")]
106    pub result_str: ::prost::alloc::string::String,
107}
108/// Nested message and enum types in `ParamResult`.
109pub mod param_result {
110    /// Possible results returned for param requests.
111    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
112    #[repr(i32)]
113    pub enum Result {
114        /// Unknown result
115        Unknown = 0,
116        /// Request succeeded
117        Success = 1,
118        /// Request timed out
119        Timeout = 2,
120        /// Connection error
121        ConnectionError = 3,
122        /// Wrong type
123        WrongType = 4,
124        /// Parameter name too long (> 16)
125        ParamNameTooLong = 5,
126    }
127}
128#[doc = r" Generated client implementations."]
129pub mod param_service_client {
130    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
131    use tonic::codegen::*;
132    #[doc = " Provide raw access to get and set parameters."]
133    #[derive(Debug, Clone)]
134    pub struct ParamServiceClient<T> {
135        inner: tonic::client::Grpc<T>,
136    }
137    impl ParamServiceClient<tonic::transport::Channel> {
138        #[doc = r" Attempt to create a new client by connecting to a given endpoint."]
139        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
140        where
141            D: std::convert::TryInto<tonic::transport::Endpoint>,
142            D::Error: Into<StdError>,
143        {
144            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
145            Ok(Self::new(conn))
146        }
147    }
148    impl<T> ParamServiceClient<T>
149    where
150        T: tonic::client::GrpcService<tonic::body::BoxBody>,
151        T::ResponseBody: Body + Send + Sync + 'static,
152        T::Error: Into<StdError>,
153        <T::ResponseBody as Body>::Error: Into<StdError> + Send,
154    {
155        pub fn new(inner: T) -> Self {
156            let inner = tonic::client::Grpc::new(inner);
157            Self { inner }
158        }
159        pub fn with_interceptor<F>(
160            inner: T,
161            interceptor: F,
162        ) -> ParamServiceClient<InterceptedService<T, F>>
163        where
164            F: tonic::service::Interceptor,
165            T: tonic::codegen::Service<
166                http::Request<tonic::body::BoxBody>,
167                Response = http::Response<
168                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
169                >,
170            >,
171            <T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error:
172                Into<StdError> + Send + Sync,
173        {
174            ParamServiceClient::new(InterceptedService::new(inner, interceptor))
175        }
176        #[doc = r" Compress requests with `gzip`."]
177        #[doc = r""]
178        #[doc = r" This requires the server to support it otherwise it might respond with an"]
179        #[doc = r" error."]
180        pub fn send_gzip(mut self) -> Self {
181            self.inner = self.inner.send_gzip();
182            self
183        }
184        #[doc = r" Enable decompressing responses with `gzip`."]
185        pub fn accept_gzip(mut self) -> Self {
186            self.inner = self.inner.accept_gzip();
187            self
188        }
189        #[doc = ""]
190        #[doc = " Get an int parameter."]
191        #[doc = ""]
192        #[doc = " If the type is wrong, the result will be `WRONG_TYPE`."]
193        pub async fn get_param_int(
194            &mut self,
195            request: impl tonic::IntoRequest<super::GetParamIntRequest>,
196        ) -> Result<tonic::Response<super::GetParamIntResponse>, tonic::Status> {
197            self.inner.ready().await.map_err(|e| {
198                tonic::Status::new(
199                    tonic::Code::Unknown,
200                    format!("Service was not ready: {}", e.into()),
201                )
202            })?;
203            let codec = tonic::codec::ProstCodec::default();
204            let path =
205                http::uri::PathAndQuery::from_static("/mavsdk.rpc.param.ParamService/GetParamInt");
206            self.inner.unary(request.into_request(), path, codec).await
207        }
208        #[doc = ""]
209        #[doc = " Set an int parameter."]
210        #[doc = ""]
211        #[doc = " If the type is wrong, the result will be `WRONG_TYPE`."]
212        pub async fn set_param_int(
213            &mut self,
214            request: impl tonic::IntoRequest<super::SetParamIntRequest>,
215        ) -> Result<tonic::Response<super::SetParamIntResponse>, tonic::Status> {
216            self.inner.ready().await.map_err(|e| {
217                tonic::Status::new(
218                    tonic::Code::Unknown,
219                    format!("Service was not ready: {}", e.into()),
220                )
221            })?;
222            let codec = tonic::codec::ProstCodec::default();
223            let path =
224                http::uri::PathAndQuery::from_static("/mavsdk.rpc.param.ParamService/SetParamInt");
225            self.inner.unary(request.into_request(), path, codec).await
226        }
227        #[doc = ""]
228        #[doc = " Get a float parameter."]
229        #[doc = ""]
230        #[doc = " If the type is wrong, the result will be `WRONG_TYPE`."]
231        pub async fn get_param_float(
232            &mut self,
233            request: impl tonic::IntoRequest<super::GetParamFloatRequest>,
234        ) -> Result<tonic::Response<super::GetParamFloatResponse>, tonic::Status> {
235            self.inner.ready().await.map_err(|e| {
236                tonic::Status::new(
237                    tonic::Code::Unknown,
238                    format!("Service was not ready: {}", e.into()),
239                )
240            })?;
241            let codec = tonic::codec::ProstCodec::default();
242            let path = http::uri::PathAndQuery::from_static(
243                "/mavsdk.rpc.param.ParamService/GetParamFloat",
244            );
245            self.inner.unary(request.into_request(), path, codec).await
246        }
247        #[doc = ""]
248        #[doc = " Set a float parameter."]
249        #[doc = ""]
250        #[doc = " If the type is wrong, the result will be `WRONG_TYPE`."]
251        pub async fn set_param_float(
252            &mut self,
253            request: impl tonic::IntoRequest<super::SetParamFloatRequest>,
254        ) -> Result<tonic::Response<super::SetParamFloatResponse>, tonic::Status> {
255            self.inner.ready().await.map_err(|e| {
256                tonic::Status::new(
257                    tonic::Code::Unknown,
258                    format!("Service was not ready: {}", e.into()),
259                )
260            })?;
261            let codec = tonic::codec::ProstCodec::default();
262            let path = http::uri::PathAndQuery::from_static(
263                "/mavsdk.rpc.param.ParamService/SetParamFloat",
264            );
265            self.inner.unary(request.into_request(), path, codec).await
266        }
267        #[doc = ""]
268        #[doc = " Get all parameters."]
269        pub async fn get_all_params(
270            &mut self,
271            request: impl tonic::IntoRequest<super::GetAllParamsRequest>,
272        ) -> Result<tonic::Response<super::GetAllParamsResponse>, tonic::Status> {
273            self.inner.ready().await.map_err(|e| {
274                tonic::Status::new(
275                    tonic::Code::Unknown,
276                    format!("Service was not ready: {}", e.into()),
277                )
278            })?;
279            let codec = tonic::codec::ProstCodec::default();
280            let path =
281                http::uri::PathAndQuery::from_static("/mavsdk.rpc.param.ParamService/GetAllParams");
282            self.inner.unary(request.into_request(), path, codec).await
283        }
284    }
285}
286#[doc = r" Generated server implementations."]
287pub mod param_service_server {
288    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
289    use tonic::codegen::*;
290    #[doc = "Generated trait containing gRPC methods that should be implemented for use with ParamServiceServer."]
291    #[async_trait]
292    pub trait ParamService: Send + Sync + 'static {
293        #[doc = ""]
294        #[doc = " Get an int parameter."]
295        #[doc = ""]
296        #[doc = " If the type is wrong, the result will be `WRONG_TYPE`."]
297        async fn get_param_int(
298            &self,
299            request: tonic::Request<super::GetParamIntRequest>,
300        ) -> Result<tonic::Response<super::GetParamIntResponse>, tonic::Status>;
301        #[doc = ""]
302        #[doc = " Set an int parameter."]
303        #[doc = ""]
304        #[doc = " If the type is wrong, the result will be `WRONG_TYPE`."]
305        async fn set_param_int(
306            &self,
307            request: tonic::Request<super::SetParamIntRequest>,
308        ) -> Result<tonic::Response<super::SetParamIntResponse>, tonic::Status>;
309        #[doc = ""]
310        #[doc = " Get a float parameter."]
311        #[doc = ""]
312        #[doc = " If the type is wrong, the result will be `WRONG_TYPE`."]
313        async fn get_param_float(
314            &self,
315            request: tonic::Request<super::GetParamFloatRequest>,
316        ) -> Result<tonic::Response<super::GetParamFloatResponse>, tonic::Status>;
317        #[doc = ""]
318        #[doc = " Set a float parameter."]
319        #[doc = ""]
320        #[doc = " If the type is wrong, the result will be `WRONG_TYPE`."]
321        async fn set_param_float(
322            &self,
323            request: tonic::Request<super::SetParamFloatRequest>,
324        ) -> Result<tonic::Response<super::SetParamFloatResponse>, tonic::Status>;
325        #[doc = ""]
326        #[doc = " Get all parameters."]
327        async fn get_all_params(
328            &self,
329            request: tonic::Request<super::GetAllParamsRequest>,
330        ) -> Result<tonic::Response<super::GetAllParamsResponse>, tonic::Status>;
331    }
332    #[doc = " Provide raw access to get and set parameters."]
333    #[derive(Debug)]
334    pub struct ParamServiceServer<T: ParamService> {
335        inner: _Inner<T>,
336        accept_compression_encodings: (),
337        send_compression_encodings: (),
338    }
339    struct _Inner<T>(Arc<T>);
340    impl<T: ParamService> ParamServiceServer<T> {
341        pub fn new(inner: T) -> Self {
342            let inner = Arc::new(inner);
343            let inner = _Inner(inner);
344            Self {
345                inner,
346                accept_compression_encodings: Default::default(),
347                send_compression_encodings: Default::default(),
348            }
349        }
350        pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
351        where
352            F: tonic::service::Interceptor,
353        {
354            InterceptedService::new(Self::new(inner), interceptor)
355        }
356    }
357    impl<T, B> tonic::codegen::Service<http::Request<B>> for ParamServiceServer<T>
358    where
359        T: ParamService,
360        B: Body + Send + Sync + 'static,
361        B::Error: Into<StdError> + Send + 'static,
362    {
363        type Response = http::Response<tonic::body::BoxBody>;
364        type Error = Never;
365        type Future = BoxFuture<Self::Response, Self::Error>;
366        fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
367            Poll::Ready(Ok(()))
368        }
369        fn call(&mut self, req: http::Request<B>) -> Self::Future {
370            let inner = self.inner.clone();
371            match req.uri().path() {
372                "/mavsdk.rpc.param.ParamService/GetParamInt" => {
373                    #[allow(non_camel_case_types)]
374                    struct GetParamIntSvc<T: ParamService>(pub Arc<T>);
375                    impl<T: ParamService> tonic::server::UnaryService<super::GetParamIntRequest> for GetParamIntSvc<T> {
376                        type Response = super::GetParamIntResponse;
377                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
378                        fn call(
379                            &mut self,
380                            request: tonic::Request<super::GetParamIntRequest>,
381                        ) -> Self::Future {
382                            let inner = self.0.clone();
383                            let fut = async move { (*inner).get_param_int(request).await };
384                            Box::pin(fut)
385                        }
386                    }
387                    let accept_compression_encodings = self.accept_compression_encodings;
388                    let send_compression_encodings = self.send_compression_encodings;
389                    let inner = self.inner.clone();
390                    let fut = async move {
391                        let inner = inner.0;
392                        let method = GetParamIntSvc(inner);
393                        let codec = tonic::codec::ProstCodec::default();
394                        let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
395                            accept_compression_encodings,
396                            send_compression_encodings,
397                        );
398                        let res = grpc.unary(method, req).await;
399                        Ok(res)
400                    };
401                    Box::pin(fut)
402                }
403                "/mavsdk.rpc.param.ParamService/SetParamInt" => {
404                    #[allow(non_camel_case_types)]
405                    struct SetParamIntSvc<T: ParamService>(pub Arc<T>);
406                    impl<T: ParamService> tonic::server::UnaryService<super::SetParamIntRequest> for SetParamIntSvc<T> {
407                        type Response = super::SetParamIntResponse;
408                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
409                        fn call(
410                            &mut self,
411                            request: tonic::Request<super::SetParamIntRequest>,
412                        ) -> Self::Future {
413                            let inner = self.0.clone();
414                            let fut = async move { (*inner).set_param_int(request).await };
415                            Box::pin(fut)
416                        }
417                    }
418                    let accept_compression_encodings = self.accept_compression_encodings;
419                    let send_compression_encodings = self.send_compression_encodings;
420                    let inner = self.inner.clone();
421                    let fut = async move {
422                        let inner = inner.0;
423                        let method = SetParamIntSvc(inner);
424                        let codec = tonic::codec::ProstCodec::default();
425                        let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
426                            accept_compression_encodings,
427                            send_compression_encodings,
428                        );
429                        let res = grpc.unary(method, req).await;
430                        Ok(res)
431                    };
432                    Box::pin(fut)
433                }
434                "/mavsdk.rpc.param.ParamService/GetParamFloat" => {
435                    #[allow(non_camel_case_types)]
436                    struct GetParamFloatSvc<T: ParamService>(pub Arc<T>);
437                    impl<T: ParamService> tonic::server::UnaryService<super::GetParamFloatRequest>
438                        for GetParamFloatSvc<T>
439                    {
440                        type Response = super::GetParamFloatResponse;
441                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
442                        fn call(
443                            &mut self,
444                            request: tonic::Request<super::GetParamFloatRequest>,
445                        ) -> Self::Future {
446                            let inner = self.0.clone();
447                            let fut = async move { (*inner).get_param_float(request).await };
448                            Box::pin(fut)
449                        }
450                    }
451                    let accept_compression_encodings = self.accept_compression_encodings;
452                    let send_compression_encodings = self.send_compression_encodings;
453                    let inner = self.inner.clone();
454                    let fut = async move {
455                        let inner = inner.0;
456                        let method = GetParamFloatSvc(inner);
457                        let codec = tonic::codec::ProstCodec::default();
458                        let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
459                            accept_compression_encodings,
460                            send_compression_encodings,
461                        );
462                        let res = grpc.unary(method, req).await;
463                        Ok(res)
464                    };
465                    Box::pin(fut)
466                }
467                "/mavsdk.rpc.param.ParamService/SetParamFloat" => {
468                    #[allow(non_camel_case_types)]
469                    struct SetParamFloatSvc<T: ParamService>(pub Arc<T>);
470                    impl<T: ParamService> tonic::server::UnaryService<super::SetParamFloatRequest>
471                        for SetParamFloatSvc<T>
472                    {
473                        type Response = super::SetParamFloatResponse;
474                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
475                        fn call(
476                            &mut self,
477                            request: tonic::Request<super::SetParamFloatRequest>,
478                        ) -> Self::Future {
479                            let inner = self.0.clone();
480                            let fut = async move { (*inner).set_param_float(request).await };
481                            Box::pin(fut)
482                        }
483                    }
484                    let accept_compression_encodings = self.accept_compression_encodings;
485                    let send_compression_encodings = self.send_compression_encodings;
486                    let inner = self.inner.clone();
487                    let fut = async move {
488                        let inner = inner.0;
489                        let method = SetParamFloatSvc(inner);
490                        let codec = tonic::codec::ProstCodec::default();
491                        let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
492                            accept_compression_encodings,
493                            send_compression_encodings,
494                        );
495                        let res = grpc.unary(method, req).await;
496                        Ok(res)
497                    };
498                    Box::pin(fut)
499                }
500                "/mavsdk.rpc.param.ParamService/GetAllParams" => {
501                    #[allow(non_camel_case_types)]
502                    struct GetAllParamsSvc<T: ParamService>(pub Arc<T>);
503                    impl<T: ParamService> tonic::server::UnaryService<super::GetAllParamsRequest>
504                        for GetAllParamsSvc<T>
505                    {
506                        type Response = super::GetAllParamsResponse;
507                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
508                        fn call(
509                            &mut self,
510                            request: tonic::Request<super::GetAllParamsRequest>,
511                        ) -> Self::Future {
512                            let inner = self.0.clone();
513                            let fut = async move { (*inner).get_all_params(request).await };
514                            Box::pin(fut)
515                        }
516                    }
517                    let accept_compression_encodings = self.accept_compression_encodings;
518                    let send_compression_encodings = self.send_compression_encodings;
519                    let inner = self.inner.clone();
520                    let fut = async move {
521                        let inner = inner.0;
522                        let method = GetAllParamsSvc(inner);
523                        let codec = tonic::codec::ProstCodec::default();
524                        let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
525                            accept_compression_encodings,
526                            send_compression_encodings,
527                        );
528                        let res = grpc.unary(method, req).await;
529                        Ok(res)
530                    };
531                    Box::pin(fut)
532                }
533                _ => Box::pin(async move {
534                    Ok(http::Response::builder()
535                        .status(200)
536                        .header("grpc-status", "12")
537                        .header("content-type", "application/grpc")
538                        .body(empty_body())
539                        .unwrap())
540                }),
541            }
542        }
543    }
544    impl<T: ParamService> Clone for ParamServiceServer<T> {
545        fn clone(&self) -> Self {
546            let inner = self.inner.clone();
547            Self {
548                inner,
549                accept_compression_encodings: self.accept_compression_encodings,
550                send_compression_encodings: self.send_compression_encodings,
551            }
552        }
553    }
554    impl<T: ParamService> Clone for _Inner<T> {
555        fn clone(&self) -> Self {
556            Self(self.0.clone())
557        }
558    }
559    impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
560        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
561            write!(f, "{:?}", self.0)
562        }
563    }
564    impl<T: ParamService> tonic::transport::NamedService for ParamServiceServer<T> {
565        const NAME: &'static str = "mavsdk.rpc.param.ParamService";
566    }
567}