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