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