openrr_remote/gen/
impls.rs

1// This file is @generated by openrr-internal-codegen.
2// It is not intended for manual editing.
3
4#![allow(unused_variables)]
5#![allow(clippy::useless_conversion, clippy::unit_arg)]
6
7use arci::{BaseVelocity, Error, Isometry2, Isometry3, Scan2D, WaitFuture};
8use super::*;
9#[derive(Debug, Clone)]
10pub struct RemoteGamepadSender {
11    pub(crate) client: pb::gamepad_client::GamepadClient<tonic::transport::Channel>,
12}
13impl RemoteGamepadSender {
14    /// Attempt to create a new sender by connecting to a given endpoint.
15    pub async fn connect<D>(dst: D) -> Result<Self, arci::Error>
16    where
17        D: TryInto<tonic::transport::Endpoint>,
18        D::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
19    {
20        let client = pb::gamepad_client::GamepadClient::connect(dst)
21            .await
22            .map_err(|e| arci::Error::Connection {
23                message: e.to_string(),
24            })?;
25        Ok(Self { client })
26    }
27    /// Create a new sender.
28    pub fn new(channel: tonic::transport::Channel) -> Self {
29        Self {
30            client: pb::gamepad_client::GamepadClient::new(channel),
31        }
32    }
33}
34#[derive(Debug)]
35pub struct RemoteGamepadReceiver<T> {
36    pub(crate) inner: T,
37}
38impl<T> RemoteGamepadReceiver<T>
39where
40    T: arci::Gamepad + 'static,
41{
42    /// Create a new receiver.
43    pub fn new(inner: T) -> Self {
44        Self { inner }
45    }
46    /// Convert this receiver into a tower service.
47    pub fn into_service(self) -> pb::gamepad_server::GamepadServer<Self> {
48        pb::gamepad_server::GamepadServer::new(self)
49    }
50    pub async fn serve(self, addr: SocketAddr) -> Result<(), arci::Error> {
51        tonic::transport::Server::builder()
52            .add_service(self.into_service())
53            .serve(addr)
54            .await
55            .map_err(|e| arci::Error::Connection {
56                message: e.to_string(),
57            })?;
58        Ok(())
59    }
60}
61#[derive(Debug, Clone)]
62pub struct RemoteJointTrajectoryClientSender {
63    pub(crate) client: pb::joint_trajectory_client_client::JointTrajectoryClientClient<
64        tonic::transport::Channel,
65    >,
66}
67impl RemoteJointTrajectoryClientSender {
68    /// Attempt to create a new sender by connecting to a given endpoint.
69    pub async fn connect<D>(dst: D) -> Result<Self, arci::Error>
70    where
71        D: TryInto<tonic::transport::Endpoint>,
72        D::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
73    {
74        let client = pb::joint_trajectory_client_client::JointTrajectoryClientClient::connect(
75                dst,
76            )
77            .await
78            .map_err(|e| arci::Error::Connection {
79                message: e.to_string(),
80            })?;
81        Ok(Self { client })
82    }
83    /// Create a new sender.
84    pub fn new(channel: tonic::transport::Channel) -> Self {
85        Self {
86            client: pb::joint_trajectory_client_client::JointTrajectoryClientClient::new(
87                channel,
88            ),
89        }
90    }
91}
92#[derive(Debug)]
93pub struct RemoteJointTrajectoryClientReceiver<T> {
94    pub(crate) inner: T,
95}
96impl<T> RemoteJointTrajectoryClientReceiver<T>
97where
98    T: arci::JointTrajectoryClient + 'static,
99{
100    /// Create a new receiver.
101    pub fn new(inner: T) -> Self {
102        Self { inner }
103    }
104    /// Convert this receiver into a tower service.
105    pub fn into_service(
106        self,
107    ) -> pb::joint_trajectory_client_server::JointTrajectoryClientServer<Self> {
108        pb::joint_trajectory_client_server::JointTrajectoryClientServer::new(self)
109    }
110    pub async fn serve(self, addr: SocketAddr) -> Result<(), arci::Error> {
111        tonic::transport::Server::builder()
112            .add_service(self.into_service())
113            .serve(addr)
114            .await
115            .map_err(|e| arci::Error::Connection {
116                message: e.to_string(),
117            })?;
118        Ok(())
119    }
120}
121#[derive(Debug, Clone)]
122pub struct RemoteLaserScan2DSender {
123    pub(crate) client: pb::laser_scan2_d_client::LaserScan2DClient<
124        tonic::transport::Channel,
125    >,
126}
127impl RemoteLaserScan2DSender {
128    /// Attempt to create a new sender by connecting to a given endpoint.
129    pub async fn connect<D>(dst: D) -> Result<Self, arci::Error>
130    where
131        D: TryInto<tonic::transport::Endpoint>,
132        D::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
133    {
134        let client = pb::laser_scan2_d_client::LaserScan2DClient::connect(dst)
135            .await
136            .map_err(|e| arci::Error::Connection {
137                message: e.to_string(),
138            })?;
139        Ok(Self { client })
140    }
141    /// Create a new sender.
142    pub fn new(channel: tonic::transport::Channel) -> Self {
143        Self {
144            client: pb::laser_scan2_d_client::LaserScan2DClient::new(channel),
145        }
146    }
147}
148#[derive(Debug)]
149pub struct RemoteLaserScan2DReceiver<T> {
150    pub(crate) inner: T,
151}
152impl<T> RemoteLaserScan2DReceiver<T>
153where
154    T: arci::LaserScan2D + 'static,
155{
156    /// Create a new receiver.
157    pub fn new(inner: T) -> Self {
158        Self { inner }
159    }
160    /// Convert this receiver into a tower service.
161    pub fn into_service(self) -> pb::laser_scan2_d_server::LaserScan2DServer<Self> {
162        pb::laser_scan2_d_server::LaserScan2DServer::new(self)
163    }
164    pub async fn serve(self, addr: SocketAddr) -> Result<(), arci::Error> {
165        tonic::transport::Server::builder()
166            .add_service(self.into_service())
167            .serve(addr)
168            .await
169            .map_err(|e| arci::Error::Connection {
170                message: e.to_string(),
171            })?;
172        Ok(())
173    }
174}
175impl arci::LaserScan2D for RemoteLaserScan2DSender {
176    fn current_scan(&self) -> Result<Scan2D, Error> {
177        let mut client = self.client.clone();
178        let args = tonic::Request::new(());
179        Ok(
180            block_in_place(client.current_scan(args))
181                .map_err(|e| arci::Error::Other(e.into()))?
182                .into_inner()
183                .into(),
184        )
185    }
186}
187#[tonic::async_trait]
188impl<T> pb::laser_scan2_d_server::LaserScan2D for RemoteLaserScan2DReceiver<T>
189where
190    T: arci::LaserScan2D + 'static,
191{
192    async fn current_scan(
193        &self,
194        request: tonic::Request<()>,
195    ) -> std::result::Result<tonic::Response<pb::Scan2D>, tonic::Status> {
196        let request = request.into_inner();
197        let res = arci::LaserScan2D::current_scan(&self.inner)
198            .map_err(|e| tonic::Status::unknown(e.to_string()))?
199            .into();
200        Ok(tonic::Response::new(res))
201    }
202}
203#[derive(Debug, Clone)]
204pub struct RemoteLocalizationSender {
205    pub(crate) client: pb::localization_client::LocalizationClient<
206        tonic::transport::Channel,
207    >,
208}
209impl RemoteLocalizationSender {
210    /// Attempt to create a new sender by connecting to a given endpoint.
211    pub async fn connect<D>(dst: D) -> Result<Self, arci::Error>
212    where
213        D: TryInto<tonic::transport::Endpoint>,
214        D::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
215    {
216        let client = pb::localization_client::LocalizationClient::connect(dst)
217            .await
218            .map_err(|e| arci::Error::Connection {
219                message: e.to_string(),
220            })?;
221        Ok(Self { client })
222    }
223    /// Create a new sender.
224    pub fn new(channel: tonic::transport::Channel) -> Self {
225        Self {
226            client: pb::localization_client::LocalizationClient::new(channel),
227        }
228    }
229}
230#[derive(Debug)]
231pub struct RemoteLocalizationReceiver<T> {
232    pub(crate) inner: T,
233}
234impl<T> RemoteLocalizationReceiver<T>
235where
236    T: arci::Localization + 'static,
237{
238    /// Create a new receiver.
239    pub fn new(inner: T) -> Self {
240        Self { inner }
241    }
242    /// Convert this receiver into a tower service.
243    pub fn into_service(self) -> pb::localization_server::LocalizationServer<Self> {
244        pb::localization_server::LocalizationServer::new(self)
245    }
246    pub async fn serve(self, addr: SocketAddr) -> Result<(), arci::Error> {
247        tonic::transport::Server::builder()
248            .add_service(self.into_service())
249            .serve(addr)
250            .await
251            .map_err(|e| arci::Error::Connection {
252                message: e.to_string(),
253            })?;
254        Ok(())
255    }
256}
257impl arci::Localization for RemoteLocalizationSender {
258    fn current_pose(&self, frame_id: &str) -> Result<Isometry2<f64>, Error> {
259        let mut client = self.client.clone();
260        let args = tonic::Request::new(frame_id.into());
261        Ok(
262            block_in_place(client.current_pose(args))
263                .map_err(|e| arci::Error::Other(e.into()))?
264                .into_inner()
265                .into(),
266        )
267    }
268}
269#[tonic::async_trait]
270impl<T> pb::localization_server::Localization for RemoteLocalizationReceiver<T>
271where
272    T: arci::Localization + 'static,
273{
274    async fn current_pose(
275        &self,
276        request: tonic::Request<::prost::alloc::string::String>,
277    ) -> std::result::Result<tonic::Response<pb::Isometry2>, tonic::Status> {
278        let request = request.into_inner();
279        let res = arci::Localization::current_pose(&self.inner, &request)
280            .map_err(|e| tonic::Status::unknown(e.to_string()))?
281            .into();
282        Ok(tonic::Response::new(res))
283    }
284}
285#[derive(Debug, Clone)]
286pub struct RemoteMotorDrivePositionSender {
287    pub(crate) client: pb::motor_drive_position_client::MotorDrivePositionClient<
288        tonic::transport::Channel,
289    >,
290}
291impl RemoteMotorDrivePositionSender {
292    /// Attempt to create a new sender by connecting to a given endpoint.
293    pub async fn connect<D>(dst: D) -> Result<Self, arci::Error>
294    where
295        D: TryInto<tonic::transport::Endpoint>,
296        D::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
297    {
298        let client = pb::motor_drive_position_client::MotorDrivePositionClient::connect(
299                dst,
300            )
301            .await
302            .map_err(|e| arci::Error::Connection {
303                message: e.to_string(),
304            })?;
305        Ok(Self { client })
306    }
307    /// Create a new sender.
308    pub fn new(channel: tonic::transport::Channel) -> Self {
309        Self {
310            client: pb::motor_drive_position_client::MotorDrivePositionClient::new(
311                channel,
312            ),
313        }
314    }
315}
316#[derive(Debug)]
317pub struct RemoteMotorDrivePositionReceiver<T> {
318    pub(crate) inner: T,
319}
320impl<T> RemoteMotorDrivePositionReceiver<T>
321where
322    T: arci::MotorDrivePosition + 'static,
323{
324    /// Create a new receiver.
325    pub fn new(inner: T) -> Self {
326        Self { inner }
327    }
328    /// Convert this receiver into a tower service.
329    pub fn into_service(
330        self,
331    ) -> pb::motor_drive_position_server::MotorDrivePositionServer<Self> {
332        pb::motor_drive_position_server::MotorDrivePositionServer::new(self)
333    }
334    pub async fn serve(self, addr: SocketAddr) -> Result<(), arci::Error> {
335        tonic::transport::Server::builder()
336            .add_service(self.into_service())
337            .serve(addr)
338            .await
339            .map_err(|e| arci::Error::Connection {
340                message: e.to_string(),
341            })?;
342        Ok(())
343    }
344}
345impl arci::MotorDrivePosition for RemoteMotorDrivePositionSender {
346    fn set_motor_position(&self, position: f64) -> Result<(), Error> {
347        let mut client = self.client.clone();
348        let args = tonic::Request::new(position.into());
349        Ok(
350            block_in_place(client.set_motor_position(args))
351                .map_err(|e| arci::Error::Other(e.into()))?
352                .into_inner()
353                .into(),
354        )
355    }
356    fn get_motor_position(&self) -> Result<f64, Error> {
357        let mut client = self.client.clone();
358        let args = tonic::Request::new(());
359        Ok(
360            block_in_place(client.get_motor_position(args))
361                .map_err(|e| arci::Error::Other(e.into()))?
362                .into_inner()
363                .into(),
364        )
365    }
366}
367#[tonic::async_trait]
368impl<T> pb::motor_drive_position_server::MotorDrivePosition
369for RemoteMotorDrivePositionReceiver<T>
370where
371    T: arci::MotorDrivePosition + 'static,
372{
373    async fn set_motor_position(
374        &self,
375        request: tonic::Request<f64>,
376    ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
377        let request = request.into_inner();
378        let res = arci::MotorDrivePosition::set_motor_position(
379                &self.inner,
380                request.into(),
381            )
382            .map_err(|e| tonic::Status::unknown(e.to_string()))?
383            .into();
384        Ok(tonic::Response::new(res))
385    }
386    async fn get_motor_position(
387        &self,
388        request: tonic::Request<()>,
389    ) -> std::result::Result<tonic::Response<f64>, tonic::Status> {
390        let request = request.into_inner();
391        let res = arci::MotorDrivePosition::get_motor_position(&self.inner)
392            .map_err(|e| tonic::Status::unknown(e.to_string()))?
393            .into();
394        Ok(tonic::Response::new(res))
395    }
396}
397#[derive(Debug, Clone)]
398pub struct RemoteMotorDriveVelocitySender {
399    pub(crate) client: pb::motor_drive_velocity_client::MotorDriveVelocityClient<
400        tonic::transport::Channel,
401    >,
402}
403impl RemoteMotorDriveVelocitySender {
404    /// Attempt to create a new sender by connecting to a given endpoint.
405    pub async fn connect<D>(dst: D) -> Result<Self, arci::Error>
406    where
407        D: TryInto<tonic::transport::Endpoint>,
408        D::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
409    {
410        let client = pb::motor_drive_velocity_client::MotorDriveVelocityClient::connect(
411                dst,
412            )
413            .await
414            .map_err(|e| arci::Error::Connection {
415                message: e.to_string(),
416            })?;
417        Ok(Self { client })
418    }
419    /// Create a new sender.
420    pub fn new(channel: tonic::transport::Channel) -> Self {
421        Self {
422            client: pb::motor_drive_velocity_client::MotorDriveVelocityClient::new(
423                channel,
424            ),
425        }
426    }
427}
428#[derive(Debug)]
429pub struct RemoteMotorDriveVelocityReceiver<T> {
430    pub(crate) inner: T,
431}
432impl<T> RemoteMotorDriveVelocityReceiver<T>
433where
434    T: arci::MotorDriveVelocity + 'static,
435{
436    /// Create a new receiver.
437    pub fn new(inner: T) -> Self {
438        Self { inner }
439    }
440    /// Convert this receiver into a tower service.
441    pub fn into_service(
442        self,
443    ) -> pb::motor_drive_velocity_server::MotorDriveVelocityServer<Self> {
444        pb::motor_drive_velocity_server::MotorDriveVelocityServer::new(self)
445    }
446    pub async fn serve(self, addr: SocketAddr) -> Result<(), arci::Error> {
447        tonic::transport::Server::builder()
448            .add_service(self.into_service())
449            .serve(addr)
450            .await
451            .map_err(|e| arci::Error::Connection {
452                message: e.to_string(),
453            })?;
454        Ok(())
455    }
456}
457impl arci::MotorDriveVelocity for RemoteMotorDriveVelocitySender {
458    fn set_motor_velocity(&self, velocity: f64) -> Result<(), Error> {
459        let mut client = self.client.clone();
460        let args = tonic::Request::new(velocity.into());
461        Ok(
462            block_in_place(client.set_motor_velocity(args))
463                .map_err(|e| arci::Error::Other(e.into()))?
464                .into_inner()
465                .into(),
466        )
467    }
468    fn get_motor_velocity(&self) -> Result<f64, Error> {
469        let mut client = self.client.clone();
470        let args = tonic::Request::new(());
471        Ok(
472            block_in_place(client.get_motor_velocity(args))
473                .map_err(|e| arci::Error::Other(e.into()))?
474                .into_inner()
475                .into(),
476        )
477    }
478}
479#[tonic::async_trait]
480impl<T> pb::motor_drive_velocity_server::MotorDriveVelocity
481for RemoteMotorDriveVelocityReceiver<T>
482where
483    T: arci::MotorDriveVelocity + 'static,
484{
485    async fn set_motor_velocity(
486        &self,
487        request: tonic::Request<f64>,
488    ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
489        let request = request.into_inner();
490        let res = arci::MotorDriveVelocity::set_motor_velocity(
491                &self.inner,
492                request.into(),
493            )
494            .map_err(|e| tonic::Status::unknown(e.to_string()))?
495            .into();
496        Ok(tonic::Response::new(res))
497    }
498    async fn get_motor_velocity(
499        &self,
500        request: tonic::Request<()>,
501    ) -> std::result::Result<tonic::Response<f64>, tonic::Status> {
502        let request = request.into_inner();
503        let res = arci::MotorDriveVelocity::get_motor_velocity(&self.inner)
504            .map_err(|e| tonic::Status::unknown(e.to_string()))?
505            .into();
506        Ok(tonic::Response::new(res))
507    }
508}
509#[derive(Debug, Clone)]
510pub struct RemoteMotorDriveEffortSender {
511    pub(crate) client: pb::motor_drive_effort_client::MotorDriveEffortClient<
512        tonic::transport::Channel,
513    >,
514}
515impl RemoteMotorDriveEffortSender {
516    /// Attempt to create a new sender by connecting to a given endpoint.
517    pub async fn connect<D>(dst: D) -> Result<Self, arci::Error>
518    where
519        D: TryInto<tonic::transport::Endpoint>,
520        D::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
521    {
522        let client = pb::motor_drive_effort_client::MotorDriveEffortClient::connect(dst)
523            .await
524            .map_err(|e| arci::Error::Connection {
525                message: e.to_string(),
526            })?;
527        Ok(Self { client })
528    }
529    /// Create a new sender.
530    pub fn new(channel: tonic::transport::Channel) -> Self {
531        Self {
532            client: pb::motor_drive_effort_client::MotorDriveEffortClient::new(channel),
533        }
534    }
535}
536#[derive(Debug)]
537pub struct RemoteMotorDriveEffortReceiver<T> {
538    pub(crate) inner: T,
539}
540impl<T> RemoteMotorDriveEffortReceiver<T>
541where
542    T: arci::MotorDriveEffort + 'static,
543{
544    /// Create a new receiver.
545    pub fn new(inner: T) -> Self {
546        Self { inner }
547    }
548    /// Convert this receiver into a tower service.
549    pub fn into_service(
550        self,
551    ) -> pb::motor_drive_effort_server::MotorDriveEffortServer<Self> {
552        pb::motor_drive_effort_server::MotorDriveEffortServer::new(self)
553    }
554    pub async fn serve(self, addr: SocketAddr) -> Result<(), arci::Error> {
555        tonic::transport::Server::builder()
556            .add_service(self.into_service())
557            .serve(addr)
558            .await
559            .map_err(|e| arci::Error::Connection {
560                message: e.to_string(),
561            })?;
562        Ok(())
563    }
564}
565impl arci::MotorDriveEffort for RemoteMotorDriveEffortSender {
566    fn set_motor_effort(&self, effort: f64) -> Result<(), Error> {
567        let mut client = self.client.clone();
568        let args = tonic::Request::new(effort.into());
569        Ok(
570            block_in_place(client.set_motor_effort(args))
571                .map_err(|e| arci::Error::Other(e.into()))?
572                .into_inner()
573                .into(),
574        )
575    }
576    fn get_motor_effort(&self) -> Result<f64, Error> {
577        let mut client = self.client.clone();
578        let args = tonic::Request::new(());
579        Ok(
580            block_in_place(client.get_motor_effort(args))
581                .map_err(|e| arci::Error::Other(e.into()))?
582                .into_inner()
583                .into(),
584        )
585    }
586}
587#[tonic::async_trait]
588impl<T> pb::motor_drive_effort_server::MotorDriveEffort
589for RemoteMotorDriveEffortReceiver<T>
590where
591    T: arci::MotorDriveEffort + 'static,
592{
593    async fn set_motor_effort(
594        &self,
595        request: tonic::Request<f64>,
596    ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
597        let request = request.into_inner();
598        let res = arci::MotorDriveEffort::set_motor_effort(&self.inner, request.into())
599            .map_err(|e| tonic::Status::unknown(e.to_string()))?
600            .into();
601        Ok(tonic::Response::new(res))
602    }
603    async fn get_motor_effort(
604        &self,
605        request: tonic::Request<()>,
606    ) -> std::result::Result<tonic::Response<f64>, tonic::Status> {
607        let request = request.into_inner();
608        let res = arci::MotorDriveEffort::get_motor_effort(&self.inner)
609            .map_err(|e| tonic::Status::unknown(e.to_string()))?
610            .into();
611        Ok(tonic::Response::new(res))
612    }
613}
614#[derive(Debug, Clone)]
615pub struct RemoteMoveBaseSender {
616    pub(crate) client: pb::move_base_client::MoveBaseClient<tonic::transport::Channel>,
617}
618impl RemoteMoveBaseSender {
619    /// Attempt to create a new sender by connecting to a given endpoint.
620    pub async fn connect<D>(dst: D) -> Result<Self, arci::Error>
621    where
622        D: TryInto<tonic::transport::Endpoint>,
623        D::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
624    {
625        let client = pb::move_base_client::MoveBaseClient::connect(dst)
626            .await
627            .map_err(|e| arci::Error::Connection {
628                message: e.to_string(),
629            })?;
630        Ok(Self { client })
631    }
632    /// Create a new sender.
633    pub fn new(channel: tonic::transport::Channel) -> Self {
634        Self {
635            client: pb::move_base_client::MoveBaseClient::new(channel),
636        }
637    }
638}
639#[derive(Debug)]
640pub struct RemoteMoveBaseReceiver<T> {
641    pub(crate) inner: T,
642}
643impl<T> RemoteMoveBaseReceiver<T>
644where
645    T: arci::MoveBase + 'static,
646{
647    /// Create a new receiver.
648    pub fn new(inner: T) -> Self {
649        Self { inner }
650    }
651    /// Convert this receiver into a tower service.
652    pub fn into_service(self) -> pb::move_base_server::MoveBaseServer<Self> {
653        pb::move_base_server::MoveBaseServer::new(self)
654    }
655    pub async fn serve(self, addr: SocketAddr) -> Result<(), arci::Error> {
656        tonic::transport::Server::builder()
657            .add_service(self.into_service())
658            .serve(addr)
659            .await
660            .map_err(|e| arci::Error::Connection {
661                message: e.to_string(),
662            })?;
663        Ok(())
664    }
665}
666impl arci::MoveBase for RemoteMoveBaseSender {
667    fn send_velocity(&self, velocity: &BaseVelocity) -> Result<(), Error> {
668        let mut client = self.client.clone();
669        let args = tonic::Request::new((*velocity).into());
670        Ok(
671            block_in_place(client.send_velocity(args))
672                .map_err(|e| arci::Error::Other(e.into()))?
673                .into_inner()
674                .into(),
675        )
676    }
677    fn current_velocity(&self) -> Result<BaseVelocity, Error> {
678        let mut client = self.client.clone();
679        let args = tonic::Request::new(());
680        Ok(
681            block_in_place(client.current_velocity(args))
682                .map_err(|e| arci::Error::Other(e.into()))?
683                .into_inner()
684                .into(),
685        )
686    }
687}
688#[tonic::async_trait]
689impl<T> pb::move_base_server::MoveBase for RemoteMoveBaseReceiver<T>
690where
691    T: arci::MoveBase + 'static,
692{
693    async fn send_velocity(
694        &self,
695        request: tonic::Request<pb::BaseVelocity>,
696    ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
697        let request = request.into_inner();
698        let res = arci::MoveBase::send_velocity(&self.inner, &request.into())
699            .map_err(|e| tonic::Status::unknown(e.to_string()))?
700            .into();
701        Ok(tonic::Response::new(res))
702    }
703    async fn current_velocity(
704        &self,
705        request: tonic::Request<()>,
706    ) -> std::result::Result<tonic::Response<pb::BaseVelocity>, tonic::Status> {
707        let request = request.into_inner();
708        let res = arci::MoveBase::current_velocity(&self.inner)
709            .map_err(|e| tonic::Status::unknown(e.to_string()))?
710            .into();
711        Ok(tonic::Response::new(res))
712    }
713}
714#[derive(Debug, Clone)]
715pub struct RemoteNavigationSender {
716    pub(crate) client: pb::navigation_client::NavigationClient<
717        tonic::transport::Channel,
718    >,
719}
720impl RemoteNavigationSender {
721    /// Attempt to create a new sender by connecting to a given endpoint.
722    pub async fn connect<D>(dst: D) -> Result<Self, arci::Error>
723    where
724        D: TryInto<tonic::transport::Endpoint>,
725        D::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
726    {
727        let client = pb::navigation_client::NavigationClient::connect(dst)
728            .await
729            .map_err(|e| arci::Error::Connection {
730                message: e.to_string(),
731            })?;
732        Ok(Self { client })
733    }
734    /// Create a new sender.
735    pub fn new(channel: tonic::transport::Channel) -> Self {
736        Self {
737            client: pb::navigation_client::NavigationClient::new(channel),
738        }
739    }
740}
741#[derive(Debug)]
742pub struct RemoteNavigationReceiver<T> {
743    pub(crate) inner: T,
744}
745impl<T> RemoteNavigationReceiver<T>
746where
747    T: arci::Navigation + 'static,
748{
749    /// Create a new receiver.
750    pub fn new(inner: T) -> Self {
751        Self { inner }
752    }
753    /// Convert this receiver into a tower service.
754    pub fn into_service(self) -> pb::navigation_server::NavigationServer<Self> {
755        pb::navigation_server::NavigationServer::new(self)
756    }
757    pub async fn serve(self, addr: SocketAddr) -> Result<(), arci::Error> {
758        tonic::transport::Server::builder()
759            .add_service(self.into_service())
760            .serve(addr)
761            .await
762            .map_err(|e| arci::Error::Connection {
763                message: e.to_string(),
764            })?;
765        Ok(())
766    }
767}
768impl arci::Navigation for RemoteNavigationSender {
769    fn send_goal_pose(
770        &self,
771        goal: Isometry2<f64>,
772        frame_id: &str,
773        timeout: std::time::Duration,
774    ) -> Result<WaitFuture, Error> {
775        let mut client = self.client.clone();
776        let args = tonic::Request::new((goal, frame_id, timeout).into());
777        Ok(
778            wait_from_handle(
779                tokio::spawn(async move { client.send_goal_pose(args).await }),
780            ),
781        )
782    }
783    fn cancel(&self) -> Result<(), Error> {
784        let mut client = self.client.clone();
785        let args = tonic::Request::new(());
786        Ok(
787            block_in_place(client.cancel(args))
788                .map_err(|e| arci::Error::Other(e.into()))?
789                .into_inner()
790                .into(),
791        )
792    }
793}
794#[tonic::async_trait]
795impl<T> pb::navigation_server::Navigation for RemoteNavigationReceiver<T>
796where
797    T: arci::Navigation + 'static,
798{
799    async fn send_goal_pose(
800        &self,
801        request: tonic::Request<pb::GoalPoseRequest>,
802    ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
803        let request = request.into_inner();
804        let res = arci::Navigation::send_goal_pose(
805                &self.inner,
806                request.goal.unwrap().into(),
807                &request.frame_id,
808                request.timeout.unwrap().try_into().unwrap(),
809            )
810            .map_err(|e| tonic::Status::unknown(e.to_string()))?
811            .await
812            .map_err(|e| tonic::Status::unknown(e.to_string()))?
813            .into();
814        Ok(tonic::Response::new(res))
815    }
816    async fn cancel(
817        &self,
818        request: tonic::Request<()>,
819    ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
820        let request = request.into_inner();
821        let res = arci::Navigation::cancel(&self.inner)
822            .map_err(|e| tonic::Status::unknown(e.to_string()))?
823            .into();
824        Ok(tonic::Response::new(res))
825    }
826}
827#[derive(Debug, Clone)]
828pub struct RemoteSpeakerSender {
829    pub(crate) client: pb::speaker_client::SpeakerClient<tonic::transport::Channel>,
830}
831impl RemoteSpeakerSender {
832    /// Attempt to create a new sender by connecting to a given endpoint.
833    pub async fn connect<D>(dst: D) -> Result<Self, arci::Error>
834    where
835        D: TryInto<tonic::transport::Endpoint>,
836        D::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
837    {
838        let client = pb::speaker_client::SpeakerClient::connect(dst)
839            .await
840            .map_err(|e| arci::Error::Connection {
841                message: e.to_string(),
842            })?;
843        Ok(Self { client })
844    }
845    /// Create a new sender.
846    pub fn new(channel: tonic::transport::Channel) -> Self {
847        Self {
848            client: pb::speaker_client::SpeakerClient::new(channel),
849        }
850    }
851}
852#[derive(Debug)]
853pub struct RemoteSpeakerReceiver<T> {
854    pub(crate) inner: T,
855}
856impl<T> RemoteSpeakerReceiver<T>
857where
858    T: arci::Speaker + 'static,
859{
860    /// Create a new receiver.
861    pub fn new(inner: T) -> Self {
862        Self { inner }
863    }
864    /// Convert this receiver into a tower service.
865    pub fn into_service(self) -> pb::speaker_server::SpeakerServer<Self> {
866        pb::speaker_server::SpeakerServer::new(self)
867    }
868    pub async fn serve(self, addr: SocketAddr) -> Result<(), arci::Error> {
869        tonic::transport::Server::builder()
870            .add_service(self.into_service())
871            .serve(addr)
872            .await
873            .map_err(|e| arci::Error::Connection {
874                message: e.to_string(),
875            })?;
876        Ok(())
877    }
878}
879impl arci::Speaker for RemoteSpeakerSender {
880    fn speak(&self, message: &str) -> Result<WaitFuture, Error> {
881        let mut client = self.client.clone();
882        let args = tonic::Request::new(message.into());
883        Ok(wait_from_handle(tokio::spawn(async move { client.speak(args).await })))
884    }
885}
886#[tonic::async_trait]
887impl<T> pb::speaker_server::Speaker for RemoteSpeakerReceiver<T>
888where
889    T: arci::Speaker + 'static,
890{
891    async fn speak(
892        &self,
893        request: tonic::Request<::prost::alloc::string::String>,
894    ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
895        let request = request.into_inner();
896        let res = arci::Speaker::speak(&self.inner, &request)
897            .map_err(|e| tonic::Status::unknown(e.to_string()))?
898            .await
899            .map_err(|e| tonic::Status::unknown(e.to_string()))?
900            .into();
901        Ok(tonic::Response::new(res))
902    }
903}
904#[derive(Debug, Clone)]
905pub struct RemoteTransformResolverSender {
906    pub(crate) client: pb::transform_resolver_client::TransformResolverClient<
907        tonic::transport::Channel,
908    >,
909}
910impl RemoteTransformResolverSender {
911    /// Attempt to create a new sender by connecting to a given endpoint.
912    pub async fn connect<D>(dst: D) -> Result<Self, arci::Error>
913    where
914        D: TryInto<tonic::transport::Endpoint>,
915        D::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
916    {
917        let client = pb::transform_resolver_client::TransformResolverClient::connect(dst)
918            .await
919            .map_err(|e| arci::Error::Connection {
920                message: e.to_string(),
921            })?;
922        Ok(Self { client })
923    }
924    /// Create a new sender.
925    pub fn new(channel: tonic::transport::Channel) -> Self {
926        Self {
927            client: pb::transform_resolver_client::TransformResolverClient::new(channel),
928        }
929    }
930}
931#[derive(Debug)]
932pub struct RemoteTransformResolverReceiver<T> {
933    pub(crate) inner: T,
934}
935impl<T> RemoteTransformResolverReceiver<T>
936where
937    T: arci::TransformResolver + 'static,
938{
939    /// Create a new receiver.
940    pub fn new(inner: T) -> Self {
941        Self { inner }
942    }
943    /// Convert this receiver into a tower service.
944    pub fn into_service(
945        self,
946    ) -> pb::transform_resolver_server::TransformResolverServer<Self> {
947        pb::transform_resolver_server::TransformResolverServer::new(self)
948    }
949    pub async fn serve(self, addr: SocketAddr) -> Result<(), arci::Error> {
950        tonic::transport::Server::builder()
951            .add_service(self.into_service())
952            .serve(addr)
953            .await
954            .map_err(|e| arci::Error::Connection {
955                message: e.to_string(),
956            })?;
957        Ok(())
958    }
959}
960impl arci::TransformResolver for RemoteTransformResolverSender {
961    fn resolve_transformation(
962        &self,
963        from: &str,
964        to: &str,
965        time: std::time::SystemTime,
966    ) -> Result<Isometry3<f64>, Error> {
967        let mut client = self.client.clone();
968        let args = tonic::Request::new((from, to, time).into());
969        Ok(
970            block_in_place(client.resolve_transformation(args))
971                .map_err(|e| arci::Error::Other(e.into()))?
972                .into_inner()
973                .into(),
974        )
975    }
976}
977#[tonic::async_trait]
978impl<T> pb::transform_resolver_server::TransformResolver
979for RemoteTransformResolverReceiver<T>
980where
981    T: arci::TransformResolver + 'static,
982{
983    async fn resolve_transformation(
984        &self,
985        request: tonic::Request<pb::ResolveTransformationRequest>,
986    ) -> std::result::Result<tonic::Response<pb::Isometry3>, tonic::Status> {
987        let request = request.into_inner();
988        let res = arci::TransformResolver::resolve_transformation(
989                &self.inner,
990                &request.from,
991                &request.to,
992                request.time.unwrap().try_into().unwrap(),
993            )
994            .map_err(|e| tonic::Status::unknown(e.to_string()))?
995            .into();
996        Ok(tonic::Response::new(res))
997    }
998}