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