Skip to main content

fidl_fuchsia_thermal/
fidl_fuchsia_thermal.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_thermal_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ClientStateConnectorConnectRequest {
16    pub client_type: String,
17    pub watcher: fidl::endpoints::ServerEnd<ClientStateWatcherMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for ClientStateConnectorConnectRequest
22{
23}
24
25#[derive(Debug, Default, PartialEq)]
26pub struct SensorManagerConnectRequest {
27    /// Required.
28    pub name: Option<String>,
29    /// Required.
30    /// Selects which protocol interface (`temperature` or `trippoint`) to connect on the sensor.
31    pub server_end: Option<SensorServer_>,
32    #[doc(hidden)]
33    pub __source_breaking: fidl::marker::SourceBreaking,
34}
35
36impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
37    for SensorManagerConnectRequest
38{
39}
40
41/// The server end for a thermal sensor connection.
42#[derive(Debug)]
43pub enum SensorServer_ {
44    /// Connects to the sensor's `fuchsia.hardware.temperature.Device` protocol.
45    Temperature(fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_temperature::DeviceMarker>),
46    /// Connects to the sensor's `fuchsia.hardware.trippoint.TripPoint` protocol.
47    ///
48    /// Trip point configuration (`SetTripPoints`, `GetTripPointDescriptors`, and
49    /// `WaitForAnyTripPoint`) is shared across all clients connected to the same sensor.
50    Trippoint(fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_trippoint::TripPointMarker>),
51    #[doc(hidden)]
52    __SourceBreaking { unknown_ordinal: u64 },
53}
54
55/// Pattern that matches an unknown `SensorServer_` member.
56#[macro_export]
57macro_rules! SensorServer_Unknown {
58    () => {
59        _
60    };
61}
62
63// Custom PartialEq so that unknown variants are not equal to themselves.
64impl PartialEq for SensorServer_ {
65    fn eq(&self, other: &Self) -> bool {
66        match (self, other) {
67            (Self::Temperature(x), Self::Temperature(y)) => *x == *y,
68            (Self::Trippoint(x), Self::Trippoint(y)) => *x == *y,
69            _ => false,
70        }
71    }
72}
73
74impl SensorServer_ {
75    #[inline]
76    pub fn ordinal(&self) -> u64 {
77        match *self {
78            Self::Temperature(_) => 1,
79            Self::Trippoint(_) => 2,
80            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
81        }
82    }
83
84    #[inline]
85    pub fn unknown_variant_for_testing() -> Self {
86        Self::__SourceBreaking { unknown_ordinal: 0 }
87    }
88
89    #[inline]
90    pub fn is_unknown(&self) -> bool {
91        match self {
92            Self::__SourceBreaking { .. } => true,
93            _ => false,
94        }
95    }
96}
97
98impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SensorServer_ {}
99
100#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
101pub struct ClientStateConnectorMarker;
102
103impl fidl::endpoints::ProtocolMarker for ClientStateConnectorMarker {
104    type Proxy = ClientStateConnectorProxy;
105    type RequestStream = ClientStateConnectorRequestStream;
106    #[cfg(target_os = "fuchsia")]
107    type SynchronousProxy = ClientStateConnectorSynchronousProxy;
108
109    const DEBUG_NAME: &'static str = "fuchsia.thermal.ClientStateConnector";
110}
111impl fidl::endpoints::DiscoverableProtocolMarker for ClientStateConnectorMarker {}
112
113pub trait ClientStateConnectorProxyInterface: Send + Sync {
114    fn r#connect(
115        &self,
116        client_type: &str,
117        watcher: fidl::endpoints::ServerEnd<ClientStateWatcherMarker>,
118    ) -> Result<(), fidl::Error>;
119}
120#[derive(Debug)]
121#[cfg(target_os = "fuchsia")]
122pub struct ClientStateConnectorSynchronousProxy {
123    client: fidl::client::sync::Client,
124}
125
126#[cfg(target_os = "fuchsia")]
127impl fidl::endpoints::SynchronousProxy for ClientStateConnectorSynchronousProxy {
128    type Proxy = ClientStateConnectorProxy;
129    type Protocol = ClientStateConnectorMarker;
130
131    fn from_channel(inner: fidl::Channel) -> Self {
132        Self::new(inner)
133    }
134
135    fn into_channel(self) -> fidl::Channel {
136        self.client.into_channel()
137    }
138
139    fn as_channel(&self) -> &fidl::Channel {
140        self.client.as_channel()
141    }
142}
143
144#[cfg(target_os = "fuchsia")]
145impl ClientStateConnectorSynchronousProxy {
146    pub fn new(channel: fidl::Channel) -> Self {
147        Self { client: fidl::client::sync::Client::new(channel) }
148    }
149
150    pub fn into_channel(self) -> fidl::Channel {
151        self.client.into_channel()
152    }
153
154    /// Waits until an event arrives and returns it. It is safe for other
155    /// threads to make concurrent requests while waiting for an event.
156    pub fn wait_for_event(
157        &self,
158        deadline: zx::MonotonicInstant,
159    ) -> Result<ClientStateConnectorEvent, fidl::Error> {
160        ClientStateConnectorEvent::decode(
161            self.client.wait_for_event::<ClientStateConnectorMarker>(deadline)?,
162        )
163    }
164
165    /// Connects a [`ClientStateWatcher`] to the thermal state of the specified
166    /// [`ClientType`].
167    ///
168    /// A client may call this method and begin using the [`ClientStateWatcher`]
169    /// client endpoint immediately.
170    ///
171    /// If `client_type` does not exactly (case-sensitive) match with a client
172    /// entry found in the central thermal configuration, then the request will
173    /// fail. On failure, both the `watcher` server endpoint as well as the
174    /// current `ClientStateConnector` connection will be terminated.
175    ///
176    /// + `client_type` specifies the client-specific thermal state to which
177    /// `watcher` should be connected. The value is valid iff it matches with a
178    /// client entry found in the central thermal configuration.
179    ///
180    /// + `watcher` is the server endpoint of a [`ClientStateWatcher`] channel
181    /// that will be connected to the thermal state of `client_type`.
182    pub fn r#connect(
183        &self,
184        mut client_type: &str,
185        mut watcher: fidl::endpoints::ServerEnd<ClientStateWatcherMarker>,
186    ) -> Result<(), fidl::Error> {
187        self.client.send::<ClientStateConnectorConnectRequest>(
188            (client_type, watcher),
189            0x65abd3ba57ddaa1d,
190            fidl::encoding::DynamicFlags::empty(),
191        )
192    }
193}
194
195#[cfg(target_os = "fuchsia")]
196impl From<ClientStateConnectorSynchronousProxy> for zx::NullableHandle {
197    fn from(value: ClientStateConnectorSynchronousProxy) -> Self {
198        value.into_channel().into()
199    }
200}
201
202#[cfg(target_os = "fuchsia")]
203impl From<fidl::Channel> for ClientStateConnectorSynchronousProxy {
204    fn from(value: fidl::Channel) -> Self {
205        Self::new(value)
206    }
207}
208
209#[cfg(target_os = "fuchsia")]
210impl fidl::endpoints::FromClient for ClientStateConnectorSynchronousProxy {
211    type Protocol = ClientStateConnectorMarker;
212
213    fn from_client(value: fidl::endpoints::ClientEnd<ClientStateConnectorMarker>) -> Self {
214        Self::new(value.into_channel())
215    }
216}
217
218#[derive(Debug, Clone)]
219pub struct ClientStateConnectorProxy {
220    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
221}
222
223impl fidl::endpoints::Proxy for ClientStateConnectorProxy {
224    type Protocol = ClientStateConnectorMarker;
225
226    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
227        Self::new(inner)
228    }
229
230    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
231        self.client.into_channel().map_err(|client| Self { client })
232    }
233
234    fn as_channel(&self) -> &::fidl::AsyncChannel {
235        self.client.as_channel()
236    }
237}
238
239impl ClientStateConnectorProxy {
240    /// Create a new Proxy for fuchsia.thermal/ClientStateConnector.
241    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
242        let protocol_name =
243            <ClientStateConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
244        Self { client: fidl::client::Client::new(channel, protocol_name) }
245    }
246
247    /// Get a Stream of events from the remote end of the protocol.
248    ///
249    /// # Panics
250    ///
251    /// Panics if the event stream was already taken.
252    pub fn take_event_stream(&self) -> ClientStateConnectorEventStream {
253        ClientStateConnectorEventStream { event_receiver: self.client.take_event_receiver() }
254    }
255
256    /// Connects a [`ClientStateWatcher`] to the thermal state of the specified
257    /// [`ClientType`].
258    ///
259    /// A client may call this method and begin using the [`ClientStateWatcher`]
260    /// client endpoint immediately.
261    ///
262    /// If `client_type` does not exactly (case-sensitive) match with a client
263    /// entry found in the central thermal configuration, then the request will
264    /// fail. On failure, both the `watcher` server endpoint as well as the
265    /// current `ClientStateConnector` connection will be terminated.
266    ///
267    /// + `client_type` specifies the client-specific thermal state to which
268    /// `watcher` should be connected. The value is valid iff it matches with a
269    /// client entry found in the central thermal configuration.
270    ///
271    /// + `watcher` is the server endpoint of a [`ClientStateWatcher`] channel
272    /// that will be connected to the thermal state of `client_type`.
273    pub fn r#connect(
274        &self,
275        mut client_type: &str,
276        mut watcher: fidl::endpoints::ServerEnd<ClientStateWatcherMarker>,
277    ) -> Result<(), fidl::Error> {
278        ClientStateConnectorProxyInterface::r#connect(self, client_type, watcher)
279    }
280}
281
282impl ClientStateConnectorProxyInterface for ClientStateConnectorProxy {
283    fn r#connect(
284        &self,
285        mut client_type: &str,
286        mut watcher: fidl::endpoints::ServerEnd<ClientStateWatcherMarker>,
287    ) -> Result<(), fidl::Error> {
288        self.client.send::<ClientStateConnectorConnectRequest>(
289            (client_type, watcher),
290            0x65abd3ba57ddaa1d,
291            fidl::encoding::DynamicFlags::empty(),
292        )
293    }
294}
295
296pub struct ClientStateConnectorEventStream {
297    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
298}
299
300impl std::marker::Unpin for ClientStateConnectorEventStream {}
301
302impl futures::stream::FusedStream for ClientStateConnectorEventStream {
303    fn is_terminated(&self) -> bool {
304        self.event_receiver.is_terminated()
305    }
306}
307
308impl futures::Stream for ClientStateConnectorEventStream {
309    type Item = Result<ClientStateConnectorEvent, fidl::Error>;
310
311    fn poll_next(
312        mut self: std::pin::Pin<&mut Self>,
313        cx: &mut std::task::Context<'_>,
314    ) -> std::task::Poll<Option<Self::Item>> {
315        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
316            &mut self.event_receiver,
317            cx
318        )?) {
319            Some(buf) => std::task::Poll::Ready(Some(ClientStateConnectorEvent::decode(buf))),
320            None => std::task::Poll::Ready(None),
321        }
322    }
323}
324
325#[derive(Debug)]
326pub enum ClientStateConnectorEvent {}
327
328impl ClientStateConnectorEvent {
329    /// Decodes a message buffer as a [`ClientStateConnectorEvent`].
330    fn decode(
331        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
332    ) -> Result<ClientStateConnectorEvent, fidl::Error> {
333        let (bytes, _handles) = buf.split_mut();
334        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
335        debug_assert_eq!(tx_header.tx_id, 0);
336        match tx_header.ordinal {
337            _ => Err(fidl::Error::UnknownOrdinal {
338                ordinal: tx_header.ordinal,
339                protocol_name:
340                    <ClientStateConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
341            }),
342        }
343    }
344}
345
346/// A Stream of incoming requests for fuchsia.thermal/ClientStateConnector.
347pub struct ClientStateConnectorRequestStream {
348    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
349    is_terminated: bool,
350}
351
352impl std::marker::Unpin for ClientStateConnectorRequestStream {}
353
354impl futures::stream::FusedStream for ClientStateConnectorRequestStream {
355    fn is_terminated(&self) -> bool {
356        self.is_terminated
357    }
358}
359
360impl fidl::endpoints::RequestStream for ClientStateConnectorRequestStream {
361    type Protocol = ClientStateConnectorMarker;
362    type ControlHandle = ClientStateConnectorControlHandle;
363
364    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
365        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
366    }
367
368    fn control_handle(&self) -> Self::ControlHandle {
369        ClientStateConnectorControlHandle { inner: self.inner.clone() }
370    }
371
372    fn into_inner(
373        self,
374    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
375    {
376        (self.inner, self.is_terminated)
377    }
378
379    fn from_inner(
380        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
381        is_terminated: bool,
382    ) -> Self {
383        Self { inner, is_terminated }
384    }
385}
386
387impl futures::Stream for ClientStateConnectorRequestStream {
388    type Item = Result<ClientStateConnectorRequest, fidl::Error>;
389
390    fn poll_next(
391        mut self: std::pin::Pin<&mut Self>,
392        cx: &mut std::task::Context<'_>,
393    ) -> std::task::Poll<Option<Self::Item>> {
394        let this = &mut *self;
395        if this.inner.check_shutdown(cx) {
396            this.is_terminated = true;
397            return std::task::Poll::Ready(None);
398        }
399        if this.is_terminated {
400            panic!("polled ClientStateConnectorRequestStream after completion");
401        }
402        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
403            |bytes, handles| {
404                match this.inner.channel().read_etc(cx, bytes, handles) {
405                    std::task::Poll::Ready(Ok(())) => {}
406                    std::task::Poll::Pending => return std::task::Poll::Pending,
407                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
408                        this.is_terminated = true;
409                        return std::task::Poll::Ready(None);
410                    }
411                    std::task::Poll::Ready(Err(e)) => {
412                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
413                            e.into(),
414                        ))));
415                    }
416                }
417
418                // A message has been received from the channel
419                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
420
421                std::task::Poll::Ready(Some(match header.ordinal {
422                0x65abd3ba57ddaa1d => {
423                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
424                    let mut req = fidl::new_empty!(ClientStateConnectorConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
425                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClientStateConnectorConnectRequest>(&header, _body_bytes, handles, &mut req)?;
426                    let control_handle = ClientStateConnectorControlHandle {
427                        inner: this.inner.clone(),
428                    };
429                    Ok(ClientStateConnectorRequest::Connect {client_type: req.client_type,
430watcher: req.watcher,
431
432                        control_handle,
433                    })
434                }
435                _ => Err(fidl::Error::UnknownOrdinal {
436                    ordinal: header.ordinal,
437                    protocol_name: <ClientStateConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
438                }),
439            }))
440            },
441        )
442    }
443}
444
445/// Allows a client to connect a [`ClientStateWatcher`] to the thermal state of
446/// a given [`ClientType`].
447#[derive(Debug)]
448pub enum ClientStateConnectorRequest {
449    /// Connects a [`ClientStateWatcher`] to the thermal state of the specified
450    /// [`ClientType`].
451    ///
452    /// A client may call this method and begin using the [`ClientStateWatcher`]
453    /// client endpoint immediately.
454    ///
455    /// If `client_type` does not exactly (case-sensitive) match with a client
456    /// entry found in the central thermal configuration, then the request will
457    /// fail. On failure, both the `watcher` server endpoint as well as the
458    /// current `ClientStateConnector` connection will be terminated.
459    ///
460    /// + `client_type` specifies the client-specific thermal state to which
461    /// `watcher` should be connected. The value is valid iff it matches with a
462    /// client entry found in the central thermal configuration.
463    ///
464    /// + `watcher` is the server endpoint of a [`ClientStateWatcher`] channel
465    /// that will be connected to the thermal state of `client_type`.
466    Connect {
467        client_type: String,
468        watcher: fidl::endpoints::ServerEnd<ClientStateWatcherMarker>,
469        control_handle: ClientStateConnectorControlHandle,
470    },
471}
472
473impl ClientStateConnectorRequest {
474    #[allow(irrefutable_let_patterns)]
475    pub fn into_connect(
476        self,
477    ) -> Option<(
478        String,
479        fidl::endpoints::ServerEnd<ClientStateWatcherMarker>,
480        ClientStateConnectorControlHandle,
481    )> {
482        if let ClientStateConnectorRequest::Connect { client_type, watcher, control_handle } = self
483        {
484            Some((client_type, watcher, control_handle))
485        } else {
486            None
487        }
488    }
489
490    /// Name of the method defined in FIDL
491    pub fn method_name(&self) -> &'static str {
492        match *self {
493            ClientStateConnectorRequest::Connect { .. } => "connect",
494        }
495    }
496}
497
498#[derive(Debug, Clone)]
499pub struct ClientStateConnectorControlHandle {
500    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
501}
502
503impl ClientStateConnectorControlHandle {
504    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
505        self.inner.shutdown_with_epitaph(status.into())
506    }
507}
508
509impl fidl::endpoints::ControlHandle for ClientStateConnectorControlHandle {
510    fn shutdown(&self) {
511        self.inner.shutdown()
512    }
513
514    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
515        self.inner.shutdown_with_epitaph(status)
516    }
517
518    fn is_closed(&self) -> bool {
519        self.inner.channel().is_closed()
520    }
521    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
522        self.inner.channel().on_closed()
523    }
524
525    #[cfg(target_os = "fuchsia")]
526    fn signal_peer(
527        &self,
528        clear_mask: zx::Signals,
529        set_mask: zx::Signals,
530    ) -> Result<(), zx_status::Status> {
531        use fidl::Peered;
532        self.inner.channel().signal_peer(clear_mask, set_mask)
533    }
534}
535
536impl ClientStateConnectorControlHandle {}
537
538#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
539pub struct ClientStateWatcherMarker;
540
541impl fidl::endpoints::ProtocolMarker for ClientStateWatcherMarker {
542    type Proxy = ClientStateWatcherProxy;
543    type RequestStream = ClientStateWatcherRequestStream;
544    #[cfg(target_os = "fuchsia")]
545    type SynchronousProxy = ClientStateWatcherSynchronousProxy;
546
547    const DEBUG_NAME: &'static str = "(anonymous) ClientStateWatcher";
548}
549
550pub trait ClientStateWatcherProxyInterface: Send + Sync {
551    type WatchResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
552    fn r#watch(&self) -> Self::WatchResponseFut;
553}
554#[derive(Debug)]
555#[cfg(target_os = "fuchsia")]
556pub struct ClientStateWatcherSynchronousProxy {
557    client: fidl::client::sync::Client,
558}
559
560#[cfg(target_os = "fuchsia")]
561impl fidl::endpoints::SynchronousProxy for ClientStateWatcherSynchronousProxy {
562    type Proxy = ClientStateWatcherProxy;
563    type Protocol = ClientStateWatcherMarker;
564
565    fn from_channel(inner: fidl::Channel) -> Self {
566        Self::new(inner)
567    }
568
569    fn into_channel(self) -> fidl::Channel {
570        self.client.into_channel()
571    }
572
573    fn as_channel(&self) -> &fidl::Channel {
574        self.client.as_channel()
575    }
576}
577
578#[cfg(target_os = "fuchsia")]
579impl ClientStateWatcherSynchronousProxy {
580    pub fn new(channel: fidl::Channel) -> Self {
581        Self { client: fidl::client::sync::Client::new(channel) }
582    }
583
584    pub fn into_channel(self) -> fidl::Channel {
585        self.client.into_channel()
586    }
587
588    /// Waits until an event arrives and returns it. It is safe for other
589    /// threads to make concurrent requests while waiting for an event.
590    pub fn wait_for_event(
591        &self,
592        deadline: zx::MonotonicInstant,
593    ) -> Result<ClientStateWatcherEvent, fidl::Error> {
594        ClientStateWatcherEvent::decode(
595            self.client.wait_for_event::<ClientStateWatcherMarker>(deadline)?,
596        )
597    }
598
599    /// Watches for changes to a client's thermal state.
600    ///
601    /// A client's thermal state is determined according to the central thermal
602    /// configuration of its specific type. See the
603    /// [README.md](/src/power/power-manager/thermal_config/README.md) for more
604    /// details.
605    ///
606    /// On a given connection, the first call will return immediately with the
607    /// client's current thermal state. Subsequent `Watch` requests will only
608    /// return a new `state` if the client's thermal state has changed. This
609    /// follows the [hanging
610    /// get](https://fuchsia.dev/fuchsia-src/concepts/api/fidl#hanging-get)
611    /// pattern.
612    ///
613    /// - `state` is an unsigned integer representing the client's thermal
614    /// state.
615    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
616        let _response = self.client.send_query::<
617            fidl::encoding::EmptyPayload,
618            ClientStateWatcherWatchResponse,
619            ClientStateWatcherMarker,
620        >(
621            (),
622            0x44831316a9942f7e,
623            fidl::encoding::DynamicFlags::empty(),
624            ___deadline,
625        )?;
626        Ok(_response.state)
627    }
628}
629
630#[cfg(target_os = "fuchsia")]
631impl From<ClientStateWatcherSynchronousProxy> for zx::NullableHandle {
632    fn from(value: ClientStateWatcherSynchronousProxy) -> Self {
633        value.into_channel().into()
634    }
635}
636
637#[cfg(target_os = "fuchsia")]
638impl From<fidl::Channel> for ClientStateWatcherSynchronousProxy {
639    fn from(value: fidl::Channel) -> Self {
640        Self::new(value)
641    }
642}
643
644#[cfg(target_os = "fuchsia")]
645impl fidl::endpoints::FromClient for ClientStateWatcherSynchronousProxy {
646    type Protocol = ClientStateWatcherMarker;
647
648    fn from_client(value: fidl::endpoints::ClientEnd<ClientStateWatcherMarker>) -> Self {
649        Self::new(value.into_channel())
650    }
651}
652
653#[derive(Debug, Clone)]
654pub struct ClientStateWatcherProxy {
655    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
656}
657
658impl fidl::endpoints::Proxy for ClientStateWatcherProxy {
659    type Protocol = ClientStateWatcherMarker;
660
661    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
662        Self::new(inner)
663    }
664
665    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
666        self.client.into_channel().map_err(|client| Self { client })
667    }
668
669    fn as_channel(&self) -> &::fidl::AsyncChannel {
670        self.client.as_channel()
671    }
672}
673
674impl ClientStateWatcherProxy {
675    /// Create a new Proxy for fuchsia.thermal/ClientStateWatcher.
676    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
677        let protocol_name =
678            <ClientStateWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
679        Self { client: fidl::client::Client::new(channel, protocol_name) }
680    }
681
682    /// Get a Stream of events from the remote end of the protocol.
683    ///
684    /// # Panics
685    ///
686    /// Panics if the event stream was already taken.
687    pub fn take_event_stream(&self) -> ClientStateWatcherEventStream {
688        ClientStateWatcherEventStream { event_receiver: self.client.take_event_receiver() }
689    }
690
691    /// Watches for changes to a client's thermal state.
692    ///
693    /// A client's thermal state is determined according to the central thermal
694    /// configuration of its specific type. See the
695    /// [README.md](/src/power/power-manager/thermal_config/README.md) for more
696    /// details.
697    ///
698    /// On a given connection, the first call will return immediately with the
699    /// client's current thermal state. Subsequent `Watch` requests will only
700    /// return a new `state` if the client's thermal state has changed. This
701    /// follows the [hanging
702    /// get](https://fuchsia.dev/fuchsia-src/concepts/api/fidl#hanging-get)
703    /// pattern.
704    ///
705    /// - `state` is an unsigned integer representing the client's thermal
706    /// state.
707    pub fn r#watch(
708        &self,
709    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
710        ClientStateWatcherProxyInterface::r#watch(self)
711    }
712}
713
714impl ClientStateWatcherProxyInterface for ClientStateWatcherProxy {
715    type WatchResponseFut =
716        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
717    fn r#watch(&self) -> Self::WatchResponseFut {
718        fn _decode(
719            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
720        ) -> Result<u64, fidl::Error> {
721            let _response = fidl::client::decode_transaction_body::<
722                ClientStateWatcherWatchResponse,
723                fidl::encoding::DefaultFuchsiaResourceDialect,
724                0x44831316a9942f7e,
725            >(_buf?)?;
726            Ok(_response.state)
727        }
728        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
729            (),
730            0x44831316a9942f7e,
731            fidl::encoding::DynamicFlags::empty(),
732            _decode,
733        )
734    }
735}
736
737pub struct ClientStateWatcherEventStream {
738    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
739}
740
741impl std::marker::Unpin for ClientStateWatcherEventStream {}
742
743impl futures::stream::FusedStream for ClientStateWatcherEventStream {
744    fn is_terminated(&self) -> bool {
745        self.event_receiver.is_terminated()
746    }
747}
748
749impl futures::Stream for ClientStateWatcherEventStream {
750    type Item = Result<ClientStateWatcherEvent, fidl::Error>;
751
752    fn poll_next(
753        mut self: std::pin::Pin<&mut Self>,
754        cx: &mut std::task::Context<'_>,
755    ) -> std::task::Poll<Option<Self::Item>> {
756        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
757            &mut self.event_receiver,
758            cx
759        )?) {
760            Some(buf) => std::task::Poll::Ready(Some(ClientStateWatcherEvent::decode(buf))),
761            None => std::task::Poll::Ready(None),
762        }
763    }
764}
765
766#[derive(Debug)]
767pub enum ClientStateWatcherEvent {}
768
769impl ClientStateWatcherEvent {
770    /// Decodes a message buffer as a [`ClientStateWatcherEvent`].
771    fn decode(
772        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
773    ) -> Result<ClientStateWatcherEvent, fidl::Error> {
774        let (bytes, _handles) = buf.split_mut();
775        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
776        debug_assert_eq!(tx_header.tx_id, 0);
777        match tx_header.ordinal {
778            _ => Err(fidl::Error::UnknownOrdinal {
779                ordinal: tx_header.ordinal,
780                protocol_name:
781                    <ClientStateWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
782            }),
783        }
784    }
785}
786
787/// A Stream of incoming requests for fuchsia.thermal/ClientStateWatcher.
788pub struct ClientStateWatcherRequestStream {
789    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
790    is_terminated: bool,
791}
792
793impl std::marker::Unpin for ClientStateWatcherRequestStream {}
794
795impl futures::stream::FusedStream for ClientStateWatcherRequestStream {
796    fn is_terminated(&self) -> bool {
797        self.is_terminated
798    }
799}
800
801impl fidl::endpoints::RequestStream for ClientStateWatcherRequestStream {
802    type Protocol = ClientStateWatcherMarker;
803    type ControlHandle = ClientStateWatcherControlHandle;
804
805    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
806        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
807    }
808
809    fn control_handle(&self) -> Self::ControlHandle {
810        ClientStateWatcherControlHandle { inner: self.inner.clone() }
811    }
812
813    fn into_inner(
814        self,
815    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
816    {
817        (self.inner, self.is_terminated)
818    }
819
820    fn from_inner(
821        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
822        is_terminated: bool,
823    ) -> Self {
824        Self { inner, is_terminated }
825    }
826}
827
828impl futures::Stream for ClientStateWatcherRequestStream {
829    type Item = Result<ClientStateWatcherRequest, fidl::Error>;
830
831    fn poll_next(
832        mut self: std::pin::Pin<&mut Self>,
833        cx: &mut std::task::Context<'_>,
834    ) -> std::task::Poll<Option<Self::Item>> {
835        let this = &mut *self;
836        if this.inner.check_shutdown(cx) {
837            this.is_terminated = true;
838            return std::task::Poll::Ready(None);
839        }
840        if this.is_terminated {
841            panic!("polled ClientStateWatcherRequestStream after completion");
842        }
843        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
844            |bytes, handles| {
845                match this.inner.channel().read_etc(cx, bytes, handles) {
846                    std::task::Poll::Ready(Ok(())) => {}
847                    std::task::Poll::Pending => return std::task::Poll::Pending,
848                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
849                        this.is_terminated = true;
850                        return std::task::Poll::Ready(None);
851                    }
852                    std::task::Poll::Ready(Err(e)) => {
853                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
854                            e.into(),
855                        ))));
856                    }
857                }
858
859                // A message has been received from the channel
860                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
861
862                std::task::Poll::Ready(Some(match header.ordinal {
863                0x44831316a9942f7e => {
864                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
865                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
866                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
867                    let control_handle = ClientStateWatcherControlHandle {
868                        inner: this.inner.clone(),
869                    };
870                    Ok(ClientStateWatcherRequest::Watch {
871                        responder: ClientStateWatcherWatchResponder {
872                            control_handle: std::mem::ManuallyDrop::new(control_handle),
873                            tx_id: header.tx_id,
874                        },
875                    })
876                }
877                _ => Err(fidl::Error::UnknownOrdinal {
878                    ordinal: header.ordinal,
879                    protocol_name: <ClientStateWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
880                }),
881            }))
882            },
883        )
884    }
885}
886
887/// Allows a client to watch for changes to its thermal state.
888///
889/// This protocol cannot be connected to the service directly. Instead, the
890/// server endpoint of a `ClientStateWatcher` channel must be connected to the
891/// thermal state of the desired client type using the
892/// [`ClientStateConnector.Connect'] method. The client endpoint of a
893/// `ClientStateWatcher` channel is only useful after it has been connected in
894/// this way.
895#[derive(Debug)]
896pub enum ClientStateWatcherRequest {
897    /// Watches for changes to a client's thermal state.
898    ///
899    /// A client's thermal state is determined according to the central thermal
900    /// configuration of its specific type. See the
901    /// [README.md](/src/power/power-manager/thermal_config/README.md) for more
902    /// details.
903    ///
904    /// On a given connection, the first call will return immediately with the
905    /// client's current thermal state. Subsequent `Watch` requests will only
906    /// return a new `state` if the client's thermal state has changed. This
907    /// follows the [hanging
908    /// get](https://fuchsia.dev/fuchsia-src/concepts/api/fidl#hanging-get)
909    /// pattern.
910    ///
911    /// - `state` is an unsigned integer representing the client's thermal
912    /// state.
913    Watch { responder: ClientStateWatcherWatchResponder },
914}
915
916impl ClientStateWatcherRequest {
917    #[allow(irrefutable_let_patterns)]
918    pub fn into_watch(self) -> Option<(ClientStateWatcherWatchResponder)> {
919        if let ClientStateWatcherRequest::Watch { responder } = self {
920            Some((responder))
921        } else {
922            None
923        }
924    }
925
926    /// Name of the method defined in FIDL
927    pub fn method_name(&self) -> &'static str {
928        match *self {
929            ClientStateWatcherRequest::Watch { .. } => "watch",
930        }
931    }
932}
933
934#[derive(Debug, Clone)]
935pub struct ClientStateWatcherControlHandle {
936    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
937}
938
939impl ClientStateWatcherControlHandle {
940    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
941        self.inner.shutdown_with_epitaph(status.into())
942    }
943}
944
945impl fidl::endpoints::ControlHandle for ClientStateWatcherControlHandle {
946    fn shutdown(&self) {
947        self.inner.shutdown()
948    }
949
950    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
951        self.inner.shutdown_with_epitaph(status)
952    }
953
954    fn is_closed(&self) -> bool {
955        self.inner.channel().is_closed()
956    }
957    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
958        self.inner.channel().on_closed()
959    }
960
961    #[cfg(target_os = "fuchsia")]
962    fn signal_peer(
963        &self,
964        clear_mask: zx::Signals,
965        set_mask: zx::Signals,
966    ) -> Result<(), zx_status::Status> {
967        use fidl::Peered;
968        self.inner.channel().signal_peer(clear_mask, set_mask)
969    }
970}
971
972impl ClientStateWatcherControlHandle {}
973
974#[must_use = "FIDL methods require a response to be sent"]
975#[derive(Debug)]
976pub struct ClientStateWatcherWatchResponder {
977    control_handle: std::mem::ManuallyDrop<ClientStateWatcherControlHandle>,
978    tx_id: u32,
979}
980
981/// Set the the channel to be shutdown (see [`ClientStateWatcherControlHandle::shutdown`])
982/// if the responder is dropped without sending a response, so that the client
983/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
984impl std::ops::Drop for ClientStateWatcherWatchResponder {
985    fn drop(&mut self) {
986        self.control_handle.shutdown();
987        // Safety: drops once, never accessed again
988        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
989    }
990}
991
992impl fidl::endpoints::Responder for ClientStateWatcherWatchResponder {
993    type ControlHandle = ClientStateWatcherControlHandle;
994
995    fn control_handle(&self) -> &ClientStateWatcherControlHandle {
996        &self.control_handle
997    }
998
999    fn drop_without_shutdown(mut self) {
1000        // Safety: drops once, never accessed again due to mem::forget
1001        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1002        // Prevent Drop from running (which would shut down the channel)
1003        std::mem::forget(self);
1004    }
1005}
1006
1007impl ClientStateWatcherWatchResponder {
1008    /// Sends a response to the FIDL transaction.
1009    ///
1010    /// Sets the channel to shutdown if an error occurs.
1011    pub fn send(self, mut state: u64) -> Result<(), fidl::Error> {
1012        let _result = self.send_raw(state);
1013        if _result.is_err() {
1014            self.control_handle.shutdown();
1015        }
1016        self.drop_without_shutdown();
1017        _result
1018    }
1019
1020    /// Similar to "send" but does not shutdown the channel if an error occurs.
1021    pub fn send_no_shutdown_on_err(self, mut state: u64) -> Result<(), fidl::Error> {
1022        let _result = self.send_raw(state);
1023        self.drop_without_shutdown();
1024        _result
1025    }
1026
1027    fn send_raw(&self, mut state: u64) -> Result<(), fidl::Error> {
1028        self.control_handle.inner.send::<ClientStateWatcherWatchResponse>(
1029            (state,),
1030            self.tx_id,
1031            0x44831316a9942f7e,
1032            fidl::encoding::DynamicFlags::empty(),
1033        )
1034    }
1035}
1036
1037#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1038pub struct SensorManagerMarker;
1039
1040impl fidl::endpoints::ProtocolMarker for SensorManagerMarker {
1041    type Proxy = SensorManagerProxy;
1042    type RequestStream = SensorManagerRequestStream;
1043    #[cfg(target_os = "fuchsia")]
1044    type SynchronousProxy = SensorManagerSynchronousProxy;
1045
1046    const DEBUG_NAME: &'static str = "fuchsia.thermal.SensorManager";
1047}
1048impl fidl::endpoints::DiscoverableProtocolMarker for SensorManagerMarker {}
1049pub type SensorManagerSetTemperatureOverrideResult = Result<(), SetTemperatureOverrideError>;
1050pub type SensorManagerClearTemperatureOverrideResult = Result<(), ClearTemperatureOverrideError>;
1051pub type SensorManagerConnectResult = Result<(), ConnectError>;
1052
1053pub trait SensorManagerProxyInterface: Send + Sync {
1054    type ListSensorsResponseFut: std::future::Future<Output = Result<Vec<SensorInfo>, fidl::Error>>
1055        + Send;
1056    fn r#list_sensors(&self) -> Self::ListSensorsResponseFut;
1057    type SetTemperatureOverrideResponseFut: std::future::Future<Output = Result<SensorManagerSetTemperatureOverrideResult, fidl::Error>>
1058        + Send;
1059    fn r#set_temperature_override(
1060        &self,
1061        name: &str,
1062        override_temperature: f32,
1063    ) -> Self::SetTemperatureOverrideResponseFut;
1064    type ClearTemperatureOverrideResponseFut: std::future::Future<
1065            Output = Result<SensorManagerClearTemperatureOverrideResult, fidl::Error>,
1066        > + Send;
1067    fn r#clear_temperature_override(&self, name: &str)
1068    -> Self::ClearTemperatureOverrideResponseFut;
1069    type ConnectResponseFut: std::future::Future<Output = Result<SensorManagerConnectResult, fidl::Error>>
1070        + Send;
1071    fn r#connect(&self, payload: SensorManagerConnectRequest) -> Self::ConnectResponseFut;
1072}
1073#[derive(Debug)]
1074#[cfg(target_os = "fuchsia")]
1075pub struct SensorManagerSynchronousProxy {
1076    client: fidl::client::sync::Client,
1077}
1078
1079#[cfg(target_os = "fuchsia")]
1080impl fidl::endpoints::SynchronousProxy for SensorManagerSynchronousProxy {
1081    type Proxy = SensorManagerProxy;
1082    type Protocol = SensorManagerMarker;
1083
1084    fn from_channel(inner: fidl::Channel) -> Self {
1085        Self::new(inner)
1086    }
1087
1088    fn into_channel(self) -> fidl::Channel {
1089        self.client.into_channel()
1090    }
1091
1092    fn as_channel(&self) -> &fidl::Channel {
1093        self.client.as_channel()
1094    }
1095}
1096
1097#[cfg(target_os = "fuchsia")]
1098impl SensorManagerSynchronousProxy {
1099    pub fn new(channel: fidl::Channel) -> Self {
1100        Self { client: fidl::client::sync::Client::new(channel) }
1101    }
1102
1103    pub fn into_channel(self) -> fidl::Channel {
1104        self.client.into_channel()
1105    }
1106
1107    /// Waits until an event arrives and returns it. It is safe for other
1108    /// threads to make concurrent requests while waiting for an event.
1109    pub fn wait_for_event(
1110        &self,
1111        deadline: zx::MonotonicInstant,
1112    ) -> Result<SensorManagerEvent, fidl::Error> {
1113        SensorManagerEvent::decode(self.client.wait_for_event::<SensorManagerMarker>(deadline)?)
1114    }
1115
1116    /// Lists sensors that may be controlled and connected to by clients.
1117    pub fn r#list_sensors(
1118        &self,
1119        ___deadline: zx::MonotonicInstant,
1120    ) -> Result<Vec<SensorInfo>, fidl::Error> {
1121        let _response = self.client.send_query::<
1122            fidl::encoding::EmptyPayload,
1123            fidl::encoding::FlexibleType<SensorManagerListSensorsResponse>,
1124            SensorManagerMarker,
1125        >(
1126            (),
1127            0x4407236d8bad1a9b,
1128            fidl::encoding::DynamicFlags::FLEXIBLE,
1129            ___deadline,
1130        )?
1131        .into_result::<SensorManagerMarker>("list_sensors")?;
1132        Ok(_response.sensors)
1133    }
1134
1135    /// Sets an override temperature for the sensor with `name`.
1136    ///
1137    /// When an override temperature is set, internal thermal policies will
1138    /// use the override temperature. Temperature values retrieved from
1139    /// sensor connections vended by `Connect` will also receive the override
1140    /// temperature.
1141    ///
1142    /// This interaction does not affect the thermal sensor itself.
1143    /// Clients who connect directly to the sensor without `Connect` will
1144    /// receive the real sensor value.
1145    ///
1146    /// If a sensor with the given `name` is not found,
1147    /// `SetTemperatureOverrideError.SENSOR_NOT_FOUND` is returned.
1148    pub fn r#set_temperature_override(
1149        &self,
1150        mut name: &str,
1151        mut override_temperature: f32,
1152        ___deadline: zx::MonotonicInstant,
1153    ) -> Result<SensorManagerSetTemperatureOverrideResult, fidl::Error> {
1154        let _response = self.client.send_query::<
1155            SensorManagerSetTemperatureOverrideRequest,
1156            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, SetTemperatureOverrideError>,
1157            SensorManagerMarker,
1158        >(
1159            (name, override_temperature,),
1160            0x13abb6faff00a238,
1161            fidl::encoding::DynamicFlags::FLEXIBLE,
1162            ___deadline,
1163        )?
1164        .into_result::<SensorManagerMarker>("set_temperature_override")?;
1165        Ok(_response.map(|x| x))
1166    }
1167
1168    /// Clears the temperature override set by `SetTemperatureOverride`.
1169    /// If no temperature override has been set, this interaction does nothing.
1170    ///
1171    /// If a sensor with the given `name` is not found,
1172    /// `ClearTemperatureOverrideError.SENSOR_NOT_FOUND` is returned.
1173    pub fn r#clear_temperature_override(
1174        &self,
1175        mut name: &str,
1176        ___deadline: zx::MonotonicInstant,
1177    ) -> Result<SensorManagerClearTemperatureOverrideResult, fidl::Error> {
1178        let _response = self.client.send_query::<
1179            SensorManagerClearTemperatureOverrideRequest,
1180            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, ClearTemperatureOverrideError>,
1181            SensorManagerMarker,
1182        >(
1183            (name,),
1184            0x3ad5b3a009f687cb,
1185            fidl::encoding::DynamicFlags::FLEXIBLE,
1186            ___deadline,
1187        )?
1188        .into_result::<SensorManagerMarker>("clear_temperature_override")?;
1189        Ok(_response.map(|x| x))
1190    }
1191
1192    /// Connects to the thermal sensor with the given `name`.
1193    ///
1194    /// If any required arguments are not provided,
1195    /// `ConnectError.INVALID_ARGUMENTS` is returned.
1196    ///
1197    /// If a sensor with the given `name` is not found,
1198    /// `ConnectError.SENSOR_NOT_FOUND` is returned.
1199    pub fn r#connect(
1200        &self,
1201        mut payload: SensorManagerConnectRequest,
1202        ___deadline: zx::MonotonicInstant,
1203    ) -> Result<SensorManagerConnectResult, fidl::Error> {
1204        let _response = self.client.send_query::<
1205            SensorManagerConnectRequest,
1206            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, ConnectError>,
1207            SensorManagerMarker,
1208        >(
1209            &mut payload,
1210            0x76abcbb8819f26bf,
1211            fidl::encoding::DynamicFlags::FLEXIBLE,
1212            ___deadline,
1213        )?
1214        .into_result::<SensorManagerMarker>("connect")?;
1215        Ok(_response.map(|x| x))
1216    }
1217}
1218
1219#[cfg(target_os = "fuchsia")]
1220impl From<SensorManagerSynchronousProxy> for zx::NullableHandle {
1221    fn from(value: SensorManagerSynchronousProxy) -> Self {
1222        value.into_channel().into()
1223    }
1224}
1225
1226#[cfg(target_os = "fuchsia")]
1227impl From<fidl::Channel> for SensorManagerSynchronousProxy {
1228    fn from(value: fidl::Channel) -> Self {
1229        Self::new(value)
1230    }
1231}
1232
1233#[cfg(target_os = "fuchsia")]
1234impl fidl::endpoints::FromClient for SensorManagerSynchronousProxy {
1235    type Protocol = SensorManagerMarker;
1236
1237    fn from_client(value: fidl::endpoints::ClientEnd<SensorManagerMarker>) -> Self {
1238        Self::new(value.into_channel())
1239    }
1240}
1241
1242#[derive(Debug, Clone)]
1243pub struct SensorManagerProxy {
1244    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1245}
1246
1247impl fidl::endpoints::Proxy for SensorManagerProxy {
1248    type Protocol = SensorManagerMarker;
1249
1250    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1251        Self::new(inner)
1252    }
1253
1254    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1255        self.client.into_channel().map_err(|client| Self { client })
1256    }
1257
1258    fn as_channel(&self) -> &::fidl::AsyncChannel {
1259        self.client.as_channel()
1260    }
1261}
1262
1263impl SensorManagerProxy {
1264    /// Create a new Proxy for fuchsia.thermal/SensorManager.
1265    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1266        let protocol_name = <SensorManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1267        Self { client: fidl::client::Client::new(channel, protocol_name) }
1268    }
1269
1270    /// Get a Stream of events from the remote end of the protocol.
1271    ///
1272    /// # Panics
1273    ///
1274    /// Panics if the event stream was already taken.
1275    pub fn take_event_stream(&self) -> SensorManagerEventStream {
1276        SensorManagerEventStream { event_receiver: self.client.take_event_receiver() }
1277    }
1278
1279    /// Lists sensors that may be controlled and connected to by clients.
1280    pub fn r#list_sensors(
1281        &self,
1282    ) -> fidl::client::QueryResponseFut<
1283        Vec<SensorInfo>,
1284        fidl::encoding::DefaultFuchsiaResourceDialect,
1285    > {
1286        SensorManagerProxyInterface::r#list_sensors(self)
1287    }
1288
1289    /// Sets an override temperature for the sensor with `name`.
1290    ///
1291    /// When an override temperature is set, internal thermal policies will
1292    /// use the override temperature. Temperature values retrieved from
1293    /// sensor connections vended by `Connect` will also receive the override
1294    /// temperature.
1295    ///
1296    /// This interaction does not affect the thermal sensor itself.
1297    /// Clients who connect directly to the sensor without `Connect` will
1298    /// receive the real sensor value.
1299    ///
1300    /// If a sensor with the given `name` is not found,
1301    /// `SetTemperatureOverrideError.SENSOR_NOT_FOUND` is returned.
1302    pub fn r#set_temperature_override(
1303        &self,
1304        mut name: &str,
1305        mut override_temperature: f32,
1306    ) -> fidl::client::QueryResponseFut<
1307        SensorManagerSetTemperatureOverrideResult,
1308        fidl::encoding::DefaultFuchsiaResourceDialect,
1309    > {
1310        SensorManagerProxyInterface::r#set_temperature_override(self, name, override_temperature)
1311    }
1312
1313    /// Clears the temperature override set by `SetTemperatureOverride`.
1314    /// If no temperature override has been set, this interaction does nothing.
1315    ///
1316    /// If a sensor with the given `name` is not found,
1317    /// `ClearTemperatureOverrideError.SENSOR_NOT_FOUND` is returned.
1318    pub fn r#clear_temperature_override(
1319        &self,
1320        mut name: &str,
1321    ) -> fidl::client::QueryResponseFut<
1322        SensorManagerClearTemperatureOverrideResult,
1323        fidl::encoding::DefaultFuchsiaResourceDialect,
1324    > {
1325        SensorManagerProxyInterface::r#clear_temperature_override(self, name)
1326    }
1327
1328    /// Connects to the thermal sensor with the given `name`.
1329    ///
1330    /// If any required arguments are not provided,
1331    /// `ConnectError.INVALID_ARGUMENTS` is returned.
1332    ///
1333    /// If a sensor with the given `name` is not found,
1334    /// `ConnectError.SENSOR_NOT_FOUND` is returned.
1335    pub fn r#connect(
1336        &self,
1337        mut payload: SensorManagerConnectRequest,
1338    ) -> fidl::client::QueryResponseFut<
1339        SensorManagerConnectResult,
1340        fidl::encoding::DefaultFuchsiaResourceDialect,
1341    > {
1342        SensorManagerProxyInterface::r#connect(self, payload)
1343    }
1344}
1345
1346impl SensorManagerProxyInterface for SensorManagerProxy {
1347    type ListSensorsResponseFut = fidl::client::QueryResponseFut<
1348        Vec<SensorInfo>,
1349        fidl::encoding::DefaultFuchsiaResourceDialect,
1350    >;
1351    fn r#list_sensors(&self) -> Self::ListSensorsResponseFut {
1352        fn _decode(
1353            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1354        ) -> Result<Vec<SensorInfo>, fidl::Error> {
1355            let _response = fidl::client::decode_transaction_body::<
1356                fidl::encoding::FlexibleType<SensorManagerListSensorsResponse>,
1357                fidl::encoding::DefaultFuchsiaResourceDialect,
1358                0x4407236d8bad1a9b,
1359            >(_buf?)?
1360            .into_result::<SensorManagerMarker>("list_sensors")?;
1361            Ok(_response.sensors)
1362        }
1363        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<SensorInfo>>(
1364            (),
1365            0x4407236d8bad1a9b,
1366            fidl::encoding::DynamicFlags::FLEXIBLE,
1367            _decode,
1368        )
1369    }
1370
1371    type SetTemperatureOverrideResponseFut = fidl::client::QueryResponseFut<
1372        SensorManagerSetTemperatureOverrideResult,
1373        fidl::encoding::DefaultFuchsiaResourceDialect,
1374    >;
1375    fn r#set_temperature_override(
1376        &self,
1377        mut name: &str,
1378        mut override_temperature: f32,
1379    ) -> Self::SetTemperatureOverrideResponseFut {
1380        fn _decode(
1381            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1382        ) -> Result<SensorManagerSetTemperatureOverrideResult, fidl::Error> {
1383            let _response = fidl::client::decode_transaction_body::<
1384                fidl::encoding::FlexibleResultType<
1385                    fidl::encoding::EmptyStruct,
1386                    SetTemperatureOverrideError,
1387                >,
1388                fidl::encoding::DefaultFuchsiaResourceDialect,
1389                0x13abb6faff00a238,
1390            >(_buf?)?
1391            .into_result::<SensorManagerMarker>("set_temperature_override")?;
1392            Ok(_response.map(|x| x))
1393        }
1394        self.client.send_query_and_decode::<
1395            SensorManagerSetTemperatureOverrideRequest,
1396            SensorManagerSetTemperatureOverrideResult,
1397        >(
1398            (name, override_temperature,),
1399            0x13abb6faff00a238,
1400            fidl::encoding::DynamicFlags::FLEXIBLE,
1401            _decode,
1402        )
1403    }
1404
1405    type ClearTemperatureOverrideResponseFut = fidl::client::QueryResponseFut<
1406        SensorManagerClearTemperatureOverrideResult,
1407        fidl::encoding::DefaultFuchsiaResourceDialect,
1408    >;
1409    fn r#clear_temperature_override(
1410        &self,
1411        mut name: &str,
1412    ) -> Self::ClearTemperatureOverrideResponseFut {
1413        fn _decode(
1414            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1415        ) -> Result<SensorManagerClearTemperatureOverrideResult, fidl::Error> {
1416            let _response = fidl::client::decode_transaction_body::<
1417                fidl::encoding::FlexibleResultType<
1418                    fidl::encoding::EmptyStruct,
1419                    ClearTemperatureOverrideError,
1420                >,
1421                fidl::encoding::DefaultFuchsiaResourceDialect,
1422                0x3ad5b3a009f687cb,
1423            >(_buf?)?
1424            .into_result::<SensorManagerMarker>("clear_temperature_override")?;
1425            Ok(_response.map(|x| x))
1426        }
1427        self.client.send_query_and_decode::<
1428            SensorManagerClearTemperatureOverrideRequest,
1429            SensorManagerClearTemperatureOverrideResult,
1430        >(
1431            (name,),
1432            0x3ad5b3a009f687cb,
1433            fidl::encoding::DynamicFlags::FLEXIBLE,
1434            _decode,
1435        )
1436    }
1437
1438    type ConnectResponseFut = fidl::client::QueryResponseFut<
1439        SensorManagerConnectResult,
1440        fidl::encoding::DefaultFuchsiaResourceDialect,
1441    >;
1442    fn r#connect(&self, mut payload: SensorManagerConnectRequest) -> Self::ConnectResponseFut {
1443        fn _decode(
1444            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1445        ) -> Result<SensorManagerConnectResult, fidl::Error> {
1446            let _response = fidl::client::decode_transaction_body::<
1447                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, ConnectError>,
1448                fidl::encoding::DefaultFuchsiaResourceDialect,
1449                0x76abcbb8819f26bf,
1450            >(_buf?)?
1451            .into_result::<SensorManagerMarker>("connect")?;
1452            Ok(_response.map(|x| x))
1453        }
1454        self.client
1455            .send_query_and_decode::<SensorManagerConnectRequest, SensorManagerConnectResult>(
1456                &mut payload,
1457                0x76abcbb8819f26bf,
1458                fidl::encoding::DynamicFlags::FLEXIBLE,
1459                _decode,
1460            )
1461    }
1462}
1463
1464pub struct SensorManagerEventStream {
1465    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1466}
1467
1468impl std::marker::Unpin for SensorManagerEventStream {}
1469
1470impl futures::stream::FusedStream for SensorManagerEventStream {
1471    fn is_terminated(&self) -> bool {
1472        self.event_receiver.is_terminated()
1473    }
1474}
1475
1476impl futures::Stream for SensorManagerEventStream {
1477    type Item = Result<SensorManagerEvent, fidl::Error>;
1478
1479    fn poll_next(
1480        mut self: std::pin::Pin<&mut Self>,
1481        cx: &mut std::task::Context<'_>,
1482    ) -> std::task::Poll<Option<Self::Item>> {
1483        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1484            &mut self.event_receiver,
1485            cx
1486        )?) {
1487            Some(buf) => std::task::Poll::Ready(Some(SensorManagerEvent::decode(buf))),
1488            None => std::task::Poll::Ready(None),
1489        }
1490    }
1491}
1492
1493#[derive(Debug)]
1494pub enum SensorManagerEvent {
1495    #[non_exhaustive]
1496    _UnknownEvent {
1497        /// Ordinal of the event that was sent.
1498        ordinal: u64,
1499    },
1500}
1501
1502impl SensorManagerEvent {
1503    /// Decodes a message buffer as a [`SensorManagerEvent`].
1504    fn decode(
1505        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1506    ) -> Result<SensorManagerEvent, fidl::Error> {
1507        let (bytes, _handles) = buf.split_mut();
1508        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1509        debug_assert_eq!(tx_header.tx_id, 0);
1510        match tx_header.ordinal {
1511            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1512                Ok(SensorManagerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1513            }
1514            _ => Err(fidl::Error::UnknownOrdinal {
1515                ordinal: tx_header.ordinal,
1516                protocol_name: <SensorManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1517            }),
1518        }
1519    }
1520}
1521
1522/// A Stream of incoming requests for fuchsia.thermal/SensorManager.
1523pub struct SensorManagerRequestStream {
1524    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1525    is_terminated: bool,
1526}
1527
1528impl std::marker::Unpin for SensorManagerRequestStream {}
1529
1530impl futures::stream::FusedStream for SensorManagerRequestStream {
1531    fn is_terminated(&self) -> bool {
1532        self.is_terminated
1533    }
1534}
1535
1536impl fidl::endpoints::RequestStream for SensorManagerRequestStream {
1537    type Protocol = SensorManagerMarker;
1538    type ControlHandle = SensorManagerControlHandle;
1539
1540    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1541        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1542    }
1543
1544    fn control_handle(&self) -> Self::ControlHandle {
1545        SensorManagerControlHandle { inner: self.inner.clone() }
1546    }
1547
1548    fn into_inner(
1549        self,
1550    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1551    {
1552        (self.inner, self.is_terminated)
1553    }
1554
1555    fn from_inner(
1556        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1557        is_terminated: bool,
1558    ) -> Self {
1559        Self { inner, is_terminated }
1560    }
1561}
1562
1563impl futures::Stream for SensorManagerRequestStream {
1564    type Item = Result<SensorManagerRequest, fidl::Error>;
1565
1566    fn poll_next(
1567        mut self: std::pin::Pin<&mut Self>,
1568        cx: &mut std::task::Context<'_>,
1569    ) -> std::task::Poll<Option<Self::Item>> {
1570        let this = &mut *self;
1571        if this.inner.check_shutdown(cx) {
1572            this.is_terminated = true;
1573            return std::task::Poll::Ready(None);
1574        }
1575        if this.is_terminated {
1576            panic!("polled SensorManagerRequestStream after completion");
1577        }
1578        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1579            |bytes, handles| {
1580                match this.inner.channel().read_etc(cx, bytes, handles) {
1581                    std::task::Poll::Ready(Ok(())) => {}
1582                    std::task::Poll::Pending => return std::task::Poll::Pending,
1583                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1584                        this.is_terminated = true;
1585                        return std::task::Poll::Ready(None);
1586                    }
1587                    std::task::Poll::Ready(Err(e)) => {
1588                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1589                            e.into(),
1590                        ))));
1591                    }
1592                }
1593
1594                // A message has been received from the channel
1595                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1596
1597                std::task::Poll::Ready(Some(match header.ordinal {
1598                    0x4407236d8bad1a9b => {
1599                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1600                        let mut req = fidl::new_empty!(
1601                            fidl::encoding::EmptyPayload,
1602                            fidl::encoding::DefaultFuchsiaResourceDialect
1603                        );
1604                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1605                        let control_handle =
1606                            SensorManagerControlHandle { inner: this.inner.clone() };
1607                        Ok(SensorManagerRequest::ListSensors {
1608                            responder: SensorManagerListSensorsResponder {
1609                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1610                                tx_id: header.tx_id,
1611                            },
1612                        })
1613                    }
1614                    0x13abb6faff00a238 => {
1615                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1616                        let mut req = fidl::new_empty!(
1617                            SensorManagerSetTemperatureOverrideRequest,
1618                            fidl::encoding::DefaultFuchsiaResourceDialect
1619                        );
1620                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SensorManagerSetTemperatureOverrideRequest>(&header, _body_bytes, handles, &mut req)?;
1621                        let control_handle =
1622                            SensorManagerControlHandle { inner: this.inner.clone() };
1623                        Ok(SensorManagerRequest::SetTemperatureOverride {
1624                            name: req.name,
1625                            override_temperature: req.override_temperature,
1626
1627                            responder: SensorManagerSetTemperatureOverrideResponder {
1628                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1629                                tx_id: header.tx_id,
1630                            },
1631                        })
1632                    }
1633                    0x3ad5b3a009f687cb => {
1634                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1635                        let mut req = fidl::new_empty!(
1636                            SensorManagerClearTemperatureOverrideRequest,
1637                            fidl::encoding::DefaultFuchsiaResourceDialect
1638                        );
1639                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SensorManagerClearTemperatureOverrideRequest>(&header, _body_bytes, handles, &mut req)?;
1640                        let control_handle =
1641                            SensorManagerControlHandle { inner: this.inner.clone() };
1642                        Ok(SensorManagerRequest::ClearTemperatureOverride {
1643                            name: req.name,
1644
1645                            responder: SensorManagerClearTemperatureOverrideResponder {
1646                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1647                                tx_id: header.tx_id,
1648                            },
1649                        })
1650                    }
1651                    0x76abcbb8819f26bf => {
1652                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1653                        let mut req = fidl::new_empty!(
1654                            SensorManagerConnectRequest,
1655                            fidl::encoding::DefaultFuchsiaResourceDialect
1656                        );
1657                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SensorManagerConnectRequest>(&header, _body_bytes, handles, &mut req)?;
1658                        let control_handle =
1659                            SensorManagerControlHandle { inner: this.inner.clone() };
1660                        Ok(SensorManagerRequest::Connect {
1661                            payload: req,
1662                            responder: SensorManagerConnectResponder {
1663                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1664                                tx_id: header.tx_id,
1665                            },
1666                        })
1667                    }
1668                    _ if header.tx_id == 0
1669                        && header
1670                            .dynamic_flags()
1671                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1672                    {
1673                        Ok(SensorManagerRequest::_UnknownMethod {
1674                            ordinal: header.ordinal,
1675                            control_handle: SensorManagerControlHandle {
1676                                inner: this.inner.clone(),
1677                            },
1678                            method_type: fidl::MethodType::OneWay,
1679                        })
1680                    }
1681                    _ if header
1682                        .dynamic_flags()
1683                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1684                    {
1685                        this.inner.send_framework_err(
1686                            fidl::encoding::FrameworkErr::UnknownMethod,
1687                            header.tx_id,
1688                            header.ordinal,
1689                            header.dynamic_flags(),
1690                            (bytes, handles),
1691                        )?;
1692                        Ok(SensorManagerRequest::_UnknownMethod {
1693                            ordinal: header.ordinal,
1694                            control_handle: SensorManagerControlHandle {
1695                                inner: this.inner.clone(),
1696                            },
1697                            method_type: fidl::MethodType::TwoWay,
1698                        })
1699                    }
1700                    _ => Err(fidl::Error::UnknownOrdinal {
1701                        ordinal: header.ordinal,
1702                        protocol_name:
1703                            <SensorManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1704                    }),
1705                }))
1706            },
1707        )
1708    }
1709}
1710
1711/// Interface that manages interactions and the working state of thermal sensors.
1712#[derive(Debug)]
1713pub enum SensorManagerRequest {
1714    /// Lists sensors that may be controlled and connected to by clients.
1715    ListSensors { responder: SensorManagerListSensorsResponder },
1716    /// Sets an override temperature for the sensor with `name`.
1717    ///
1718    /// When an override temperature is set, internal thermal policies will
1719    /// use the override temperature. Temperature values retrieved from
1720    /// sensor connections vended by `Connect` will also receive the override
1721    /// temperature.
1722    ///
1723    /// This interaction does not affect the thermal sensor itself.
1724    /// Clients who connect directly to the sensor without `Connect` will
1725    /// receive the real sensor value.
1726    ///
1727    /// If a sensor with the given `name` is not found,
1728    /// `SetTemperatureOverrideError.SENSOR_NOT_FOUND` is returned.
1729    SetTemperatureOverride {
1730        name: String,
1731        override_temperature: f32,
1732        responder: SensorManagerSetTemperatureOverrideResponder,
1733    },
1734    /// Clears the temperature override set by `SetTemperatureOverride`.
1735    /// If no temperature override has been set, this interaction does nothing.
1736    ///
1737    /// If a sensor with the given `name` is not found,
1738    /// `ClearTemperatureOverrideError.SENSOR_NOT_FOUND` is returned.
1739    ClearTemperatureOverride {
1740        name: String,
1741        responder: SensorManagerClearTemperatureOverrideResponder,
1742    },
1743    /// Connects to the thermal sensor with the given `name`.
1744    ///
1745    /// If any required arguments are not provided,
1746    /// `ConnectError.INVALID_ARGUMENTS` is returned.
1747    ///
1748    /// If a sensor with the given `name` is not found,
1749    /// `ConnectError.SENSOR_NOT_FOUND` is returned.
1750    Connect { payload: SensorManagerConnectRequest, responder: SensorManagerConnectResponder },
1751    /// An interaction was received which does not match any known method.
1752    #[non_exhaustive]
1753    _UnknownMethod {
1754        /// Ordinal of the method that was called.
1755        ordinal: u64,
1756        control_handle: SensorManagerControlHandle,
1757        method_type: fidl::MethodType,
1758    },
1759}
1760
1761impl SensorManagerRequest {
1762    #[allow(irrefutable_let_patterns)]
1763    pub fn into_list_sensors(self) -> Option<(SensorManagerListSensorsResponder)> {
1764        if let SensorManagerRequest::ListSensors { responder } = self {
1765            Some((responder))
1766        } else {
1767            None
1768        }
1769    }
1770
1771    #[allow(irrefutable_let_patterns)]
1772    pub fn into_set_temperature_override(
1773        self,
1774    ) -> Option<(String, f32, SensorManagerSetTemperatureOverrideResponder)> {
1775        if let SensorManagerRequest::SetTemperatureOverride {
1776            name,
1777            override_temperature,
1778            responder,
1779        } = self
1780        {
1781            Some((name, override_temperature, responder))
1782        } else {
1783            None
1784        }
1785    }
1786
1787    #[allow(irrefutable_let_patterns)]
1788    pub fn into_clear_temperature_override(
1789        self,
1790    ) -> Option<(String, SensorManagerClearTemperatureOverrideResponder)> {
1791        if let SensorManagerRequest::ClearTemperatureOverride { name, responder } = self {
1792            Some((name, responder))
1793        } else {
1794            None
1795        }
1796    }
1797
1798    #[allow(irrefutable_let_patterns)]
1799    pub fn into_connect(
1800        self,
1801    ) -> Option<(SensorManagerConnectRequest, SensorManagerConnectResponder)> {
1802        if let SensorManagerRequest::Connect { payload, responder } = self {
1803            Some((payload, responder))
1804        } else {
1805            None
1806        }
1807    }
1808
1809    /// Name of the method defined in FIDL
1810    pub fn method_name(&self) -> &'static str {
1811        match *self {
1812            SensorManagerRequest::ListSensors { .. } => "list_sensors",
1813            SensorManagerRequest::SetTemperatureOverride { .. } => "set_temperature_override",
1814            SensorManagerRequest::ClearTemperatureOverride { .. } => "clear_temperature_override",
1815            SensorManagerRequest::Connect { .. } => "connect",
1816            SensorManagerRequest::_UnknownMethod {
1817                method_type: fidl::MethodType::OneWay, ..
1818            } => "unknown one-way method",
1819            SensorManagerRequest::_UnknownMethod {
1820                method_type: fidl::MethodType::TwoWay, ..
1821            } => "unknown two-way method",
1822        }
1823    }
1824}
1825
1826#[derive(Debug, Clone)]
1827pub struct SensorManagerControlHandle {
1828    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1829}
1830
1831impl SensorManagerControlHandle {
1832    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1833        self.inner.shutdown_with_epitaph(status.into())
1834    }
1835}
1836
1837impl fidl::endpoints::ControlHandle for SensorManagerControlHandle {
1838    fn shutdown(&self) {
1839        self.inner.shutdown()
1840    }
1841
1842    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1843        self.inner.shutdown_with_epitaph(status)
1844    }
1845
1846    fn is_closed(&self) -> bool {
1847        self.inner.channel().is_closed()
1848    }
1849    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1850        self.inner.channel().on_closed()
1851    }
1852
1853    #[cfg(target_os = "fuchsia")]
1854    fn signal_peer(
1855        &self,
1856        clear_mask: zx::Signals,
1857        set_mask: zx::Signals,
1858    ) -> Result<(), zx_status::Status> {
1859        use fidl::Peered;
1860        self.inner.channel().signal_peer(clear_mask, set_mask)
1861    }
1862}
1863
1864impl SensorManagerControlHandle {}
1865
1866#[must_use = "FIDL methods require a response to be sent"]
1867#[derive(Debug)]
1868pub struct SensorManagerListSensorsResponder {
1869    control_handle: std::mem::ManuallyDrop<SensorManagerControlHandle>,
1870    tx_id: u32,
1871}
1872
1873/// Set the the channel to be shutdown (see [`SensorManagerControlHandle::shutdown`])
1874/// if the responder is dropped without sending a response, so that the client
1875/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1876impl std::ops::Drop for SensorManagerListSensorsResponder {
1877    fn drop(&mut self) {
1878        self.control_handle.shutdown();
1879        // Safety: drops once, never accessed again
1880        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1881    }
1882}
1883
1884impl fidl::endpoints::Responder for SensorManagerListSensorsResponder {
1885    type ControlHandle = SensorManagerControlHandle;
1886
1887    fn control_handle(&self) -> &SensorManagerControlHandle {
1888        &self.control_handle
1889    }
1890
1891    fn drop_without_shutdown(mut self) {
1892        // Safety: drops once, never accessed again due to mem::forget
1893        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1894        // Prevent Drop from running (which would shut down the channel)
1895        std::mem::forget(self);
1896    }
1897}
1898
1899impl SensorManagerListSensorsResponder {
1900    /// Sends a response to the FIDL transaction.
1901    ///
1902    /// Sets the channel to shutdown if an error occurs.
1903    pub fn send(self, mut sensors: &[SensorInfo]) -> Result<(), fidl::Error> {
1904        let _result = self.send_raw(sensors);
1905        if _result.is_err() {
1906            self.control_handle.shutdown();
1907        }
1908        self.drop_without_shutdown();
1909        _result
1910    }
1911
1912    /// Similar to "send" but does not shutdown the channel if an error occurs.
1913    pub fn send_no_shutdown_on_err(self, mut sensors: &[SensorInfo]) -> Result<(), fidl::Error> {
1914        let _result = self.send_raw(sensors);
1915        self.drop_without_shutdown();
1916        _result
1917    }
1918
1919    fn send_raw(&self, mut sensors: &[SensorInfo]) -> Result<(), fidl::Error> {
1920        self.control_handle
1921            .inner
1922            .send::<fidl::encoding::FlexibleType<SensorManagerListSensorsResponse>>(
1923                fidl::encoding::Flexible::new((sensors,)),
1924                self.tx_id,
1925                0x4407236d8bad1a9b,
1926                fidl::encoding::DynamicFlags::FLEXIBLE,
1927            )
1928    }
1929}
1930
1931#[must_use = "FIDL methods require a response to be sent"]
1932#[derive(Debug)]
1933pub struct SensorManagerSetTemperatureOverrideResponder {
1934    control_handle: std::mem::ManuallyDrop<SensorManagerControlHandle>,
1935    tx_id: u32,
1936}
1937
1938/// Set the the channel to be shutdown (see [`SensorManagerControlHandle::shutdown`])
1939/// if the responder is dropped without sending a response, so that the client
1940/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1941impl std::ops::Drop for SensorManagerSetTemperatureOverrideResponder {
1942    fn drop(&mut self) {
1943        self.control_handle.shutdown();
1944        // Safety: drops once, never accessed again
1945        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1946    }
1947}
1948
1949impl fidl::endpoints::Responder for SensorManagerSetTemperatureOverrideResponder {
1950    type ControlHandle = SensorManagerControlHandle;
1951
1952    fn control_handle(&self) -> &SensorManagerControlHandle {
1953        &self.control_handle
1954    }
1955
1956    fn drop_without_shutdown(mut self) {
1957        // Safety: drops once, never accessed again due to mem::forget
1958        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1959        // Prevent Drop from running (which would shut down the channel)
1960        std::mem::forget(self);
1961    }
1962}
1963
1964impl SensorManagerSetTemperatureOverrideResponder {
1965    /// Sends a response to the FIDL transaction.
1966    ///
1967    /// Sets the channel to shutdown if an error occurs.
1968    pub fn send(
1969        self,
1970        mut result: Result<(), SetTemperatureOverrideError>,
1971    ) -> Result<(), fidl::Error> {
1972        let _result = self.send_raw(result);
1973        if _result.is_err() {
1974            self.control_handle.shutdown();
1975        }
1976        self.drop_without_shutdown();
1977        _result
1978    }
1979
1980    /// Similar to "send" but does not shutdown the channel if an error occurs.
1981    pub fn send_no_shutdown_on_err(
1982        self,
1983        mut result: Result<(), SetTemperatureOverrideError>,
1984    ) -> Result<(), fidl::Error> {
1985        let _result = self.send_raw(result);
1986        self.drop_without_shutdown();
1987        _result
1988    }
1989
1990    fn send_raw(
1991        &self,
1992        mut result: Result<(), SetTemperatureOverrideError>,
1993    ) -> Result<(), fidl::Error> {
1994        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1995            fidl::encoding::EmptyStruct,
1996            SetTemperatureOverrideError,
1997        >>(
1998            fidl::encoding::FlexibleResult::new(result),
1999            self.tx_id,
2000            0x13abb6faff00a238,
2001            fidl::encoding::DynamicFlags::FLEXIBLE,
2002        )
2003    }
2004}
2005
2006#[must_use = "FIDL methods require a response to be sent"]
2007#[derive(Debug)]
2008pub struct SensorManagerClearTemperatureOverrideResponder {
2009    control_handle: std::mem::ManuallyDrop<SensorManagerControlHandle>,
2010    tx_id: u32,
2011}
2012
2013/// Set the the channel to be shutdown (see [`SensorManagerControlHandle::shutdown`])
2014/// if the responder is dropped without sending a response, so that the client
2015/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2016impl std::ops::Drop for SensorManagerClearTemperatureOverrideResponder {
2017    fn drop(&mut self) {
2018        self.control_handle.shutdown();
2019        // Safety: drops once, never accessed again
2020        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2021    }
2022}
2023
2024impl fidl::endpoints::Responder for SensorManagerClearTemperatureOverrideResponder {
2025    type ControlHandle = SensorManagerControlHandle;
2026
2027    fn control_handle(&self) -> &SensorManagerControlHandle {
2028        &self.control_handle
2029    }
2030
2031    fn drop_without_shutdown(mut self) {
2032        // Safety: drops once, never accessed again due to mem::forget
2033        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2034        // Prevent Drop from running (which would shut down the channel)
2035        std::mem::forget(self);
2036    }
2037}
2038
2039impl SensorManagerClearTemperatureOverrideResponder {
2040    /// Sends a response to the FIDL transaction.
2041    ///
2042    /// Sets the channel to shutdown if an error occurs.
2043    pub fn send(
2044        self,
2045        mut result: Result<(), ClearTemperatureOverrideError>,
2046    ) -> Result<(), fidl::Error> {
2047        let _result = self.send_raw(result);
2048        if _result.is_err() {
2049            self.control_handle.shutdown();
2050        }
2051        self.drop_without_shutdown();
2052        _result
2053    }
2054
2055    /// Similar to "send" but does not shutdown the channel if an error occurs.
2056    pub fn send_no_shutdown_on_err(
2057        self,
2058        mut result: Result<(), ClearTemperatureOverrideError>,
2059    ) -> Result<(), fidl::Error> {
2060        let _result = self.send_raw(result);
2061        self.drop_without_shutdown();
2062        _result
2063    }
2064
2065    fn send_raw(
2066        &self,
2067        mut result: Result<(), ClearTemperatureOverrideError>,
2068    ) -> Result<(), fidl::Error> {
2069        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2070            fidl::encoding::EmptyStruct,
2071            ClearTemperatureOverrideError,
2072        >>(
2073            fidl::encoding::FlexibleResult::new(result),
2074            self.tx_id,
2075            0x3ad5b3a009f687cb,
2076            fidl::encoding::DynamicFlags::FLEXIBLE,
2077        )
2078    }
2079}
2080
2081#[must_use = "FIDL methods require a response to be sent"]
2082#[derive(Debug)]
2083pub struct SensorManagerConnectResponder {
2084    control_handle: std::mem::ManuallyDrop<SensorManagerControlHandle>,
2085    tx_id: u32,
2086}
2087
2088/// Set the the channel to be shutdown (see [`SensorManagerControlHandle::shutdown`])
2089/// if the responder is dropped without sending a response, so that the client
2090/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2091impl std::ops::Drop for SensorManagerConnectResponder {
2092    fn drop(&mut self) {
2093        self.control_handle.shutdown();
2094        // Safety: drops once, never accessed again
2095        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2096    }
2097}
2098
2099impl fidl::endpoints::Responder for SensorManagerConnectResponder {
2100    type ControlHandle = SensorManagerControlHandle;
2101
2102    fn control_handle(&self) -> &SensorManagerControlHandle {
2103        &self.control_handle
2104    }
2105
2106    fn drop_without_shutdown(mut self) {
2107        // Safety: drops once, never accessed again due to mem::forget
2108        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2109        // Prevent Drop from running (which would shut down the channel)
2110        std::mem::forget(self);
2111    }
2112}
2113
2114impl SensorManagerConnectResponder {
2115    /// Sends a response to the FIDL transaction.
2116    ///
2117    /// Sets the channel to shutdown if an error occurs.
2118    pub fn send(self, mut result: Result<(), ConnectError>) -> Result<(), fidl::Error> {
2119        let _result = self.send_raw(result);
2120        if _result.is_err() {
2121            self.control_handle.shutdown();
2122        }
2123        self.drop_without_shutdown();
2124        _result
2125    }
2126
2127    /// Similar to "send" but does not shutdown the channel if an error occurs.
2128    pub fn send_no_shutdown_on_err(
2129        self,
2130        mut result: Result<(), ConnectError>,
2131    ) -> Result<(), fidl::Error> {
2132        let _result = self.send_raw(result);
2133        self.drop_without_shutdown();
2134        _result
2135    }
2136
2137    fn send_raw(&self, mut result: Result<(), ConnectError>) -> Result<(), fidl::Error> {
2138        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2139            fidl::encoding::EmptyStruct,
2140            ConnectError,
2141        >>(
2142            fidl::encoding::FlexibleResult::new(result),
2143            self.tx_id,
2144            0x76abcbb8819f26bf,
2145            fidl::encoding::DynamicFlags::FLEXIBLE,
2146        )
2147    }
2148}
2149
2150mod internal {
2151    use super::*;
2152
2153    impl fidl::encoding::ResourceTypeMarker for ClientStateConnectorConnectRequest {
2154        type Borrowed<'a> = &'a mut Self;
2155        fn take_or_borrow<'a>(
2156            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2157        ) -> Self::Borrowed<'a> {
2158            value
2159        }
2160    }
2161
2162    unsafe impl fidl::encoding::TypeMarker for ClientStateConnectorConnectRequest {
2163        type Owned = Self;
2164
2165        #[inline(always)]
2166        fn inline_align(_context: fidl::encoding::Context) -> usize {
2167            8
2168        }
2169
2170        #[inline(always)]
2171        fn inline_size(_context: fidl::encoding::Context) -> usize {
2172            24
2173        }
2174    }
2175
2176    unsafe impl
2177        fidl::encoding::Encode<
2178            ClientStateConnectorConnectRequest,
2179            fidl::encoding::DefaultFuchsiaResourceDialect,
2180        > for &mut ClientStateConnectorConnectRequest
2181    {
2182        #[inline]
2183        unsafe fn encode(
2184            self,
2185            encoder: &mut fidl::encoding::Encoder<
2186                '_,
2187                fidl::encoding::DefaultFuchsiaResourceDialect,
2188            >,
2189            offset: usize,
2190            _depth: fidl::encoding::Depth,
2191        ) -> fidl::Result<()> {
2192            encoder.debug_check_bounds::<ClientStateConnectorConnectRequest>(offset);
2193            // Delegate to tuple encoding.
2194            fidl::encoding::Encode::<ClientStateConnectorConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2195                (
2196                    <fidl::encoding::BoundedString<8> as fidl::encoding::ValueTypeMarker>::borrow(&self.client_type),
2197                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ClientStateWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
2198                ),
2199                encoder, offset, _depth
2200            )
2201        }
2202    }
2203    unsafe impl<
2204        T0: fidl::encoding::Encode<
2205                fidl::encoding::BoundedString<8>,
2206                fidl::encoding::DefaultFuchsiaResourceDialect,
2207            >,
2208        T1: fidl::encoding::Encode<
2209                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ClientStateWatcherMarker>>,
2210                fidl::encoding::DefaultFuchsiaResourceDialect,
2211            >,
2212    >
2213        fidl::encoding::Encode<
2214            ClientStateConnectorConnectRequest,
2215            fidl::encoding::DefaultFuchsiaResourceDialect,
2216        > for (T0, T1)
2217    {
2218        #[inline]
2219        unsafe fn encode(
2220            self,
2221            encoder: &mut fidl::encoding::Encoder<
2222                '_,
2223                fidl::encoding::DefaultFuchsiaResourceDialect,
2224            >,
2225            offset: usize,
2226            depth: fidl::encoding::Depth,
2227        ) -> fidl::Result<()> {
2228            encoder.debug_check_bounds::<ClientStateConnectorConnectRequest>(offset);
2229            // Zero out padding regions. There's no need to apply masks
2230            // because the unmasked parts will be overwritten by fields.
2231            unsafe {
2232                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2233                (ptr as *mut u64).write_unaligned(0);
2234            }
2235            // Write the fields.
2236            self.0.encode(encoder, offset + 0, depth)?;
2237            self.1.encode(encoder, offset + 16, depth)?;
2238            Ok(())
2239        }
2240    }
2241
2242    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2243        for ClientStateConnectorConnectRequest
2244    {
2245        #[inline(always)]
2246        fn new_empty() -> Self {
2247            Self {
2248                client_type: fidl::new_empty!(
2249                    fidl::encoding::BoundedString<8>,
2250                    fidl::encoding::DefaultFuchsiaResourceDialect
2251                ),
2252                watcher: fidl::new_empty!(
2253                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ClientStateWatcherMarker>>,
2254                    fidl::encoding::DefaultFuchsiaResourceDialect
2255                ),
2256            }
2257        }
2258
2259        #[inline]
2260        unsafe fn decode(
2261            &mut self,
2262            decoder: &mut fidl::encoding::Decoder<
2263                '_,
2264                fidl::encoding::DefaultFuchsiaResourceDialect,
2265            >,
2266            offset: usize,
2267            _depth: fidl::encoding::Depth,
2268        ) -> fidl::Result<()> {
2269            decoder.debug_check_bounds::<Self>(offset);
2270            // Verify that padding bytes are zero.
2271            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2272            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2273            let mask = 0xffffffff00000000u64;
2274            let maskedval = padval & mask;
2275            if maskedval != 0 {
2276                return Err(fidl::Error::NonZeroPadding {
2277                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2278                });
2279            }
2280            fidl::decode!(
2281                fidl::encoding::BoundedString<8>,
2282                fidl::encoding::DefaultFuchsiaResourceDialect,
2283                &mut self.client_type,
2284                decoder,
2285                offset + 0,
2286                _depth
2287            )?;
2288            fidl::decode!(
2289                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ClientStateWatcherMarker>>,
2290                fidl::encoding::DefaultFuchsiaResourceDialect,
2291                &mut self.watcher,
2292                decoder,
2293                offset + 16,
2294                _depth
2295            )?;
2296            Ok(())
2297        }
2298    }
2299
2300    impl SensorManagerConnectRequest {
2301        #[inline(always)]
2302        fn max_ordinal_present(&self) -> u64 {
2303            if let Some(_) = self.server_end {
2304                return 2;
2305            }
2306            if let Some(_) = self.name {
2307                return 1;
2308            }
2309            0
2310        }
2311    }
2312
2313    impl fidl::encoding::ResourceTypeMarker for SensorManagerConnectRequest {
2314        type Borrowed<'a> = &'a mut Self;
2315        fn take_or_borrow<'a>(
2316            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2317        ) -> Self::Borrowed<'a> {
2318            value
2319        }
2320    }
2321
2322    unsafe impl fidl::encoding::TypeMarker for SensorManagerConnectRequest {
2323        type Owned = Self;
2324
2325        #[inline(always)]
2326        fn inline_align(_context: fidl::encoding::Context) -> usize {
2327            8
2328        }
2329
2330        #[inline(always)]
2331        fn inline_size(_context: fidl::encoding::Context) -> usize {
2332            16
2333        }
2334    }
2335
2336    unsafe impl
2337        fidl::encoding::Encode<
2338            SensorManagerConnectRequest,
2339            fidl::encoding::DefaultFuchsiaResourceDialect,
2340        > for &mut SensorManagerConnectRequest
2341    {
2342        unsafe fn encode(
2343            self,
2344            encoder: &mut fidl::encoding::Encoder<
2345                '_,
2346                fidl::encoding::DefaultFuchsiaResourceDialect,
2347            >,
2348            offset: usize,
2349            mut depth: fidl::encoding::Depth,
2350        ) -> fidl::Result<()> {
2351            encoder.debug_check_bounds::<SensorManagerConnectRequest>(offset);
2352            // Vector header
2353            let max_ordinal: u64 = self.max_ordinal_present();
2354            encoder.write_num(max_ordinal, offset);
2355            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2356            // Calling encoder.out_of_line_offset(0) is not allowed.
2357            if max_ordinal == 0 {
2358                return Ok(());
2359            }
2360            depth.increment()?;
2361            let envelope_size = 8;
2362            let bytes_len = max_ordinal as usize * envelope_size;
2363            #[allow(unused_variables)]
2364            let offset = encoder.out_of_line_offset(bytes_len);
2365            let mut _prev_end_offset: usize = 0;
2366            if 1 > max_ordinal {
2367                return Ok(());
2368            }
2369
2370            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2371            // are envelope_size bytes.
2372            let cur_offset: usize = (1 - 1) * envelope_size;
2373
2374            // Zero reserved fields.
2375            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2376
2377            // Safety:
2378            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2379            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2380            //   envelope_size bytes, there is always sufficient room.
2381            fidl::encoding::encode_in_envelope_optional::<
2382                fidl::encoding::BoundedString<256>,
2383                fidl::encoding::DefaultFuchsiaResourceDialect,
2384            >(
2385                self.name.as_ref().map(
2386                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
2387                ),
2388                encoder,
2389                offset + cur_offset,
2390                depth,
2391            )?;
2392
2393            _prev_end_offset = cur_offset + envelope_size;
2394            if 2 > max_ordinal {
2395                return Ok(());
2396            }
2397
2398            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2399            // are envelope_size bytes.
2400            let cur_offset: usize = (2 - 1) * envelope_size;
2401
2402            // Zero reserved fields.
2403            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2404
2405            // Safety:
2406            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2407            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2408            //   envelope_size bytes, there is always sufficient room.
2409            fidl::encoding::encode_in_envelope_optional::<
2410                SensorServer_,
2411                fidl::encoding::DefaultFuchsiaResourceDialect,
2412            >(
2413                self.server_end
2414                    .as_mut()
2415                    .map(<SensorServer_ as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
2416                encoder,
2417                offset + cur_offset,
2418                depth,
2419            )?;
2420
2421            _prev_end_offset = cur_offset + envelope_size;
2422
2423            Ok(())
2424        }
2425    }
2426
2427    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2428        for SensorManagerConnectRequest
2429    {
2430        #[inline(always)]
2431        fn new_empty() -> Self {
2432            Self::default()
2433        }
2434
2435        unsafe fn decode(
2436            &mut self,
2437            decoder: &mut fidl::encoding::Decoder<
2438                '_,
2439                fidl::encoding::DefaultFuchsiaResourceDialect,
2440            >,
2441            offset: usize,
2442            mut depth: fidl::encoding::Depth,
2443        ) -> fidl::Result<()> {
2444            decoder.debug_check_bounds::<Self>(offset);
2445            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2446                None => return Err(fidl::Error::NotNullable),
2447                Some(len) => len,
2448            };
2449            // Calling decoder.out_of_line_offset(0) is not allowed.
2450            if len == 0 {
2451                return Ok(());
2452            };
2453            depth.increment()?;
2454            let envelope_size = 8;
2455            let bytes_len = len * envelope_size;
2456            let offset = decoder.out_of_line_offset(bytes_len)?;
2457            // Decode the envelope for each type.
2458            let mut _next_ordinal_to_read = 0;
2459            let mut next_offset = offset;
2460            let end_offset = offset + bytes_len;
2461            _next_ordinal_to_read += 1;
2462            if next_offset >= end_offset {
2463                return Ok(());
2464            }
2465
2466            // Decode unknown envelopes for gaps in ordinals.
2467            while _next_ordinal_to_read < 1 {
2468                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2469                _next_ordinal_to_read += 1;
2470                next_offset += envelope_size;
2471            }
2472
2473            let next_out_of_line = decoder.next_out_of_line();
2474            let handles_before = decoder.remaining_handles();
2475            if let Some((inlined, num_bytes, num_handles)) =
2476                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2477            {
2478                let member_inline_size =
2479                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
2480                        decoder.context,
2481                    );
2482                if inlined != (member_inline_size <= 4) {
2483                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2484                }
2485                let inner_offset;
2486                let mut inner_depth = depth.clone();
2487                if inlined {
2488                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2489                    inner_offset = next_offset;
2490                } else {
2491                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2492                    inner_depth.increment()?;
2493                }
2494                let val_ref = self.name.get_or_insert_with(|| {
2495                    fidl::new_empty!(
2496                        fidl::encoding::BoundedString<256>,
2497                        fidl::encoding::DefaultFuchsiaResourceDialect
2498                    )
2499                });
2500                fidl::decode!(
2501                    fidl::encoding::BoundedString<256>,
2502                    fidl::encoding::DefaultFuchsiaResourceDialect,
2503                    val_ref,
2504                    decoder,
2505                    inner_offset,
2506                    inner_depth
2507                )?;
2508                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2509                {
2510                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2511                }
2512                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2513                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2514                }
2515            }
2516
2517            next_offset += envelope_size;
2518            _next_ordinal_to_read += 1;
2519            if next_offset >= end_offset {
2520                return Ok(());
2521            }
2522
2523            // Decode unknown envelopes for gaps in ordinals.
2524            while _next_ordinal_to_read < 2 {
2525                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2526                _next_ordinal_to_read += 1;
2527                next_offset += envelope_size;
2528            }
2529
2530            let next_out_of_line = decoder.next_out_of_line();
2531            let handles_before = decoder.remaining_handles();
2532            if let Some((inlined, num_bytes, num_handles)) =
2533                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2534            {
2535                let member_inline_size =
2536                    <SensorServer_ as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2537                if inlined != (member_inline_size <= 4) {
2538                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2539                }
2540                let inner_offset;
2541                let mut inner_depth = depth.clone();
2542                if inlined {
2543                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2544                    inner_offset = next_offset;
2545                } else {
2546                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2547                    inner_depth.increment()?;
2548                }
2549                let val_ref = self.server_end.get_or_insert_with(|| {
2550                    fidl::new_empty!(SensorServer_, fidl::encoding::DefaultFuchsiaResourceDialect)
2551                });
2552                fidl::decode!(
2553                    SensorServer_,
2554                    fidl::encoding::DefaultFuchsiaResourceDialect,
2555                    val_ref,
2556                    decoder,
2557                    inner_offset,
2558                    inner_depth
2559                )?;
2560                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2561                {
2562                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2563                }
2564                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2565                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2566                }
2567            }
2568
2569            next_offset += envelope_size;
2570
2571            // Decode the remaining unknown envelopes.
2572            while next_offset < end_offset {
2573                _next_ordinal_to_read += 1;
2574                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2575                next_offset += envelope_size;
2576            }
2577
2578            Ok(())
2579        }
2580    }
2581
2582    impl fidl::encoding::ResourceTypeMarker for SensorServer_ {
2583        type Borrowed<'a> = &'a mut Self;
2584        fn take_or_borrow<'a>(
2585            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2586        ) -> Self::Borrowed<'a> {
2587            value
2588        }
2589    }
2590
2591    unsafe impl fidl::encoding::TypeMarker for SensorServer_ {
2592        type Owned = Self;
2593
2594        #[inline(always)]
2595        fn inline_align(_context: fidl::encoding::Context) -> usize {
2596            8
2597        }
2598
2599        #[inline(always)]
2600        fn inline_size(_context: fidl::encoding::Context) -> usize {
2601            16
2602        }
2603    }
2604
2605    unsafe impl fidl::encoding::Encode<SensorServer_, fidl::encoding::DefaultFuchsiaResourceDialect>
2606        for &mut SensorServer_
2607    {
2608        #[inline]
2609        unsafe fn encode(
2610            self,
2611            encoder: &mut fidl::encoding::Encoder<
2612                '_,
2613                fidl::encoding::DefaultFuchsiaResourceDialect,
2614            >,
2615            offset: usize,
2616            _depth: fidl::encoding::Depth,
2617        ) -> fidl::Result<()> {
2618            encoder.debug_check_bounds::<SensorServer_>(offset);
2619            encoder.write_num::<u64>(self.ordinal(), offset);
2620            match self {
2621                SensorServer_::Temperature(ref mut val) => fidl::encoding::encode_in_envelope::<
2622                    fidl::encoding::Endpoint<
2623                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_temperature::DeviceMarker>,
2624                    >,
2625                    fidl::encoding::DefaultFuchsiaResourceDialect,
2626                >(
2627                    <fidl::encoding::Endpoint<
2628                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_temperature::DeviceMarker>,
2629                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2630                        val
2631                    ),
2632                    encoder,
2633                    offset + 8,
2634                    _depth,
2635                ),
2636                SensorServer_::Trippoint(ref mut val) => fidl::encoding::encode_in_envelope::<
2637                    fidl::encoding::Endpoint<
2638                        fidl::endpoints::ServerEnd<
2639                            fidl_fuchsia_hardware_trippoint::TripPointMarker,
2640                        >,
2641                    >,
2642                    fidl::encoding::DefaultFuchsiaResourceDialect,
2643                >(
2644                    <fidl::encoding::Endpoint<
2645                        fidl::endpoints::ServerEnd<
2646                            fidl_fuchsia_hardware_trippoint::TripPointMarker,
2647                        >,
2648                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2649                        val
2650                    ),
2651                    encoder,
2652                    offset + 8,
2653                    _depth,
2654                ),
2655                SensorServer_::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2656            }
2657        }
2658    }
2659
2660    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for SensorServer_ {
2661        #[inline(always)]
2662        fn new_empty() -> Self {
2663            Self::__SourceBreaking { unknown_ordinal: 0 }
2664        }
2665
2666        #[inline]
2667        unsafe fn decode(
2668            &mut self,
2669            decoder: &mut fidl::encoding::Decoder<
2670                '_,
2671                fidl::encoding::DefaultFuchsiaResourceDialect,
2672            >,
2673            offset: usize,
2674            mut depth: fidl::encoding::Depth,
2675        ) -> fidl::Result<()> {
2676            decoder.debug_check_bounds::<Self>(offset);
2677            #[allow(unused_variables)]
2678            let next_out_of_line = decoder.next_out_of_line();
2679            let handles_before = decoder.remaining_handles();
2680            let (ordinal, inlined, num_bytes, num_handles) =
2681                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2682
2683            let member_inline_size = match ordinal {
2684                1 => <fidl::encoding::Endpoint<
2685                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_temperature::DeviceMarker>,
2686                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2687                2 => <fidl::encoding::Endpoint<
2688                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_trippoint::TripPointMarker>,
2689                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2690                0 => return Err(fidl::Error::UnknownUnionTag),
2691                _ => num_bytes as usize,
2692            };
2693
2694            if inlined != (member_inline_size <= 4) {
2695                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2696            }
2697            let _inner_offset;
2698            if inlined {
2699                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2700                _inner_offset = offset + 8;
2701            } else {
2702                depth.increment()?;
2703                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2704            }
2705            match ordinal {
2706                1 => {
2707                    #[allow(irrefutable_let_patterns)]
2708                    if let SensorServer_::Temperature(_) = self {
2709                        // Do nothing, read the value into the object
2710                    } else {
2711                        // Initialize `self` to the right variant
2712                        *self = SensorServer_::Temperature(fidl::new_empty!(
2713                            fidl::encoding::Endpoint<
2714                                fidl::endpoints::ServerEnd<
2715                                    fidl_fuchsia_hardware_temperature::DeviceMarker,
2716                                >,
2717                            >,
2718                            fidl::encoding::DefaultFuchsiaResourceDialect
2719                        ));
2720                    }
2721                    #[allow(irrefutable_let_patterns)]
2722                    if let SensorServer_::Temperature(ref mut val) = self {
2723                        fidl::decode!(
2724                            fidl::encoding::Endpoint<
2725                                fidl::endpoints::ServerEnd<
2726                                    fidl_fuchsia_hardware_temperature::DeviceMarker,
2727                                >,
2728                            >,
2729                            fidl::encoding::DefaultFuchsiaResourceDialect,
2730                            val,
2731                            decoder,
2732                            _inner_offset,
2733                            depth
2734                        )?;
2735                    } else {
2736                        unreachable!()
2737                    }
2738                }
2739                2 => {
2740                    #[allow(irrefutable_let_patterns)]
2741                    if let SensorServer_::Trippoint(_) = self {
2742                        // Do nothing, read the value into the object
2743                    } else {
2744                        // Initialize `self` to the right variant
2745                        *self = SensorServer_::Trippoint(fidl::new_empty!(
2746                            fidl::encoding::Endpoint<
2747                                fidl::endpoints::ServerEnd<
2748                                    fidl_fuchsia_hardware_trippoint::TripPointMarker,
2749                                >,
2750                            >,
2751                            fidl::encoding::DefaultFuchsiaResourceDialect
2752                        ));
2753                    }
2754                    #[allow(irrefutable_let_patterns)]
2755                    if let SensorServer_::Trippoint(ref mut val) = self {
2756                        fidl::decode!(
2757                            fidl::encoding::Endpoint<
2758                                fidl::endpoints::ServerEnd<
2759                                    fidl_fuchsia_hardware_trippoint::TripPointMarker,
2760                                >,
2761                            >,
2762                            fidl::encoding::DefaultFuchsiaResourceDialect,
2763                            val,
2764                            decoder,
2765                            _inner_offset,
2766                            depth
2767                        )?;
2768                    } else {
2769                        unreachable!()
2770                    }
2771                }
2772                #[allow(deprecated)]
2773                ordinal => {
2774                    for _ in 0..num_handles {
2775                        decoder.drop_next_handle()?;
2776                    }
2777                    *self = SensorServer_::__SourceBreaking { unknown_ordinal: ordinal };
2778                }
2779            }
2780            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2781                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2782            }
2783            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2784                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2785            }
2786            Ok(())
2787        }
2788    }
2789}