fidl_fuchsia_sensors/
fidl_fuchsia_sensors.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_sensors__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ManagerConfigureSensorRatesRequest {
16    pub id: i32,
17    pub sensor_rate_config: fidl_fuchsia_sensors_types::SensorRateConfig,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for ManagerConfigureSensorRatesRequest
22{
23}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct ManagerMarker;
27
28impl fidl::endpoints::ProtocolMarker for ManagerMarker {
29    type Proxy = ManagerProxy;
30    type RequestStream = ManagerRequestStream;
31    #[cfg(target_os = "fuchsia")]
32    type SynchronousProxy = ManagerSynchronousProxy;
33
34    const DEBUG_NAME: &'static str = "fuchsia.sensors.Manager";
35}
36impl fidl::endpoints::DiscoverableProtocolMarker for ManagerMarker {}
37pub type ManagerConfigurePlaybackResult = Result<(), ConfigurePlaybackError>;
38pub type ManagerConfigureSensorRatesResult = Result<(), ConfigureSensorRateError>;
39pub type ManagerActivateResult = Result<(), ActivateSensorError>;
40pub type ManagerDeactivateResult = Result<(), DeactivateSensorError>;
41
42pub trait ManagerProxyInterface: Send + Sync {
43    type ConfigurePlaybackResponseFut: std::future::Future<Output = Result<ManagerConfigurePlaybackResult, fidl::Error>>
44        + Send;
45    fn r#configure_playback(
46        &self,
47        source_config: &fidl_fuchsia_hardware_sensors::PlaybackSourceConfig,
48    ) -> Self::ConfigurePlaybackResponseFut;
49    type GetSensorsListResponseFut: std::future::Future<
50            Output = Result<Vec<fidl_fuchsia_sensors_types::SensorInfo>, fidl::Error>,
51        > + Send;
52    fn r#get_sensors_list(&self) -> Self::GetSensorsListResponseFut;
53    type ConfigureSensorRatesResponseFut: std::future::Future<Output = Result<ManagerConfigureSensorRatesResult, fidl::Error>>
54        + Send;
55    fn r#configure_sensor_rates(
56        &self,
57        id: i32,
58        sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
59    ) -> Self::ConfigureSensorRatesResponseFut;
60    type ActivateResponseFut: std::future::Future<Output = Result<ManagerActivateResult, fidl::Error>>
61        + Send;
62    fn r#activate(&self, id: i32) -> Self::ActivateResponseFut;
63    type DeactivateResponseFut: std::future::Future<Output = Result<ManagerDeactivateResult, fidl::Error>>
64        + Send;
65    fn r#deactivate(&self, id: i32) -> Self::DeactivateResponseFut;
66}
67#[derive(Debug)]
68#[cfg(target_os = "fuchsia")]
69pub struct ManagerSynchronousProxy {
70    client: fidl::client::sync::Client,
71}
72
73#[cfg(target_os = "fuchsia")]
74impl fidl::endpoints::SynchronousProxy for ManagerSynchronousProxy {
75    type Proxy = ManagerProxy;
76    type Protocol = ManagerMarker;
77
78    fn from_channel(inner: fidl::Channel) -> Self {
79        Self::new(inner)
80    }
81
82    fn into_channel(self) -> fidl::Channel {
83        self.client.into_channel()
84    }
85
86    fn as_channel(&self) -> &fidl::Channel {
87        self.client.as_channel()
88    }
89}
90
91#[cfg(target_os = "fuchsia")]
92impl ManagerSynchronousProxy {
93    pub fn new(channel: fidl::Channel) -> Self {
94        let protocol_name = <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
95        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
96    }
97
98    pub fn into_channel(self) -> fidl::Channel {
99        self.client.into_channel()
100    }
101
102    /// Waits until an event arrives and returns it. It is safe for other
103    /// threads to make concurrent requests while waiting for an event.
104    pub fn wait_for_event(
105        &self,
106        deadline: zx::MonotonicInstant,
107    ) -> Result<ManagerEvent, fidl::Error> {
108        ManagerEvent::decode(self.client.wait_for_event(deadline)?)
109    }
110
111    /// On Fuchsia configurations with sensor data playback enabled, the Playback protocol should
112    /// be accessed through this protocol. If the Playback protocol is unavailable on a given
113    /// Fuchsia configuration, this method will always return PLAYBACK_UNAVAILABLE.
114    pub fn r#configure_playback(
115        &self,
116        mut source_config: &fidl_fuchsia_hardware_sensors::PlaybackSourceConfig,
117        ___deadline: zx::MonotonicInstant,
118    ) -> Result<ManagerConfigurePlaybackResult, fidl::Error> {
119        let _response =
120            self.client
121                .send_query::<ManagerConfigurePlaybackRequest, fidl::encoding::FlexibleResultType<
122                    fidl::encoding::EmptyStruct,
123                    ConfigurePlaybackError,
124                >>(
125                    (source_config,),
126                    0x2aec5d56edab43fa,
127                    fidl::encoding::DynamicFlags::FLEXIBLE,
128                    ___deadline,
129                )?
130                .into_result::<ManagerMarker>("configure_playback")?;
131        Ok(_response.map(|x| x))
132    }
133
134    /// Returns the list of sensors managed by the SensorManager.
135    pub fn r#get_sensors_list(
136        &self,
137        ___deadline: zx::MonotonicInstant,
138    ) -> Result<Vec<fidl_fuchsia_sensors_types::SensorInfo>, fidl::Error> {
139        let _response = self.client.send_query::<
140            fidl::encoding::EmptyPayload,
141            fidl::encoding::FlexibleType<ManagerGetSensorsListResponse>,
142        >(
143            (),
144            0x48cf103cfbec3a4a,
145            fidl::encoding::DynamicFlags::FLEXIBLE,
146            ___deadline,
147        )?
148        .into_result::<ManagerMarker>("get_sensors_list")?;
149        Ok(_response.sensors)
150    }
151
152    /// Configures the sampling period and reporting latency for a particular sensor.
153    pub fn r#configure_sensor_rates(
154        &self,
155        mut id: i32,
156        mut sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
157        ___deadline: zx::MonotonicInstant,
158    ) -> Result<ManagerConfigureSensorRatesResult, fidl::Error> {
159        let _response = self
160            .client
161            .send_query::<ManagerConfigureSensorRatesRequest, fidl::encoding::FlexibleResultType<
162                fidl::encoding::EmptyStruct,
163                ConfigureSensorRateError,
164            >>(
165                (id, sensor_rate_config),
166                0x28046f7f3f340652,
167                fidl::encoding::DynamicFlags::FLEXIBLE,
168                ___deadline,
169            )?
170            .into_result::<ManagerMarker>("configure_sensor_rates")?;
171        Ok(_response.map(|x| x))
172    }
173
174    /// Activates a sensor. Events will begin to appear in the stream of sensor events.
175    pub fn r#activate(
176        &self,
177        mut id: i32,
178        ___deadline: zx::MonotonicInstant,
179    ) -> Result<ManagerActivateResult, fidl::Error> {
180        let _response =
181            self.client
182                .send_query::<ManagerActivateRequest, fidl::encoding::FlexibleResultType<
183                    fidl::encoding::EmptyStruct,
184                    ActivateSensorError,
185                >>(
186                    (id,), 0x5678f117cae5ba42, fidl::encoding::DynamicFlags::FLEXIBLE, ___deadline
187                )?
188                .into_result::<ManagerMarker>("activate")?;
189        Ok(_response.map(|x| x))
190    }
191
192    /// Deactivates a sensor. Events will no longer appear in the stream of sensor events.
193    pub fn r#deactivate(
194        &self,
195        mut id: i32,
196        ___deadline: zx::MonotonicInstant,
197    ) -> Result<ManagerDeactivateResult, fidl::Error> {
198        let _response =
199            self.client
200                .send_query::<ManagerDeactivateRequest, fidl::encoding::FlexibleResultType<
201                    fidl::encoding::EmptyStruct,
202                    DeactivateSensorError,
203                >>(
204                    (id,), 0x7fafbca62982c87, fidl::encoding::DynamicFlags::FLEXIBLE, ___deadline
205                )?
206                .into_result::<ManagerMarker>("deactivate")?;
207        Ok(_response.map(|x| x))
208    }
209}
210
211#[cfg(target_os = "fuchsia")]
212impl From<ManagerSynchronousProxy> for zx::NullableHandle {
213    fn from(value: ManagerSynchronousProxy) -> Self {
214        value.into_channel().into()
215    }
216}
217
218#[cfg(target_os = "fuchsia")]
219impl From<fidl::Channel> for ManagerSynchronousProxy {
220    fn from(value: fidl::Channel) -> Self {
221        Self::new(value)
222    }
223}
224
225#[cfg(target_os = "fuchsia")]
226impl fidl::endpoints::FromClient for ManagerSynchronousProxy {
227    type Protocol = ManagerMarker;
228
229    fn from_client(value: fidl::endpoints::ClientEnd<ManagerMarker>) -> Self {
230        Self::new(value.into_channel())
231    }
232}
233
234#[derive(Debug, Clone)]
235pub struct ManagerProxy {
236    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
237}
238
239impl fidl::endpoints::Proxy for ManagerProxy {
240    type Protocol = ManagerMarker;
241
242    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
243        Self::new(inner)
244    }
245
246    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
247        self.client.into_channel().map_err(|client| Self { client })
248    }
249
250    fn as_channel(&self) -> &::fidl::AsyncChannel {
251        self.client.as_channel()
252    }
253}
254
255impl ManagerProxy {
256    /// Create a new Proxy for fuchsia.sensors/Manager.
257    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
258        let protocol_name = <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
259        Self { client: fidl::client::Client::new(channel, protocol_name) }
260    }
261
262    /// Get a Stream of events from the remote end of the protocol.
263    ///
264    /// # Panics
265    ///
266    /// Panics if the event stream was already taken.
267    pub fn take_event_stream(&self) -> ManagerEventStream {
268        ManagerEventStream { event_receiver: self.client.take_event_receiver() }
269    }
270
271    /// On Fuchsia configurations with sensor data playback enabled, the Playback protocol should
272    /// be accessed through this protocol. If the Playback protocol is unavailable on a given
273    /// Fuchsia configuration, this method will always return PLAYBACK_UNAVAILABLE.
274    pub fn r#configure_playback(
275        &self,
276        mut source_config: &fidl_fuchsia_hardware_sensors::PlaybackSourceConfig,
277    ) -> fidl::client::QueryResponseFut<
278        ManagerConfigurePlaybackResult,
279        fidl::encoding::DefaultFuchsiaResourceDialect,
280    > {
281        ManagerProxyInterface::r#configure_playback(self, source_config)
282    }
283
284    /// Returns the list of sensors managed by the SensorManager.
285    pub fn r#get_sensors_list(
286        &self,
287    ) -> fidl::client::QueryResponseFut<
288        Vec<fidl_fuchsia_sensors_types::SensorInfo>,
289        fidl::encoding::DefaultFuchsiaResourceDialect,
290    > {
291        ManagerProxyInterface::r#get_sensors_list(self)
292    }
293
294    /// Configures the sampling period and reporting latency for a particular sensor.
295    pub fn r#configure_sensor_rates(
296        &self,
297        mut id: i32,
298        mut sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
299    ) -> fidl::client::QueryResponseFut<
300        ManagerConfigureSensorRatesResult,
301        fidl::encoding::DefaultFuchsiaResourceDialect,
302    > {
303        ManagerProxyInterface::r#configure_sensor_rates(self, id, sensor_rate_config)
304    }
305
306    /// Activates a sensor. Events will begin to appear in the stream of sensor events.
307    pub fn r#activate(
308        &self,
309        mut id: i32,
310    ) -> fidl::client::QueryResponseFut<
311        ManagerActivateResult,
312        fidl::encoding::DefaultFuchsiaResourceDialect,
313    > {
314        ManagerProxyInterface::r#activate(self, id)
315    }
316
317    /// Deactivates a sensor. Events will no longer appear in the stream of sensor events.
318    pub fn r#deactivate(
319        &self,
320        mut id: i32,
321    ) -> fidl::client::QueryResponseFut<
322        ManagerDeactivateResult,
323        fidl::encoding::DefaultFuchsiaResourceDialect,
324    > {
325        ManagerProxyInterface::r#deactivate(self, id)
326    }
327}
328
329impl ManagerProxyInterface for ManagerProxy {
330    type ConfigurePlaybackResponseFut = fidl::client::QueryResponseFut<
331        ManagerConfigurePlaybackResult,
332        fidl::encoding::DefaultFuchsiaResourceDialect,
333    >;
334    fn r#configure_playback(
335        &self,
336        mut source_config: &fidl_fuchsia_hardware_sensors::PlaybackSourceConfig,
337    ) -> Self::ConfigurePlaybackResponseFut {
338        fn _decode(
339            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
340        ) -> Result<ManagerConfigurePlaybackResult, fidl::Error> {
341            let _response = fidl::client::decode_transaction_body::<
342                fidl::encoding::FlexibleResultType<
343                    fidl::encoding::EmptyStruct,
344                    ConfigurePlaybackError,
345                >,
346                fidl::encoding::DefaultFuchsiaResourceDialect,
347                0x2aec5d56edab43fa,
348            >(_buf?)?
349            .into_result::<ManagerMarker>("configure_playback")?;
350            Ok(_response.map(|x| x))
351        }
352        self.client.send_query_and_decode::<
353            ManagerConfigurePlaybackRequest,
354            ManagerConfigurePlaybackResult,
355        >(
356            (source_config,),
357            0x2aec5d56edab43fa,
358            fidl::encoding::DynamicFlags::FLEXIBLE,
359            _decode,
360        )
361    }
362
363    type GetSensorsListResponseFut = fidl::client::QueryResponseFut<
364        Vec<fidl_fuchsia_sensors_types::SensorInfo>,
365        fidl::encoding::DefaultFuchsiaResourceDialect,
366    >;
367    fn r#get_sensors_list(&self) -> Self::GetSensorsListResponseFut {
368        fn _decode(
369            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
370        ) -> Result<Vec<fidl_fuchsia_sensors_types::SensorInfo>, fidl::Error> {
371            let _response = fidl::client::decode_transaction_body::<
372                fidl::encoding::FlexibleType<ManagerGetSensorsListResponse>,
373                fidl::encoding::DefaultFuchsiaResourceDialect,
374                0x48cf103cfbec3a4a,
375            >(_buf?)?
376            .into_result::<ManagerMarker>("get_sensors_list")?;
377            Ok(_response.sensors)
378        }
379        self.client.send_query_and_decode::<
380            fidl::encoding::EmptyPayload,
381            Vec<fidl_fuchsia_sensors_types::SensorInfo>,
382        >(
383            (),
384            0x48cf103cfbec3a4a,
385            fidl::encoding::DynamicFlags::FLEXIBLE,
386            _decode,
387        )
388    }
389
390    type ConfigureSensorRatesResponseFut = fidl::client::QueryResponseFut<
391        ManagerConfigureSensorRatesResult,
392        fidl::encoding::DefaultFuchsiaResourceDialect,
393    >;
394    fn r#configure_sensor_rates(
395        &self,
396        mut id: i32,
397        mut sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
398    ) -> Self::ConfigureSensorRatesResponseFut {
399        fn _decode(
400            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
401        ) -> Result<ManagerConfigureSensorRatesResult, fidl::Error> {
402            let _response = fidl::client::decode_transaction_body::<
403                fidl::encoding::FlexibleResultType<
404                    fidl::encoding::EmptyStruct,
405                    ConfigureSensorRateError,
406                >,
407                fidl::encoding::DefaultFuchsiaResourceDialect,
408                0x28046f7f3f340652,
409            >(_buf?)?
410            .into_result::<ManagerMarker>("configure_sensor_rates")?;
411            Ok(_response.map(|x| x))
412        }
413        self.client.send_query_and_decode::<
414            ManagerConfigureSensorRatesRequest,
415            ManagerConfigureSensorRatesResult,
416        >(
417            (id, sensor_rate_config,),
418            0x28046f7f3f340652,
419            fidl::encoding::DynamicFlags::FLEXIBLE,
420            _decode,
421        )
422    }
423
424    type ActivateResponseFut = fidl::client::QueryResponseFut<
425        ManagerActivateResult,
426        fidl::encoding::DefaultFuchsiaResourceDialect,
427    >;
428    fn r#activate(&self, mut id: i32) -> Self::ActivateResponseFut {
429        fn _decode(
430            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
431        ) -> Result<ManagerActivateResult, fidl::Error> {
432            let _response = fidl::client::decode_transaction_body::<
433                fidl::encoding::FlexibleResultType<
434                    fidl::encoding::EmptyStruct,
435                    ActivateSensorError,
436                >,
437                fidl::encoding::DefaultFuchsiaResourceDialect,
438                0x5678f117cae5ba42,
439            >(_buf?)?
440            .into_result::<ManagerMarker>("activate")?;
441            Ok(_response.map(|x| x))
442        }
443        self.client.send_query_and_decode::<ManagerActivateRequest, ManagerActivateResult>(
444            (id,),
445            0x5678f117cae5ba42,
446            fidl::encoding::DynamicFlags::FLEXIBLE,
447            _decode,
448        )
449    }
450
451    type DeactivateResponseFut = fidl::client::QueryResponseFut<
452        ManagerDeactivateResult,
453        fidl::encoding::DefaultFuchsiaResourceDialect,
454    >;
455    fn r#deactivate(&self, mut id: i32) -> Self::DeactivateResponseFut {
456        fn _decode(
457            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
458        ) -> Result<ManagerDeactivateResult, fidl::Error> {
459            let _response = fidl::client::decode_transaction_body::<
460                fidl::encoding::FlexibleResultType<
461                    fidl::encoding::EmptyStruct,
462                    DeactivateSensorError,
463                >,
464                fidl::encoding::DefaultFuchsiaResourceDialect,
465                0x7fafbca62982c87,
466            >(_buf?)?
467            .into_result::<ManagerMarker>("deactivate")?;
468            Ok(_response.map(|x| x))
469        }
470        self.client.send_query_and_decode::<ManagerDeactivateRequest, ManagerDeactivateResult>(
471            (id,),
472            0x7fafbca62982c87,
473            fidl::encoding::DynamicFlags::FLEXIBLE,
474            _decode,
475        )
476    }
477}
478
479pub struct ManagerEventStream {
480    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
481}
482
483impl std::marker::Unpin for ManagerEventStream {}
484
485impl futures::stream::FusedStream for ManagerEventStream {
486    fn is_terminated(&self) -> bool {
487        self.event_receiver.is_terminated()
488    }
489}
490
491impl futures::Stream for ManagerEventStream {
492    type Item = Result<ManagerEvent, fidl::Error>;
493
494    fn poll_next(
495        mut self: std::pin::Pin<&mut Self>,
496        cx: &mut std::task::Context<'_>,
497    ) -> std::task::Poll<Option<Self::Item>> {
498        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
499            &mut self.event_receiver,
500            cx
501        )?) {
502            Some(buf) => std::task::Poll::Ready(Some(ManagerEvent::decode(buf))),
503            None => std::task::Poll::Ready(None),
504        }
505    }
506}
507
508#[derive(Debug)]
509pub enum ManagerEvent {
510    OnSensorEvent {
511        event: fidl_fuchsia_sensors_types::SensorEvent,
512    },
513    #[non_exhaustive]
514    _UnknownEvent {
515        /// Ordinal of the event that was sent.
516        ordinal: u64,
517    },
518}
519
520impl ManagerEvent {
521    #[allow(irrefutable_let_patterns)]
522    pub fn into_on_sensor_event(self) -> Option<fidl_fuchsia_sensors_types::SensorEvent> {
523        if let ManagerEvent::OnSensorEvent { event } = self { Some((event)) } else { None }
524    }
525
526    /// Decodes a message buffer as a [`ManagerEvent`].
527    fn decode(
528        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
529    ) -> Result<ManagerEvent, fidl::Error> {
530        let (bytes, _handles) = buf.split_mut();
531        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
532        debug_assert_eq!(tx_header.tx_id, 0);
533        match tx_header.ordinal {
534            0x6ceb07e11d43e9b => {
535                let mut out = fidl::new_empty!(
536                    ManagerOnSensorEventRequest,
537                    fidl::encoding::DefaultFuchsiaResourceDialect
538                );
539                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerOnSensorEventRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
540                Ok((ManagerEvent::OnSensorEvent { event: out.event }))
541            }
542            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
543                Ok(ManagerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
544            }
545            _ => Err(fidl::Error::UnknownOrdinal {
546                ordinal: tx_header.ordinal,
547                protocol_name: <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
548            }),
549        }
550    }
551}
552
553/// A Stream of incoming requests for fuchsia.sensors/Manager.
554pub struct ManagerRequestStream {
555    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
556    is_terminated: bool,
557}
558
559impl std::marker::Unpin for ManagerRequestStream {}
560
561impl futures::stream::FusedStream for ManagerRequestStream {
562    fn is_terminated(&self) -> bool {
563        self.is_terminated
564    }
565}
566
567impl fidl::endpoints::RequestStream for ManagerRequestStream {
568    type Protocol = ManagerMarker;
569    type ControlHandle = ManagerControlHandle;
570
571    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
572        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
573    }
574
575    fn control_handle(&self) -> Self::ControlHandle {
576        ManagerControlHandle { inner: self.inner.clone() }
577    }
578
579    fn into_inner(
580        self,
581    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
582    {
583        (self.inner, self.is_terminated)
584    }
585
586    fn from_inner(
587        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
588        is_terminated: bool,
589    ) -> Self {
590        Self { inner, is_terminated }
591    }
592}
593
594impl futures::Stream for ManagerRequestStream {
595    type Item = Result<ManagerRequest, fidl::Error>;
596
597    fn poll_next(
598        mut self: std::pin::Pin<&mut Self>,
599        cx: &mut std::task::Context<'_>,
600    ) -> std::task::Poll<Option<Self::Item>> {
601        let this = &mut *self;
602        if this.inner.check_shutdown(cx) {
603            this.is_terminated = true;
604            return std::task::Poll::Ready(None);
605        }
606        if this.is_terminated {
607            panic!("polled ManagerRequestStream after completion");
608        }
609        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
610            |bytes, handles| {
611                match this.inner.channel().read_etc(cx, bytes, handles) {
612                    std::task::Poll::Ready(Ok(())) => {}
613                    std::task::Poll::Pending => return std::task::Poll::Pending,
614                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
615                        this.is_terminated = true;
616                        return std::task::Poll::Ready(None);
617                    }
618                    std::task::Poll::Ready(Err(e)) => {
619                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
620                            e.into(),
621                        ))));
622                    }
623                }
624
625                // A message has been received from the channel
626                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
627
628                std::task::Poll::Ready(Some(match header.ordinal {
629                    0x2aec5d56edab43fa => {
630                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
631                        let mut req = fidl::new_empty!(
632                            ManagerConfigurePlaybackRequest,
633                            fidl::encoding::DefaultFuchsiaResourceDialect
634                        );
635                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerConfigurePlaybackRequest>(&header, _body_bytes, handles, &mut req)?;
636                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
637                        Ok(ManagerRequest::ConfigurePlayback {
638                            source_config: req.source_config,
639
640                            responder: ManagerConfigurePlaybackResponder {
641                                control_handle: std::mem::ManuallyDrop::new(control_handle),
642                                tx_id: header.tx_id,
643                            },
644                        })
645                    }
646                    0x48cf103cfbec3a4a => {
647                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
648                        let mut req = fidl::new_empty!(
649                            fidl::encoding::EmptyPayload,
650                            fidl::encoding::DefaultFuchsiaResourceDialect
651                        );
652                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
653                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
654                        Ok(ManagerRequest::GetSensorsList {
655                            responder: ManagerGetSensorsListResponder {
656                                control_handle: std::mem::ManuallyDrop::new(control_handle),
657                                tx_id: header.tx_id,
658                            },
659                        })
660                    }
661                    0x28046f7f3f340652 => {
662                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
663                        let mut req = fidl::new_empty!(
664                            ManagerConfigureSensorRatesRequest,
665                            fidl::encoding::DefaultFuchsiaResourceDialect
666                        );
667                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerConfigureSensorRatesRequest>(&header, _body_bytes, handles, &mut req)?;
668                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
669                        Ok(ManagerRequest::ConfigureSensorRates {
670                            id: req.id,
671                            sensor_rate_config: req.sensor_rate_config,
672
673                            responder: ManagerConfigureSensorRatesResponder {
674                                control_handle: std::mem::ManuallyDrop::new(control_handle),
675                                tx_id: header.tx_id,
676                            },
677                        })
678                    }
679                    0x5678f117cae5ba42 => {
680                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
681                        let mut req = fidl::new_empty!(
682                            ManagerActivateRequest,
683                            fidl::encoding::DefaultFuchsiaResourceDialect
684                        );
685                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerActivateRequest>(&header, _body_bytes, handles, &mut req)?;
686                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
687                        Ok(ManagerRequest::Activate {
688                            id: req.id,
689
690                            responder: ManagerActivateResponder {
691                                control_handle: std::mem::ManuallyDrop::new(control_handle),
692                                tx_id: header.tx_id,
693                            },
694                        })
695                    }
696                    0x7fafbca62982c87 => {
697                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
698                        let mut req = fidl::new_empty!(
699                            ManagerDeactivateRequest,
700                            fidl::encoding::DefaultFuchsiaResourceDialect
701                        );
702                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerDeactivateRequest>(&header, _body_bytes, handles, &mut req)?;
703                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
704                        Ok(ManagerRequest::Deactivate {
705                            id: req.id,
706
707                            responder: ManagerDeactivateResponder {
708                                control_handle: std::mem::ManuallyDrop::new(control_handle),
709                                tx_id: header.tx_id,
710                            },
711                        })
712                    }
713                    _ if header.tx_id == 0
714                        && header
715                            .dynamic_flags()
716                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
717                    {
718                        Ok(ManagerRequest::_UnknownMethod {
719                            ordinal: header.ordinal,
720                            control_handle: ManagerControlHandle { inner: this.inner.clone() },
721                            method_type: fidl::MethodType::OneWay,
722                        })
723                    }
724                    _ if header
725                        .dynamic_flags()
726                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
727                    {
728                        this.inner.send_framework_err(
729                            fidl::encoding::FrameworkErr::UnknownMethod,
730                            header.tx_id,
731                            header.ordinal,
732                            header.dynamic_flags(),
733                            (bytes, handles),
734                        )?;
735                        Ok(ManagerRequest::_UnknownMethod {
736                            ordinal: header.ordinal,
737                            control_handle: ManagerControlHandle { inner: this.inner.clone() },
738                            method_type: fidl::MethodType::TwoWay,
739                        })
740                    }
741                    _ => Err(fidl::Error::UnknownOrdinal {
742                        ordinal: header.ordinal,
743                        protocol_name:
744                            <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
745                    }),
746                }))
747            },
748        )
749    }
750}
751
752#[derive(Debug)]
753pub enum ManagerRequest {
754    /// On Fuchsia configurations with sensor data playback enabled, the Playback protocol should
755    /// be accessed through this protocol. If the Playback protocol is unavailable on a given
756    /// Fuchsia configuration, this method will always return PLAYBACK_UNAVAILABLE.
757    ConfigurePlayback {
758        source_config: fidl_fuchsia_hardware_sensors::PlaybackSourceConfig,
759        responder: ManagerConfigurePlaybackResponder,
760    },
761    /// Returns the list of sensors managed by the SensorManager.
762    GetSensorsList { responder: ManagerGetSensorsListResponder },
763    /// Configures the sampling period and reporting latency for a particular sensor.
764    ConfigureSensorRates {
765        id: i32,
766        sensor_rate_config: fidl_fuchsia_sensors_types::SensorRateConfig,
767        responder: ManagerConfigureSensorRatesResponder,
768    },
769    /// Activates a sensor. Events will begin to appear in the stream of sensor events.
770    Activate { id: i32, responder: ManagerActivateResponder },
771    /// Deactivates a sensor. Events will no longer appear in the stream of sensor events.
772    Deactivate { id: i32, responder: ManagerDeactivateResponder },
773    /// An interaction was received which does not match any known method.
774    #[non_exhaustive]
775    _UnknownMethod {
776        /// Ordinal of the method that was called.
777        ordinal: u64,
778        control_handle: ManagerControlHandle,
779        method_type: fidl::MethodType,
780    },
781}
782
783impl ManagerRequest {
784    #[allow(irrefutable_let_patterns)]
785    pub fn into_configure_playback(
786        self,
787    ) -> Option<(
788        fidl_fuchsia_hardware_sensors::PlaybackSourceConfig,
789        ManagerConfigurePlaybackResponder,
790    )> {
791        if let ManagerRequest::ConfigurePlayback { source_config, responder } = self {
792            Some((source_config, responder))
793        } else {
794            None
795        }
796    }
797
798    #[allow(irrefutable_let_patterns)]
799    pub fn into_get_sensors_list(self) -> Option<(ManagerGetSensorsListResponder)> {
800        if let ManagerRequest::GetSensorsList { responder } = self {
801            Some((responder))
802        } else {
803            None
804        }
805    }
806
807    #[allow(irrefutable_let_patterns)]
808    pub fn into_configure_sensor_rates(
809        self,
810    ) -> Option<(
811        i32,
812        fidl_fuchsia_sensors_types::SensorRateConfig,
813        ManagerConfigureSensorRatesResponder,
814    )> {
815        if let ManagerRequest::ConfigureSensorRates { id, sensor_rate_config, responder } = self {
816            Some((id, sensor_rate_config, responder))
817        } else {
818            None
819        }
820    }
821
822    #[allow(irrefutable_let_patterns)]
823    pub fn into_activate(self) -> Option<(i32, ManagerActivateResponder)> {
824        if let ManagerRequest::Activate { id, responder } = self {
825            Some((id, responder))
826        } else {
827            None
828        }
829    }
830
831    #[allow(irrefutable_let_patterns)]
832    pub fn into_deactivate(self) -> Option<(i32, ManagerDeactivateResponder)> {
833        if let ManagerRequest::Deactivate { id, responder } = self {
834            Some((id, responder))
835        } else {
836            None
837        }
838    }
839
840    /// Name of the method defined in FIDL
841    pub fn method_name(&self) -> &'static str {
842        match *self {
843            ManagerRequest::ConfigurePlayback { .. } => "configure_playback",
844            ManagerRequest::GetSensorsList { .. } => "get_sensors_list",
845            ManagerRequest::ConfigureSensorRates { .. } => "configure_sensor_rates",
846            ManagerRequest::Activate { .. } => "activate",
847            ManagerRequest::Deactivate { .. } => "deactivate",
848            ManagerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
849                "unknown one-way method"
850            }
851            ManagerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
852                "unknown two-way method"
853            }
854        }
855    }
856}
857
858#[derive(Debug, Clone)]
859pub struct ManagerControlHandle {
860    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
861}
862
863impl fidl::endpoints::ControlHandle for ManagerControlHandle {
864    fn shutdown(&self) {
865        self.inner.shutdown()
866    }
867
868    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
869        self.inner.shutdown_with_epitaph(status)
870    }
871
872    fn is_closed(&self) -> bool {
873        self.inner.channel().is_closed()
874    }
875    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
876        self.inner.channel().on_closed()
877    }
878
879    #[cfg(target_os = "fuchsia")]
880    fn signal_peer(
881        &self,
882        clear_mask: zx::Signals,
883        set_mask: zx::Signals,
884    ) -> Result<(), zx_status::Status> {
885        use fidl::Peered;
886        self.inner.channel().signal_peer(clear_mask, set_mask)
887    }
888}
889
890impl ManagerControlHandle {
891    pub fn send_on_sensor_event(
892        &self,
893        mut event: &fidl_fuchsia_sensors_types::SensorEvent,
894    ) -> Result<(), fidl::Error> {
895        self.inner.send::<ManagerOnSensorEventRequest>(
896            (event,),
897            0,
898            0x6ceb07e11d43e9b,
899            fidl::encoding::DynamicFlags::FLEXIBLE,
900        )
901    }
902}
903
904#[must_use = "FIDL methods require a response to be sent"]
905#[derive(Debug)]
906pub struct ManagerConfigurePlaybackResponder {
907    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
908    tx_id: u32,
909}
910
911/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
912/// if the responder is dropped without sending a response, so that the client
913/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
914impl std::ops::Drop for ManagerConfigurePlaybackResponder {
915    fn drop(&mut self) {
916        self.control_handle.shutdown();
917        // Safety: drops once, never accessed again
918        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
919    }
920}
921
922impl fidl::endpoints::Responder for ManagerConfigurePlaybackResponder {
923    type ControlHandle = ManagerControlHandle;
924
925    fn control_handle(&self) -> &ManagerControlHandle {
926        &self.control_handle
927    }
928
929    fn drop_without_shutdown(mut self) {
930        // Safety: drops once, never accessed again due to mem::forget
931        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
932        // Prevent Drop from running (which would shut down the channel)
933        std::mem::forget(self);
934    }
935}
936
937impl ManagerConfigurePlaybackResponder {
938    /// Sends a response to the FIDL transaction.
939    ///
940    /// Sets the channel to shutdown if an error occurs.
941    pub fn send(self, mut result: Result<(), ConfigurePlaybackError>) -> Result<(), fidl::Error> {
942        let _result = self.send_raw(result);
943        if _result.is_err() {
944            self.control_handle.shutdown();
945        }
946        self.drop_without_shutdown();
947        _result
948    }
949
950    /// Similar to "send" but does not shutdown the channel if an error occurs.
951    pub fn send_no_shutdown_on_err(
952        self,
953        mut result: Result<(), ConfigurePlaybackError>,
954    ) -> Result<(), fidl::Error> {
955        let _result = self.send_raw(result);
956        self.drop_without_shutdown();
957        _result
958    }
959
960    fn send_raw(&self, mut result: Result<(), ConfigurePlaybackError>) -> Result<(), fidl::Error> {
961        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
962            fidl::encoding::EmptyStruct,
963            ConfigurePlaybackError,
964        >>(
965            fidl::encoding::FlexibleResult::new(result),
966            self.tx_id,
967            0x2aec5d56edab43fa,
968            fidl::encoding::DynamicFlags::FLEXIBLE,
969        )
970    }
971}
972
973#[must_use = "FIDL methods require a response to be sent"]
974#[derive(Debug)]
975pub struct ManagerGetSensorsListResponder {
976    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
977    tx_id: u32,
978}
979
980/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
981/// if the responder is dropped without sending a response, so that the client
982/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
983impl std::ops::Drop for ManagerGetSensorsListResponder {
984    fn drop(&mut self) {
985        self.control_handle.shutdown();
986        // Safety: drops once, never accessed again
987        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
988    }
989}
990
991impl fidl::endpoints::Responder for ManagerGetSensorsListResponder {
992    type ControlHandle = ManagerControlHandle;
993
994    fn control_handle(&self) -> &ManagerControlHandle {
995        &self.control_handle
996    }
997
998    fn drop_without_shutdown(mut self) {
999        // Safety: drops once, never accessed again due to mem::forget
1000        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1001        // Prevent Drop from running (which would shut down the channel)
1002        std::mem::forget(self);
1003    }
1004}
1005
1006impl ManagerGetSensorsListResponder {
1007    /// Sends a response to the FIDL transaction.
1008    ///
1009    /// Sets the channel to shutdown if an error occurs.
1010    pub fn send(
1011        self,
1012        mut sensors: &[fidl_fuchsia_sensors_types::SensorInfo],
1013    ) -> Result<(), fidl::Error> {
1014        let _result = self.send_raw(sensors);
1015        if _result.is_err() {
1016            self.control_handle.shutdown();
1017        }
1018        self.drop_without_shutdown();
1019        _result
1020    }
1021
1022    /// Similar to "send" but does not shutdown the channel if an error occurs.
1023    pub fn send_no_shutdown_on_err(
1024        self,
1025        mut sensors: &[fidl_fuchsia_sensors_types::SensorInfo],
1026    ) -> Result<(), fidl::Error> {
1027        let _result = self.send_raw(sensors);
1028        self.drop_without_shutdown();
1029        _result
1030    }
1031
1032    fn send_raw(
1033        &self,
1034        mut sensors: &[fidl_fuchsia_sensors_types::SensorInfo],
1035    ) -> Result<(), fidl::Error> {
1036        self.control_handle
1037            .inner
1038            .send::<fidl::encoding::FlexibleType<ManagerGetSensorsListResponse>>(
1039                fidl::encoding::Flexible::new((sensors,)),
1040                self.tx_id,
1041                0x48cf103cfbec3a4a,
1042                fidl::encoding::DynamicFlags::FLEXIBLE,
1043            )
1044    }
1045}
1046
1047#[must_use = "FIDL methods require a response to be sent"]
1048#[derive(Debug)]
1049pub struct ManagerConfigureSensorRatesResponder {
1050    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
1051    tx_id: u32,
1052}
1053
1054/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
1055/// if the responder is dropped without sending a response, so that the client
1056/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1057impl std::ops::Drop for ManagerConfigureSensorRatesResponder {
1058    fn drop(&mut self) {
1059        self.control_handle.shutdown();
1060        // Safety: drops once, never accessed again
1061        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1062    }
1063}
1064
1065impl fidl::endpoints::Responder for ManagerConfigureSensorRatesResponder {
1066    type ControlHandle = ManagerControlHandle;
1067
1068    fn control_handle(&self) -> &ManagerControlHandle {
1069        &self.control_handle
1070    }
1071
1072    fn drop_without_shutdown(mut self) {
1073        // Safety: drops once, never accessed again due to mem::forget
1074        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1075        // Prevent Drop from running (which would shut down the channel)
1076        std::mem::forget(self);
1077    }
1078}
1079
1080impl ManagerConfigureSensorRatesResponder {
1081    /// Sends a response to the FIDL transaction.
1082    ///
1083    /// Sets the channel to shutdown if an error occurs.
1084    pub fn send(self, mut result: Result<(), ConfigureSensorRateError>) -> Result<(), fidl::Error> {
1085        let _result = self.send_raw(result);
1086        if _result.is_err() {
1087            self.control_handle.shutdown();
1088        }
1089        self.drop_without_shutdown();
1090        _result
1091    }
1092
1093    /// Similar to "send" but does not shutdown the channel if an error occurs.
1094    pub fn send_no_shutdown_on_err(
1095        self,
1096        mut result: Result<(), ConfigureSensorRateError>,
1097    ) -> Result<(), fidl::Error> {
1098        let _result = self.send_raw(result);
1099        self.drop_without_shutdown();
1100        _result
1101    }
1102
1103    fn send_raw(
1104        &self,
1105        mut result: Result<(), ConfigureSensorRateError>,
1106    ) -> Result<(), fidl::Error> {
1107        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1108            fidl::encoding::EmptyStruct,
1109            ConfigureSensorRateError,
1110        >>(
1111            fidl::encoding::FlexibleResult::new(result),
1112            self.tx_id,
1113            0x28046f7f3f340652,
1114            fidl::encoding::DynamicFlags::FLEXIBLE,
1115        )
1116    }
1117}
1118
1119#[must_use = "FIDL methods require a response to be sent"]
1120#[derive(Debug)]
1121pub struct ManagerActivateResponder {
1122    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
1123    tx_id: u32,
1124}
1125
1126/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
1127/// if the responder is dropped without sending a response, so that the client
1128/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1129impl std::ops::Drop for ManagerActivateResponder {
1130    fn drop(&mut self) {
1131        self.control_handle.shutdown();
1132        // Safety: drops once, never accessed again
1133        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1134    }
1135}
1136
1137impl fidl::endpoints::Responder for ManagerActivateResponder {
1138    type ControlHandle = ManagerControlHandle;
1139
1140    fn control_handle(&self) -> &ManagerControlHandle {
1141        &self.control_handle
1142    }
1143
1144    fn drop_without_shutdown(mut self) {
1145        // Safety: drops once, never accessed again due to mem::forget
1146        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1147        // Prevent Drop from running (which would shut down the channel)
1148        std::mem::forget(self);
1149    }
1150}
1151
1152impl ManagerActivateResponder {
1153    /// Sends a response to the FIDL transaction.
1154    ///
1155    /// Sets the channel to shutdown if an error occurs.
1156    pub fn send(self, mut result: Result<(), ActivateSensorError>) -> Result<(), fidl::Error> {
1157        let _result = self.send_raw(result);
1158        if _result.is_err() {
1159            self.control_handle.shutdown();
1160        }
1161        self.drop_without_shutdown();
1162        _result
1163    }
1164
1165    /// Similar to "send" but does not shutdown the channel if an error occurs.
1166    pub fn send_no_shutdown_on_err(
1167        self,
1168        mut result: Result<(), ActivateSensorError>,
1169    ) -> Result<(), fidl::Error> {
1170        let _result = self.send_raw(result);
1171        self.drop_without_shutdown();
1172        _result
1173    }
1174
1175    fn send_raw(&self, mut result: Result<(), ActivateSensorError>) -> Result<(), fidl::Error> {
1176        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1177            fidl::encoding::EmptyStruct,
1178            ActivateSensorError,
1179        >>(
1180            fidl::encoding::FlexibleResult::new(result),
1181            self.tx_id,
1182            0x5678f117cae5ba42,
1183            fidl::encoding::DynamicFlags::FLEXIBLE,
1184        )
1185    }
1186}
1187
1188#[must_use = "FIDL methods require a response to be sent"]
1189#[derive(Debug)]
1190pub struct ManagerDeactivateResponder {
1191    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
1192    tx_id: u32,
1193}
1194
1195/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
1196/// if the responder is dropped without sending a response, so that the client
1197/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1198impl std::ops::Drop for ManagerDeactivateResponder {
1199    fn drop(&mut self) {
1200        self.control_handle.shutdown();
1201        // Safety: drops once, never accessed again
1202        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1203    }
1204}
1205
1206impl fidl::endpoints::Responder for ManagerDeactivateResponder {
1207    type ControlHandle = ManagerControlHandle;
1208
1209    fn control_handle(&self) -> &ManagerControlHandle {
1210        &self.control_handle
1211    }
1212
1213    fn drop_without_shutdown(mut self) {
1214        // Safety: drops once, never accessed again due to mem::forget
1215        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1216        // Prevent Drop from running (which would shut down the channel)
1217        std::mem::forget(self);
1218    }
1219}
1220
1221impl ManagerDeactivateResponder {
1222    /// Sends a response to the FIDL transaction.
1223    ///
1224    /// Sets the channel to shutdown if an error occurs.
1225    pub fn send(self, mut result: Result<(), DeactivateSensorError>) -> Result<(), fidl::Error> {
1226        let _result = self.send_raw(result);
1227        if _result.is_err() {
1228            self.control_handle.shutdown();
1229        }
1230        self.drop_without_shutdown();
1231        _result
1232    }
1233
1234    /// Similar to "send" but does not shutdown the channel if an error occurs.
1235    pub fn send_no_shutdown_on_err(
1236        self,
1237        mut result: Result<(), DeactivateSensorError>,
1238    ) -> Result<(), fidl::Error> {
1239        let _result = self.send_raw(result);
1240        self.drop_without_shutdown();
1241        _result
1242    }
1243
1244    fn send_raw(&self, mut result: Result<(), DeactivateSensorError>) -> Result<(), fidl::Error> {
1245        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1246            fidl::encoding::EmptyStruct,
1247            DeactivateSensorError,
1248        >>(
1249            fidl::encoding::FlexibleResult::new(result),
1250            self.tx_id,
1251            0x7fafbca62982c87,
1252            fidl::encoding::DynamicFlags::FLEXIBLE,
1253        )
1254    }
1255}
1256
1257mod internal {
1258    use super::*;
1259
1260    impl fidl::encoding::ResourceTypeMarker for ManagerConfigureSensorRatesRequest {
1261        type Borrowed<'a> = &'a mut Self;
1262        fn take_or_borrow<'a>(
1263            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1264        ) -> Self::Borrowed<'a> {
1265            value
1266        }
1267    }
1268
1269    unsafe impl fidl::encoding::TypeMarker for ManagerConfigureSensorRatesRequest {
1270        type Owned = Self;
1271
1272        #[inline(always)]
1273        fn inline_align(_context: fidl::encoding::Context) -> usize {
1274            8
1275        }
1276
1277        #[inline(always)]
1278        fn inline_size(_context: fidl::encoding::Context) -> usize {
1279            24
1280        }
1281    }
1282
1283    unsafe impl
1284        fidl::encoding::Encode<
1285            ManagerConfigureSensorRatesRequest,
1286            fidl::encoding::DefaultFuchsiaResourceDialect,
1287        > for &mut ManagerConfigureSensorRatesRequest
1288    {
1289        #[inline]
1290        unsafe fn encode(
1291            self,
1292            encoder: &mut fidl::encoding::Encoder<
1293                '_,
1294                fidl::encoding::DefaultFuchsiaResourceDialect,
1295            >,
1296            offset: usize,
1297            _depth: fidl::encoding::Depth,
1298        ) -> fidl::Result<()> {
1299            encoder.debug_check_bounds::<ManagerConfigureSensorRatesRequest>(offset);
1300            // Delegate to tuple encoding.
1301            fidl::encoding::Encode::<ManagerConfigureSensorRatesRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1302                (
1303                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
1304                    <fidl_fuchsia_sensors_types::SensorRateConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.sensor_rate_config),
1305                ),
1306                encoder, offset, _depth
1307            )
1308        }
1309    }
1310    unsafe impl<
1311        T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1312        T1: fidl::encoding::Encode<
1313                fidl_fuchsia_sensors_types::SensorRateConfig,
1314                fidl::encoding::DefaultFuchsiaResourceDialect,
1315            >,
1316    >
1317        fidl::encoding::Encode<
1318            ManagerConfigureSensorRatesRequest,
1319            fidl::encoding::DefaultFuchsiaResourceDialect,
1320        > for (T0, T1)
1321    {
1322        #[inline]
1323        unsafe fn encode(
1324            self,
1325            encoder: &mut fidl::encoding::Encoder<
1326                '_,
1327                fidl::encoding::DefaultFuchsiaResourceDialect,
1328            >,
1329            offset: usize,
1330            depth: fidl::encoding::Depth,
1331        ) -> fidl::Result<()> {
1332            encoder.debug_check_bounds::<ManagerConfigureSensorRatesRequest>(offset);
1333            // Zero out padding regions. There's no need to apply masks
1334            // because the unmasked parts will be overwritten by fields.
1335            unsafe {
1336                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1337                (ptr as *mut u64).write_unaligned(0);
1338            }
1339            // Write the fields.
1340            self.0.encode(encoder, offset + 0, depth)?;
1341            self.1.encode(encoder, offset + 8, depth)?;
1342            Ok(())
1343        }
1344    }
1345
1346    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1347        for ManagerConfigureSensorRatesRequest
1348    {
1349        #[inline(always)]
1350        fn new_empty() -> Self {
1351            Self {
1352                id: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
1353                sensor_rate_config: fidl::new_empty!(
1354                    fidl_fuchsia_sensors_types::SensorRateConfig,
1355                    fidl::encoding::DefaultFuchsiaResourceDialect
1356                ),
1357            }
1358        }
1359
1360        #[inline]
1361        unsafe fn decode(
1362            &mut self,
1363            decoder: &mut fidl::encoding::Decoder<
1364                '_,
1365                fidl::encoding::DefaultFuchsiaResourceDialect,
1366            >,
1367            offset: usize,
1368            _depth: fidl::encoding::Depth,
1369        ) -> fidl::Result<()> {
1370            decoder.debug_check_bounds::<Self>(offset);
1371            // Verify that padding bytes are zero.
1372            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1373            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1374            let mask = 0xffffffff00000000u64;
1375            let maskedval = padval & mask;
1376            if maskedval != 0 {
1377                return Err(fidl::Error::NonZeroPadding {
1378                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1379                });
1380            }
1381            fidl::decode!(
1382                i32,
1383                fidl::encoding::DefaultFuchsiaResourceDialect,
1384                &mut self.id,
1385                decoder,
1386                offset + 0,
1387                _depth
1388            )?;
1389            fidl::decode!(
1390                fidl_fuchsia_sensors_types::SensorRateConfig,
1391                fidl::encoding::DefaultFuchsiaResourceDialect,
1392                &mut self.sensor_rate_config,
1393                decoder,
1394                offset + 8,
1395                _depth
1396            )?;
1397            Ok(())
1398        }
1399    }
1400}