Skip to main content

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