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