Skip to main content

fidl_fuchsia_hardware_fan/
fidl_fuchsia_hardware_fan.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_hardware_fan_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DeviceMarker;
16
17impl fidl::endpoints::ProtocolMarker for DeviceMarker {
18    type Proxy = DeviceProxy;
19    type RequestStream = DeviceRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = DeviceSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.hardware.fan.Device";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
26
27pub trait DeviceProxyInterface: Send + Sync {
28    type GetFanLevelResponseFut: std::future::Future<Output = Result<(i32, u32), fidl::Error>>
29        + Send;
30    fn r#get_fan_level(&self) -> Self::GetFanLevelResponseFut;
31    type SetFanLevelResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
32    fn r#set_fan_level(&self, fan_level: u32) -> Self::SetFanLevelResponseFut;
33    type GetClientTypeResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
34    fn r#get_client_type(&self) -> Self::GetClientTypeResponseFut;
35}
36#[derive(Debug)]
37#[cfg(target_os = "fuchsia")]
38pub struct DeviceSynchronousProxy {
39    client: fidl::client::sync::Client,
40}
41
42#[cfg(target_os = "fuchsia")]
43impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
44    type Proxy = DeviceProxy;
45    type Protocol = DeviceMarker;
46
47    fn from_channel(inner: fidl::Channel) -> Self {
48        Self::new(inner)
49    }
50
51    fn into_channel(self) -> fidl::Channel {
52        self.client.into_channel()
53    }
54
55    fn as_channel(&self) -> &fidl::Channel {
56        self.client.as_channel()
57    }
58}
59
60#[cfg(target_os = "fuchsia")]
61impl DeviceSynchronousProxy {
62    pub fn new(channel: fidl::Channel) -> Self {
63        Self { client: fidl::client::sync::Client::new(channel) }
64    }
65
66    pub fn into_channel(self) -> fidl::Channel {
67        self.client.into_channel()
68    }
69
70    /// Waits until an event arrives and returns it. It is safe for other
71    /// threads to make concurrent requests while waiting for an event.
72    pub fn wait_for_event(
73        &self,
74        deadline: zx::MonotonicInstant,
75    ) -> Result<DeviceEvent, fidl::Error> {
76        DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
77    }
78
79    /// Get the current fan level.
80    /// - response `status`
81    ///      ZX_ERR_INTERNAL if `fan_level` is not available.
82    ///        This generally means that `fan_level` has not
83    ///        been initialized yet or something has gone
84    ///        terribly wrong.
85    /// - response `fan_level` a uint32 field indicating the
86    ///      current fan level. See fan level description above.
87    pub fn r#get_fan_level(
88        &self,
89        ___deadline: zx::MonotonicInstant,
90    ) -> Result<(i32, u32), fidl::Error> {
91        let _response = self
92            .client
93            .send_query::<fidl::encoding::EmptyPayload, FanGetFanLevelResponse, DeviceMarker>(
94                (),
95                0x63439dc551ef6dea,
96                fidl::encoding::DynamicFlags::empty(),
97                ___deadline,
98            )?;
99        Ok((_response.status, _response.fan_level))
100    }
101
102    /// Set the fan level.
103    /// + request `fan_level` a uint32 field indicating the
104    ///      requested fan level. See fan level description above.
105    /// - response `status`
106    ///      ZX_ERR_OUT_OF_RANGE if the requested fan_level is not
107    ///        valid.
108    pub fn r#set_fan_level(
109        &self,
110        mut fan_level: u32,
111        ___deadline: zx::MonotonicInstant,
112    ) -> Result<i32, fidl::Error> {
113        let _response =
114            self.client.send_query::<FanSetFanLevelRequest, FanSetFanLevelResponse, DeviceMarker>(
115                (fan_level,),
116                0x6552ae76e9703ffb,
117                fidl::encoding::DynamicFlags::empty(),
118                ___deadline,
119            )?;
120        Ok(_response.status)
121    }
122
123    /// Returns the client type to use for
124    ///    `fuchsia.thermal.ClientStateConnector::Connect`.
125    pub fn r#get_client_type(
126        &self,
127        ___deadline: zx::MonotonicInstant,
128    ) -> Result<String, fidl::Error> {
129        let _response = self
130            .client
131            .send_query::<fidl::encoding::EmptyPayload, DeviceGetClientTypeResponse, DeviceMarker>(
132                (),
133                0x186bc9e14d6c5596,
134                fidl::encoding::DynamicFlags::empty(),
135                ___deadline,
136            )?;
137        Ok(_response.client_type)
138    }
139}
140
141#[cfg(target_os = "fuchsia")]
142impl From<DeviceSynchronousProxy> for zx::NullableHandle {
143    fn from(value: DeviceSynchronousProxy) -> Self {
144        value.into_channel().into()
145    }
146}
147
148#[cfg(target_os = "fuchsia")]
149impl From<fidl::Channel> for DeviceSynchronousProxy {
150    fn from(value: fidl::Channel) -> Self {
151        Self::new(value)
152    }
153}
154
155#[cfg(target_os = "fuchsia")]
156impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
157    type Protocol = DeviceMarker;
158
159    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
160        Self::new(value.into_channel())
161    }
162}
163
164#[derive(Debug, Clone)]
165pub struct DeviceProxy {
166    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
167}
168
169impl fidl::endpoints::Proxy for DeviceProxy {
170    type Protocol = DeviceMarker;
171
172    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
173        Self::new(inner)
174    }
175
176    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
177        self.client.into_channel().map_err(|client| Self { client })
178    }
179
180    fn as_channel(&self) -> &::fidl::AsyncChannel {
181        self.client.as_channel()
182    }
183}
184
185impl DeviceProxy {
186    /// Create a new Proxy for fuchsia.hardware.fan/Device.
187    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
188        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
189        Self { client: fidl::client::Client::new(channel, protocol_name) }
190    }
191
192    /// Get a Stream of events from the remote end of the protocol.
193    ///
194    /// # Panics
195    ///
196    /// Panics if the event stream was already taken.
197    pub fn take_event_stream(&self) -> DeviceEventStream {
198        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
199    }
200
201    /// Get the current fan level.
202    /// - response `status`
203    ///      ZX_ERR_INTERNAL if `fan_level` is not available.
204    ///        This generally means that `fan_level` has not
205    ///        been initialized yet or something has gone
206    ///        terribly wrong.
207    /// - response `fan_level` a uint32 field indicating the
208    ///      current fan level. See fan level description above.
209    pub fn r#get_fan_level(
210        &self,
211    ) -> fidl::client::QueryResponseFut<(i32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>
212    {
213        DeviceProxyInterface::r#get_fan_level(self)
214    }
215
216    /// Set the fan level.
217    /// + request `fan_level` a uint32 field indicating the
218    ///      requested fan level. See fan level description above.
219    /// - response `status`
220    ///      ZX_ERR_OUT_OF_RANGE if the requested fan_level is not
221    ///        valid.
222    pub fn r#set_fan_level(
223        &self,
224        mut fan_level: u32,
225    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
226        DeviceProxyInterface::r#set_fan_level(self, fan_level)
227    }
228
229    /// Returns the client type to use for
230    ///    `fuchsia.thermal.ClientStateConnector::Connect`.
231    pub fn r#get_client_type(
232        &self,
233    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
234        DeviceProxyInterface::r#get_client_type(self)
235    }
236}
237
238impl DeviceProxyInterface for DeviceProxy {
239    type GetFanLevelResponseFut =
240        fidl::client::QueryResponseFut<(i32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>;
241    fn r#get_fan_level(&self) -> Self::GetFanLevelResponseFut {
242        fn _decode(
243            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
244        ) -> Result<(i32, u32), fidl::Error> {
245            let _response = fidl::client::decode_transaction_body::<
246                FanGetFanLevelResponse,
247                fidl::encoding::DefaultFuchsiaResourceDialect,
248                0x63439dc551ef6dea,
249            >(_buf?)?;
250            Ok((_response.status, _response.fan_level))
251        }
252        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, u32)>(
253            (),
254            0x63439dc551ef6dea,
255            fidl::encoding::DynamicFlags::empty(),
256            _decode,
257        )
258    }
259
260    type SetFanLevelResponseFut =
261        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
262    fn r#set_fan_level(&self, mut fan_level: u32) -> Self::SetFanLevelResponseFut {
263        fn _decode(
264            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
265        ) -> Result<i32, fidl::Error> {
266            let _response = fidl::client::decode_transaction_body::<
267                FanSetFanLevelResponse,
268                fidl::encoding::DefaultFuchsiaResourceDialect,
269                0x6552ae76e9703ffb,
270            >(_buf?)?;
271            Ok(_response.status)
272        }
273        self.client.send_query_and_decode::<FanSetFanLevelRequest, i32>(
274            (fan_level,),
275            0x6552ae76e9703ffb,
276            fidl::encoding::DynamicFlags::empty(),
277            _decode,
278        )
279    }
280
281    type GetClientTypeResponseFut =
282        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
283    fn r#get_client_type(&self) -> Self::GetClientTypeResponseFut {
284        fn _decode(
285            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
286        ) -> Result<String, fidl::Error> {
287            let _response = fidl::client::decode_transaction_body::<
288                DeviceGetClientTypeResponse,
289                fidl::encoding::DefaultFuchsiaResourceDialect,
290                0x186bc9e14d6c5596,
291            >(_buf?)?;
292            Ok(_response.client_type)
293        }
294        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
295            (),
296            0x186bc9e14d6c5596,
297            fidl::encoding::DynamicFlags::empty(),
298            _decode,
299        )
300    }
301}
302
303pub struct DeviceEventStream {
304    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
305}
306
307impl std::marker::Unpin for DeviceEventStream {}
308
309impl futures::stream::FusedStream for DeviceEventStream {
310    fn is_terminated(&self) -> bool {
311        self.event_receiver.is_terminated()
312    }
313}
314
315impl futures::Stream for DeviceEventStream {
316    type Item = Result<DeviceEvent, fidl::Error>;
317
318    fn poll_next(
319        mut self: std::pin::Pin<&mut Self>,
320        cx: &mut std::task::Context<'_>,
321    ) -> std::task::Poll<Option<Self::Item>> {
322        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
323            &mut self.event_receiver,
324            cx
325        )?) {
326            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
327            None => std::task::Poll::Ready(None),
328        }
329    }
330}
331
332#[derive(Debug)]
333pub enum DeviceEvent {}
334
335impl DeviceEvent {
336    /// Decodes a message buffer as a [`DeviceEvent`].
337    fn decode(
338        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
339    ) -> Result<DeviceEvent, fidl::Error> {
340        let (bytes, _handles) = buf.split_mut();
341        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
342        debug_assert_eq!(tx_header.tx_id, 0);
343        match tx_header.ordinal {
344            _ => Err(fidl::Error::UnknownOrdinal {
345                ordinal: tx_header.ordinal,
346                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
347            }),
348        }
349    }
350}
351
352/// A Stream of incoming requests for fuchsia.hardware.fan/Device.
353pub struct DeviceRequestStream {
354    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
355    is_terminated: bool,
356}
357
358impl std::marker::Unpin for DeviceRequestStream {}
359
360impl futures::stream::FusedStream for DeviceRequestStream {
361    fn is_terminated(&self) -> bool {
362        self.is_terminated
363    }
364}
365
366impl fidl::endpoints::RequestStream for DeviceRequestStream {
367    type Protocol = DeviceMarker;
368    type ControlHandle = DeviceControlHandle;
369
370    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
371        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
372    }
373
374    fn control_handle(&self) -> Self::ControlHandle {
375        DeviceControlHandle { inner: self.inner.clone() }
376    }
377
378    fn into_inner(
379        self,
380    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
381    {
382        (self.inner, self.is_terminated)
383    }
384
385    fn from_inner(
386        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
387        is_terminated: bool,
388    ) -> Self {
389        Self { inner, is_terminated }
390    }
391}
392
393impl futures::Stream for DeviceRequestStream {
394    type Item = Result<DeviceRequest, fidl::Error>;
395
396    fn poll_next(
397        mut self: std::pin::Pin<&mut Self>,
398        cx: &mut std::task::Context<'_>,
399    ) -> std::task::Poll<Option<Self::Item>> {
400        let this = &mut *self;
401        if this.inner.check_shutdown(cx) {
402            this.is_terminated = true;
403            return std::task::Poll::Ready(None);
404        }
405        if this.is_terminated {
406            panic!("polled DeviceRequestStream after completion");
407        }
408        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
409            |bytes, handles| {
410                match this.inner.channel().read_etc(cx, bytes, handles) {
411                    std::task::Poll::Ready(Ok(())) => {}
412                    std::task::Poll::Pending => return std::task::Poll::Pending,
413                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
414                        this.is_terminated = true;
415                        return std::task::Poll::Ready(None);
416                    }
417                    std::task::Poll::Ready(Err(e)) => {
418                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
419                            e.into(),
420                        ))));
421                    }
422                }
423
424                // A message has been received from the channel
425                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
426
427                std::task::Poll::Ready(Some(match header.ordinal {
428                    0x63439dc551ef6dea => {
429                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
430                        let mut req = fidl::new_empty!(
431                            fidl::encoding::EmptyPayload,
432                            fidl::encoding::DefaultFuchsiaResourceDialect
433                        );
434                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
435                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
436                        Ok(DeviceRequest::GetFanLevel {
437                            responder: DeviceGetFanLevelResponder {
438                                control_handle: std::mem::ManuallyDrop::new(control_handle),
439                                tx_id: header.tx_id,
440                            },
441                        })
442                    }
443                    0x6552ae76e9703ffb => {
444                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
445                        let mut req = fidl::new_empty!(
446                            FanSetFanLevelRequest,
447                            fidl::encoding::DefaultFuchsiaResourceDialect
448                        );
449                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FanSetFanLevelRequest>(&header, _body_bytes, handles, &mut req)?;
450                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
451                        Ok(DeviceRequest::SetFanLevel {
452                            fan_level: req.fan_level,
453
454                            responder: DeviceSetFanLevelResponder {
455                                control_handle: std::mem::ManuallyDrop::new(control_handle),
456                                tx_id: header.tx_id,
457                            },
458                        })
459                    }
460                    0x186bc9e14d6c5596 => {
461                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
462                        let mut req = fidl::new_empty!(
463                            fidl::encoding::EmptyPayload,
464                            fidl::encoding::DefaultFuchsiaResourceDialect
465                        );
466                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
467                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
468                        Ok(DeviceRequest::GetClientType {
469                            responder: DeviceGetClientTypeResponder {
470                                control_handle: std::mem::ManuallyDrop::new(control_handle),
471                                tx_id: header.tx_id,
472                            },
473                        })
474                    }
475                    _ => Err(fidl::Error::UnknownOrdinal {
476                        ordinal: header.ordinal,
477                        protocol_name:
478                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
479                    }),
480                }))
481            },
482        )
483    }
484}
485
486#[derive(Debug)]
487pub enum DeviceRequest {
488    /// Get the current fan level.
489    /// - response `status`
490    ///      ZX_ERR_INTERNAL if `fan_level` is not available.
491    ///        This generally means that `fan_level` has not
492    ///        been initialized yet or something has gone
493    ///        terribly wrong.
494    /// - response `fan_level` a uint32 field indicating the
495    ///      current fan level. See fan level description above.
496    GetFanLevel { responder: DeviceGetFanLevelResponder },
497    /// Set the fan level.
498    /// + request `fan_level` a uint32 field indicating the
499    ///      requested fan level. See fan level description above.
500    /// - response `status`
501    ///      ZX_ERR_OUT_OF_RANGE if the requested fan_level is not
502    ///        valid.
503    SetFanLevel { fan_level: u32, responder: DeviceSetFanLevelResponder },
504    /// Returns the client type to use for
505    ///    `fuchsia.thermal.ClientStateConnector::Connect`.
506    GetClientType { responder: DeviceGetClientTypeResponder },
507}
508
509impl DeviceRequest {
510    #[allow(irrefutable_let_patterns)]
511    pub fn into_get_fan_level(self) -> Option<(DeviceGetFanLevelResponder)> {
512        if let DeviceRequest::GetFanLevel { responder } = self { Some((responder)) } else { None }
513    }
514
515    #[allow(irrefutable_let_patterns)]
516    pub fn into_set_fan_level(self) -> Option<(u32, DeviceSetFanLevelResponder)> {
517        if let DeviceRequest::SetFanLevel { fan_level, responder } = self {
518            Some((fan_level, responder))
519        } else {
520            None
521        }
522    }
523
524    #[allow(irrefutable_let_patterns)]
525    pub fn into_get_client_type(self) -> Option<(DeviceGetClientTypeResponder)> {
526        if let DeviceRequest::GetClientType { responder } = self { Some((responder)) } else { None }
527    }
528
529    /// Name of the method defined in FIDL
530    pub fn method_name(&self) -> &'static str {
531        match *self {
532            DeviceRequest::GetFanLevel { .. } => "get_fan_level",
533            DeviceRequest::SetFanLevel { .. } => "set_fan_level",
534            DeviceRequest::GetClientType { .. } => "get_client_type",
535        }
536    }
537}
538
539#[derive(Debug, Clone)]
540pub struct DeviceControlHandle {
541    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
542}
543
544impl DeviceControlHandle {
545    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
546        self.inner.shutdown_with_epitaph(status.into())
547    }
548}
549
550impl fidl::endpoints::ControlHandle for DeviceControlHandle {
551    fn shutdown(&self) {
552        self.inner.shutdown()
553    }
554
555    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
556        self.inner.shutdown_with_epitaph(status)
557    }
558
559    fn is_closed(&self) -> bool {
560        self.inner.channel().is_closed()
561    }
562    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
563        self.inner.channel().on_closed()
564    }
565
566    #[cfg(target_os = "fuchsia")]
567    fn signal_peer(
568        &self,
569        clear_mask: zx::Signals,
570        set_mask: zx::Signals,
571    ) -> Result<(), zx_status::Status> {
572        use fidl::Peered;
573        self.inner.channel().signal_peer(clear_mask, set_mask)
574    }
575}
576
577impl DeviceControlHandle {}
578
579#[must_use = "FIDL methods require a response to be sent"]
580#[derive(Debug)]
581pub struct DeviceGetFanLevelResponder {
582    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
583    tx_id: u32,
584}
585
586/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
587/// if the responder is dropped without sending a response, so that the client
588/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
589impl std::ops::Drop for DeviceGetFanLevelResponder {
590    fn drop(&mut self) {
591        self.control_handle.shutdown();
592        // Safety: drops once, never accessed again
593        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
594    }
595}
596
597impl fidl::endpoints::Responder for DeviceGetFanLevelResponder {
598    type ControlHandle = DeviceControlHandle;
599
600    fn control_handle(&self) -> &DeviceControlHandle {
601        &self.control_handle
602    }
603
604    fn drop_without_shutdown(mut self) {
605        // Safety: drops once, never accessed again due to mem::forget
606        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
607        // Prevent Drop from running (which would shut down the channel)
608        std::mem::forget(self);
609    }
610}
611
612impl DeviceGetFanLevelResponder {
613    /// Sends a response to the FIDL transaction.
614    ///
615    /// Sets the channel to shutdown if an error occurs.
616    pub fn send(self, mut status: i32, mut fan_level: u32) -> Result<(), fidl::Error> {
617        let _result = self.send_raw(status, fan_level);
618        if _result.is_err() {
619            self.control_handle.shutdown();
620        }
621        self.drop_without_shutdown();
622        _result
623    }
624
625    /// Similar to "send" but does not shutdown the channel if an error occurs.
626    pub fn send_no_shutdown_on_err(
627        self,
628        mut status: i32,
629        mut fan_level: u32,
630    ) -> Result<(), fidl::Error> {
631        let _result = self.send_raw(status, fan_level);
632        self.drop_without_shutdown();
633        _result
634    }
635
636    fn send_raw(&self, mut status: i32, mut fan_level: u32) -> Result<(), fidl::Error> {
637        self.control_handle.inner.send::<FanGetFanLevelResponse>(
638            (status, fan_level),
639            self.tx_id,
640            0x63439dc551ef6dea,
641            fidl::encoding::DynamicFlags::empty(),
642        )
643    }
644}
645
646#[must_use = "FIDL methods require a response to be sent"]
647#[derive(Debug)]
648pub struct DeviceSetFanLevelResponder {
649    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
650    tx_id: u32,
651}
652
653/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
654/// if the responder is dropped without sending a response, so that the client
655/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
656impl std::ops::Drop for DeviceSetFanLevelResponder {
657    fn drop(&mut self) {
658        self.control_handle.shutdown();
659        // Safety: drops once, never accessed again
660        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
661    }
662}
663
664impl fidl::endpoints::Responder for DeviceSetFanLevelResponder {
665    type ControlHandle = DeviceControlHandle;
666
667    fn control_handle(&self) -> &DeviceControlHandle {
668        &self.control_handle
669    }
670
671    fn drop_without_shutdown(mut self) {
672        // Safety: drops once, never accessed again due to mem::forget
673        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
674        // Prevent Drop from running (which would shut down the channel)
675        std::mem::forget(self);
676    }
677}
678
679impl DeviceSetFanLevelResponder {
680    /// Sends a response to the FIDL transaction.
681    ///
682    /// Sets the channel to shutdown if an error occurs.
683    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
684        let _result = self.send_raw(status);
685        if _result.is_err() {
686            self.control_handle.shutdown();
687        }
688        self.drop_without_shutdown();
689        _result
690    }
691
692    /// Similar to "send" but does not shutdown the channel if an error occurs.
693    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
694        let _result = self.send_raw(status);
695        self.drop_without_shutdown();
696        _result
697    }
698
699    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
700        self.control_handle.inner.send::<FanSetFanLevelResponse>(
701            (status,),
702            self.tx_id,
703            0x6552ae76e9703ffb,
704            fidl::encoding::DynamicFlags::empty(),
705        )
706    }
707}
708
709#[must_use = "FIDL methods require a response to be sent"]
710#[derive(Debug)]
711pub struct DeviceGetClientTypeResponder {
712    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
713    tx_id: u32,
714}
715
716/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
717/// if the responder is dropped without sending a response, so that the client
718/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
719impl std::ops::Drop for DeviceGetClientTypeResponder {
720    fn drop(&mut self) {
721        self.control_handle.shutdown();
722        // Safety: drops once, never accessed again
723        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
724    }
725}
726
727impl fidl::endpoints::Responder for DeviceGetClientTypeResponder {
728    type ControlHandle = DeviceControlHandle;
729
730    fn control_handle(&self) -> &DeviceControlHandle {
731        &self.control_handle
732    }
733
734    fn drop_without_shutdown(mut self) {
735        // Safety: drops once, never accessed again due to mem::forget
736        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
737        // Prevent Drop from running (which would shut down the channel)
738        std::mem::forget(self);
739    }
740}
741
742impl DeviceGetClientTypeResponder {
743    /// Sends a response to the FIDL transaction.
744    ///
745    /// Sets the channel to shutdown if an error occurs.
746    pub fn send(self, mut client_type: &str) -> Result<(), fidl::Error> {
747        let _result = self.send_raw(client_type);
748        if _result.is_err() {
749            self.control_handle.shutdown();
750        }
751        self.drop_without_shutdown();
752        _result
753    }
754
755    /// Similar to "send" but does not shutdown the channel if an error occurs.
756    pub fn send_no_shutdown_on_err(self, mut client_type: &str) -> Result<(), fidl::Error> {
757        let _result = self.send_raw(client_type);
758        self.drop_without_shutdown();
759        _result
760    }
761
762    fn send_raw(&self, mut client_type: &str) -> Result<(), fidl::Error> {
763        self.control_handle.inner.send::<DeviceGetClientTypeResponse>(
764            (client_type,),
765            self.tx_id,
766            0x186bc9e14d6c5596,
767            fidl::encoding::DynamicFlags::empty(),
768        )
769    }
770}
771
772#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
773pub struct FanMarker;
774
775impl fidl::endpoints::ProtocolMarker for FanMarker {
776    type Proxy = FanProxy;
777    type RequestStream = FanRequestStream;
778    #[cfg(target_os = "fuchsia")]
779    type SynchronousProxy = FanSynchronousProxy;
780
781    const DEBUG_NAME: &'static str = "(anonymous) Fan";
782}
783
784pub trait FanProxyInterface: Send + Sync {
785    type GetFanLevelResponseFut: std::future::Future<Output = Result<(i32, u32), fidl::Error>>
786        + Send;
787    fn r#get_fan_level(&self) -> Self::GetFanLevelResponseFut;
788    type SetFanLevelResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
789    fn r#set_fan_level(&self, fan_level: u32) -> Self::SetFanLevelResponseFut;
790}
791#[derive(Debug)]
792#[cfg(target_os = "fuchsia")]
793pub struct FanSynchronousProxy {
794    client: fidl::client::sync::Client,
795}
796
797#[cfg(target_os = "fuchsia")]
798impl fidl::endpoints::SynchronousProxy for FanSynchronousProxy {
799    type Proxy = FanProxy;
800    type Protocol = FanMarker;
801
802    fn from_channel(inner: fidl::Channel) -> Self {
803        Self::new(inner)
804    }
805
806    fn into_channel(self) -> fidl::Channel {
807        self.client.into_channel()
808    }
809
810    fn as_channel(&self) -> &fidl::Channel {
811        self.client.as_channel()
812    }
813}
814
815#[cfg(target_os = "fuchsia")]
816impl FanSynchronousProxy {
817    pub fn new(channel: fidl::Channel) -> Self {
818        Self { client: fidl::client::sync::Client::new(channel) }
819    }
820
821    pub fn into_channel(self) -> fidl::Channel {
822        self.client.into_channel()
823    }
824
825    /// Waits until an event arrives and returns it. It is safe for other
826    /// threads to make concurrent requests while waiting for an event.
827    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<FanEvent, fidl::Error> {
828        FanEvent::decode(self.client.wait_for_event::<FanMarker>(deadline)?)
829    }
830
831    /// Get the current fan level.
832    /// - response `status`
833    ///      ZX_ERR_INTERNAL if `fan_level` is not available.
834    ///        This generally means that `fan_level` has not
835    ///        been initialized yet or something has gone
836    ///        terribly wrong.
837    /// - response `fan_level` a uint32 field indicating the
838    ///      current fan level. See fan level description above.
839    pub fn r#get_fan_level(
840        &self,
841        ___deadline: zx::MonotonicInstant,
842    ) -> Result<(i32, u32), fidl::Error> {
843        let _response = self
844            .client
845            .send_query::<fidl::encoding::EmptyPayload, FanGetFanLevelResponse, FanMarker>(
846                (),
847                0x63439dc551ef6dea,
848                fidl::encoding::DynamicFlags::empty(),
849                ___deadline,
850            )?;
851        Ok((_response.status, _response.fan_level))
852    }
853
854    /// Set the fan level.
855    /// + request `fan_level` a uint32 field indicating the
856    ///      requested fan level. See fan level description above.
857    /// - response `status`
858    ///      ZX_ERR_OUT_OF_RANGE if the requested fan_level is not
859    ///        valid.
860    pub fn r#set_fan_level(
861        &self,
862        mut fan_level: u32,
863        ___deadline: zx::MonotonicInstant,
864    ) -> Result<i32, fidl::Error> {
865        let _response =
866            self.client.send_query::<FanSetFanLevelRequest, FanSetFanLevelResponse, FanMarker>(
867                (fan_level,),
868                0x6552ae76e9703ffb,
869                fidl::encoding::DynamicFlags::empty(),
870                ___deadline,
871            )?;
872        Ok(_response.status)
873    }
874}
875
876#[cfg(target_os = "fuchsia")]
877impl From<FanSynchronousProxy> for zx::NullableHandle {
878    fn from(value: FanSynchronousProxy) -> Self {
879        value.into_channel().into()
880    }
881}
882
883#[cfg(target_os = "fuchsia")]
884impl From<fidl::Channel> for FanSynchronousProxy {
885    fn from(value: fidl::Channel) -> Self {
886        Self::new(value)
887    }
888}
889
890#[cfg(target_os = "fuchsia")]
891impl fidl::endpoints::FromClient for FanSynchronousProxy {
892    type Protocol = FanMarker;
893
894    fn from_client(value: fidl::endpoints::ClientEnd<FanMarker>) -> Self {
895        Self::new(value.into_channel())
896    }
897}
898
899#[derive(Debug, Clone)]
900pub struct FanProxy {
901    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
902}
903
904impl fidl::endpoints::Proxy for FanProxy {
905    type Protocol = FanMarker;
906
907    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
908        Self::new(inner)
909    }
910
911    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
912        self.client.into_channel().map_err(|client| Self { client })
913    }
914
915    fn as_channel(&self) -> &::fidl::AsyncChannel {
916        self.client.as_channel()
917    }
918}
919
920impl FanProxy {
921    /// Create a new Proxy for fuchsia.hardware.fan/Fan.
922    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
923        let protocol_name = <FanMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
924        Self { client: fidl::client::Client::new(channel, protocol_name) }
925    }
926
927    /// Get a Stream of events from the remote end of the protocol.
928    ///
929    /// # Panics
930    ///
931    /// Panics if the event stream was already taken.
932    pub fn take_event_stream(&self) -> FanEventStream {
933        FanEventStream { event_receiver: self.client.take_event_receiver() }
934    }
935
936    /// Get the current fan level.
937    /// - response `status`
938    ///      ZX_ERR_INTERNAL if `fan_level` is not available.
939    ///        This generally means that `fan_level` has not
940    ///        been initialized yet or something has gone
941    ///        terribly wrong.
942    /// - response `fan_level` a uint32 field indicating the
943    ///      current fan level. See fan level description above.
944    pub fn r#get_fan_level(
945        &self,
946    ) -> fidl::client::QueryResponseFut<(i32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>
947    {
948        FanProxyInterface::r#get_fan_level(self)
949    }
950
951    /// Set the fan level.
952    /// + request `fan_level` a uint32 field indicating the
953    ///      requested fan level. See fan level description above.
954    /// - response `status`
955    ///      ZX_ERR_OUT_OF_RANGE if the requested fan_level is not
956    ///        valid.
957    pub fn r#set_fan_level(
958        &self,
959        mut fan_level: u32,
960    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
961        FanProxyInterface::r#set_fan_level(self, fan_level)
962    }
963}
964
965impl FanProxyInterface for FanProxy {
966    type GetFanLevelResponseFut =
967        fidl::client::QueryResponseFut<(i32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>;
968    fn r#get_fan_level(&self) -> Self::GetFanLevelResponseFut {
969        fn _decode(
970            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
971        ) -> Result<(i32, u32), fidl::Error> {
972            let _response = fidl::client::decode_transaction_body::<
973                FanGetFanLevelResponse,
974                fidl::encoding::DefaultFuchsiaResourceDialect,
975                0x63439dc551ef6dea,
976            >(_buf?)?;
977            Ok((_response.status, _response.fan_level))
978        }
979        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, u32)>(
980            (),
981            0x63439dc551ef6dea,
982            fidl::encoding::DynamicFlags::empty(),
983            _decode,
984        )
985    }
986
987    type SetFanLevelResponseFut =
988        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
989    fn r#set_fan_level(&self, mut fan_level: u32) -> Self::SetFanLevelResponseFut {
990        fn _decode(
991            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
992        ) -> Result<i32, fidl::Error> {
993            let _response = fidl::client::decode_transaction_body::<
994                FanSetFanLevelResponse,
995                fidl::encoding::DefaultFuchsiaResourceDialect,
996                0x6552ae76e9703ffb,
997            >(_buf?)?;
998            Ok(_response.status)
999        }
1000        self.client.send_query_and_decode::<FanSetFanLevelRequest, i32>(
1001            (fan_level,),
1002            0x6552ae76e9703ffb,
1003            fidl::encoding::DynamicFlags::empty(),
1004            _decode,
1005        )
1006    }
1007}
1008
1009pub struct FanEventStream {
1010    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1011}
1012
1013impl std::marker::Unpin for FanEventStream {}
1014
1015impl futures::stream::FusedStream for FanEventStream {
1016    fn is_terminated(&self) -> bool {
1017        self.event_receiver.is_terminated()
1018    }
1019}
1020
1021impl futures::Stream for FanEventStream {
1022    type Item = Result<FanEvent, fidl::Error>;
1023
1024    fn poll_next(
1025        mut self: std::pin::Pin<&mut Self>,
1026        cx: &mut std::task::Context<'_>,
1027    ) -> std::task::Poll<Option<Self::Item>> {
1028        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1029            &mut self.event_receiver,
1030            cx
1031        )?) {
1032            Some(buf) => std::task::Poll::Ready(Some(FanEvent::decode(buf))),
1033            None => std::task::Poll::Ready(None),
1034        }
1035    }
1036}
1037
1038#[derive(Debug)]
1039pub enum FanEvent {}
1040
1041impl FanEvent {
1042    /// Decodes a message buffer as a [`FanEvent`].
1043    fn decode(
1044        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1045    ) -> Result<FanEvent, fidl::Error> {
1046        let (bytes, _handles) = buf.split_mut();
1047        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1048        debug_assert_eq!(tx_header.tx_id, 0);
1049        match tx_header.ordinal {
1050            _ => Err(fidl::Error::UnknownOrdinal {
1051                ordinal: tx_header.ordinal,
1052                protocol_name: <FanMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1053            }),
1054        }
1055    }
1056}
1057
1058/// A Stream of incoming requests for fuchsia.hardware.fan/Fan.
1059pub struct FanRequestStream {
1060    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1061    is_terminated: bool,
1062}
1063
1064impl std::marker::Unpin for FanRequestStream {}
1065
1066impl futures::stream::FusedStream for FanRequestStream {
1067    fn is_terminated(&self) -> bool {
1068        self.is_terminated
1069    }
1070}
1071
1072impl fidl::endpoints::RequestStream for FanRequestStream {
1073    type Protocol = FanMarker;
1074    type ControlHandle = FanControlHandle;
1075
1076    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1077        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1078    }
1079
1080    fn control_handle(&self) -> Self::ControlHandle {
1081        FanControlHandle { inner: self.inner.clone() }
1082    }
1083
1084    fn into_inner(
1085        self,
1086    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1087    {
1088        (self.inner, self.is_terminated)
1089    }
1090
1091    fn from_inner(
1092        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1093        is_terminated: bool,
1094    ) -> Self {
1095        Self { inner, is_terminated }
1096    }
1097}
1098
1099impl futures::Stream for FanRequestStream {
1100    type Item = Result<FanRequest, fidl::Error>;
1101
1102    fn poll_next(
1103        mut self: std::pin::Pin<&mut Self>,
1104        cx: &mut std::task::Context<'_>,
1105    ) -> std::task::Poll<Option<Self::Item>> {
1106        let this = &mut *self;
1107        if this.inner.check_shutdown(cx) {
1108            this.is_terminated = true;
1109            return std::task::Poll::Ready(None);
1110        }
1111        if this.is_terminated {
1112            panic!("polled FanRequestStream after completion");
1113        }
1114        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1115            |bytes, handles| {
1116                match this.inner.channel().read_etc(cx, bytes, handles) {
1117                    std::task::Poll::Ready(Ok(())) => {}
1118                    std::task::Poll::Pending => return std::task::Poll::Pending,
1119                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1120                        this.is_terminated = true;
1121                        return std::task::Poll::Ready(None);
1122                    }
1123                    std::task::Poll::Ready(Err(e)) => {
1124                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1125                            e.into(),
1126                        ))));
1127                    }
1128                }
1129
1130                // A message has been received from the channel
1131                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1132
1133                std::task::Poll::Ready(Some(match header.ordinal {
1134                    0x63439dc551ef6dea => {
1135                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1136                        let mut req = fidl::new_empty!(
1137                            fidl::encoding::EmptyPayload,
1138                            fidl::encoding::DefaultFuchsiaResourceDialect
1139                        );
1140                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1141                        let control_handle = FanControlHandle { inner: this.inner.clone() };
1142                        Ok(FanRequest::GetFanLevel {
1143                            responder: FanGetFanLevelResponder {
1144                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1145                                tx_id: header.tx_id,
1146                            },
1147                        })
1148                    }
1149                    0x6552ae76e9703ffb => {
1150                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1151                        let mut req = fidl::new_empty!(
1152                            FanSetFanLevelRequest,
1153                            fidl::encoding::DefaultFuchsiaResourceDialect
1154                        );
1155                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FanSetFanLevelRequest>(&header, _body_bytes, handles, &mut req)?;
1156                        let control_handle = FanControlHandle { inner: this.inner.clone() };
1157                        Ok(FanRequest::SetFanLevel {
1158                            fan_level: req.fan_level,
1159
1160                            responder: FanSetFanLevelResponder {
1161                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1162                                tx_id: header.tx_id,
1163                            },
1164                        })
1165                    }
1166                    _ => Err(fidl::Error::UnknownOrdinal {
1167                        ordinal: header.ordinal,
1168                        protocol_name: <FanMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1169                    }),
1170                }))
1171            },
1172        )
1173    }
1174}
1175
1176/// Fan: get and set `fan_level`
1177/// `fan_level`: 0 should be the lowest fan state, generally OFF.
1178///              Fan speed increases with `fan_level` and should
1179///              match the `fuchsia.thermal.ClientStateWatcher`
1180///              states for fans, where the states are defined
1181///              in thermal_config.json for each product.
1182///              Thus, the valid values of `fan_level` is
1183///              determined per product according to the
1184///              corresponding config json file.
1185#[derive(Debug)]
1186pub enum FanRequest {
1187    /// Get the current fan level.
1188    /// - response `status`
1189    ///      ZX_ERR_INTERNAL if `fan_level` is not available.
1190    ///        This generally means that `fan_level` has not
1191    ///        been initialized yet or something has gone
1192    ///        terribly wrong.
1193    /// - response `fan_level` a uint32 field indicating the
1194    ///      current fan level. See fan level description above.
1195    GetFanLevel { responder: FanGetFanLevelResponder },
1196    /// Set the fan level.
1197    /// + request `fan_level` a uint32 field indicating the
1198    ///      requested fan level. See fan level description above.
1199    /// - response `status`
1200    ///      ZX_ERR_OUT_OF_RANGE if the requested fan_level is not
1201    ///        valid.
1202    SetFanLevel { fan_level: u32, responder: FanSetFanLevelResponder },
1203}
1204
1205impl FanRequest {
1206    #[allow(irrefutable_let_patterns)]
1207    pub fn into_get_fan_level(self) -> Option<(FanGetFanLevelResponder)> {
1208        if let FanRequest::GetFanLevel { responder } = self { Some((responder)) } else { None }
1209    }
1210
1211    #[allow(irrefutable_let_patterns)]
1212    pub fn into_set_fan_level(self) -> Option<(u32, FanSetFanLevelResponder)> {
1213        if let FanRequest::SetFanLevel { fan_level, responder } = self {
1214            Some((fan_level, responder))
1215        } else {
1216            None
1217        }
1218    }
1219
1220    /// Name of the method defined in FIDL
1221    pub fn method_name(&self) -> &'static str {
1222        match *self {
1223            FanRequest::GetFanLevel { .. } => "get_fan_level",
1224            FanRequest::SetFanLevel { .. } => "set_fan_level",
1225        }
1226    }
1227}
1228
1229#[derive(Debug, Clone)]
1230pub struct FanControlHandle {
1231    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1232}
1233
1234impl FanControlHandle {
1235    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1236        self.inner.shutdown_with_epitaph(status.into())
1237    }
1238}
1239
1240impl fidl::endpoints::ControlHandle for FanControlHandle {
1241    fn shutdown(&self) {
1242        self.inner.shutdown()
1243    }
1244
1245    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1246        self.inner.shutdown_with_epitaph(status)
1247    }
1248
1249    fn is_closed(&self) -> bool {
1250        self.inner.channel().is_closed()
1251    }
1252    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1253        self.inner.channel().on_closed()
1254    }
1255
1256    #[cfg(target_os = "fuchsia")]
1257    fn signal_peer(
1258        &self,
1259        clear_mask: zx::Signals,
1260        set_mask: zx::Signals,
1261    ) -> Result<(), zx_status::Status> {
1262        use fidl::Peered;
1263        self.inner.channel().signal_peer(clear_mask, set_mask)
1264    }
1265}
1266
1267impl FanControlHandle {}
1268
1269#[must_use = "FIDL methods require a response to be sent"]
1270#[derive(Debug)]
1271pub struct FanGetFanLevelResponder {
1272    control_handle: std::mem::ManuallyDrop<FanControlHandle>,
1273    tx_id: u32,
1274}
1275
1276/// Set the the channel to be shutdown (see [`FanControlHandle::shutdown`])
1277/// if the responder is dropped without sending a response, so that the client
1278/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1279impl std::ops::Drop for FanGetFanLevelResponder {
1280    fn drop(&mut self) {
1281        self.control_handle.shutdown();
1282        // Safety: drops once, never accessed again
1283        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1284    }
1285}
1286
1287impl fidl::endpoints::Responder for FanGetFanLevelResponder {
1288    type ControlHandle = FanControlHandle;
1289
1290    fn control_handle(&self) -> &FanControlHandle {
1291        &self.control_handle
1292    }
1293
1294    fn drop_without_shutdown(mut self) {
1295        // Safety: drops once, never accessed again due to mem::forget
1296        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1297        // Prevent Drop from running (which would shut down the channel)
1298        std::mem::forget(self);
1299    }
1300}
1301
1302impl FanGetFanLevelResponder {
1303    /// Sends a response to the FIDL transaction.
1304    ///
1305    /// Sets the channel to shutdown if an error occurs.
1306    pub fn send(self, mut status: i32, mut fan_level: u32) -> Result<(), fidl::Error> {
1307        let _result = self.send_raw(status, fan_level);
1308        if _result.is_err() {
1309            self.control_handle.shutdown();
1310        }
1311        self.drop_without_shutdown();
1312        _result
1313    }
1314
1315    /// Similar to "send" but does not shutdown the channel if an error occurs.
1316    pub fn send_no_shutdown_on_err(
1317        self,
1318        mut status: i32,
1319        mut fan_level: u32,
1320    ) -> Result<(), fidl::Error> {
1321        let _result = self.send_raw(status, fan_level);
1322        self.drop_without_shutdown();
1323        _result
1324    }
1325
1326    fn send_raw(&self, mut status: i32, mut fan_level: u32) -> Result<(), fidl::Error> {
1327        self.control_handle.inner.send::<FanGetFanLevelResponse>(
1328            (status, fan_level),
1329            self.tx_id,
1330            0x63439dc551ef6dea,
1331            fidl::encoding::DynamicFlags::empty(),
1332        )
1333    }
1334}
1335
1336#[must_use = "FIDL methods require a response to be sent"]
1337#[derive(Debug)]
1338pub struct FanSetFanLevelResponder {
1339    control_handle: std::mem::ManuallyDrop<FanControlHandle>,
1340    tx_id: u32,
1341}
1342
1343/// Set the the channel to be shutdown (see [`FanControlHandle::shutdown`])
1344/// if the responder is dropped without sending a response, so that the client
1345/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1346impl std::ops::Drop for FanSetFanLevelResponder {
1347    fn drop(&mut self) {
1348        self.control_handle.shutdown();
1349        // Safety: drops once, never accessed again
1350        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1351    }
1352}
1353
1354impl fidl::endpoints::Responder for FanSetFanLevelResponder {
1355    type ControlHandle = FanControlHandle;
1356
1357    fn control_handle(&self) -> &FanControlHandle {
1358        &self.control_handle
1359    }
1360
1361    fn drop_without_shutdown(mut self) {
1362        // Safety: drops once, never accessed again due to mem::forget
1363        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1364        // Prevent Drop from running (which would shut down the channel)
1365        std::mem::forget(self);
1366    }
1367}
1368
1369impl FanSetFanLevelResponder {
1370    /// Sends a response to the FIDL transaction.
1371    ///
1372    /// Sets the channel to shutdown if an error occurs.
1373    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
1374        let _result = self.send_raw(status);
1375        if _result.is_err() {
1376            self.control_handle.shutdown();
1377        }
1378        self.drop_without_shutdown();
1379        _result
1380    }
1381
1382    /// Similar to "send" but does not shutdown the channel if an error occurs.
1383    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
1384        let _result = self.send_raw(status);
1385        self.drop_without_shutdown();
1386        _result
1387    }
1388
1389    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
1390        self.control_handle.inner.send::<FanSetFanLevelResponse>(
1391            (status,),
1392            self.tx_id,
1393            0x6552ae76e9703ffb,
1394            fidl::encoding::DynamicFlags::empty(),
1395        )
1396    }
1397}
1398
1399#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1400pub struct ServiceMarker;
1401
1402#[cfg(target_os = "fuchsia")]
1403impl fidl::endpoints::ServiceMarker for ServiceMarker {
1404    type Proxy = ServiceProxy;
1405    type Request = ServiceRequest;
1406    const SERVICE_NAME: &'static str = "fuchsia.hardware.fan.Service";
1407}
1408
1409/// A request for one of the member protocols of Service.
1410///
1411#[cfg(target_os = "fuchsia")]
1412pub enum ServiceRequest {
1413    Device(DeviceRequestStream),
1414}
1415
1416#[cfg(target_os = "fuchsia")]
1417impl fidl::endpoints::ServiceRequest for ServiceRequest {
1418    type Service = ServiceMarker;
1419
1420    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1421        match name {
1422            "device" => Self::Device(
1423                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1424            ),
1425            _ => panic!("no such member protocol name for service Service"),
1426        }
1427    }
1428
1429    fn member_names() -> &'static [&'static str] {
1430        &["device"]
1431    }
1432}
1433#[cfg(target_os = "fuchsia")]
1434pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1435
1436#[cfg(target_os = "fuchsia")]
1437impl fidl::endpoints::ServiceProxy for ServiceProxy {
1438    type Service = ServiceMarker;
1439
1440    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1441        Self(opener)
1442    }
1443}
1444
1445#[cfg(target_os = "fuchsia")]
1446impl ServiceProxy {
1447    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1448        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1449        self.connect_channel_to_device(server_end)?;
1450        Ok(proxy)
1451    }
1452
1453    /// Like `connect_to_device`, but returns a sync proxy.
1454    /// See [`Self::connect_to_device`] for more details.
1455    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1456        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1457        self.connect_channel_to_device(server_end)?;
1458        Ok(proxy)
1459    }
1460
1461    /// Like `connect_to_device`, but accepts a server end.
1462    /// See [`Self::connect_to_device`] for more details.
1463    pub fn connect_channel_to_device(
1464        &self,
1465        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1466    ) -> Result<(), fidl::Error> {
1467        self.0.open_member("device", server_end.into_channel())
1468    }
1469
1470    pub fn instance_name(&self) -> &str {
1471        self.0.instance_name()
1472    }
1473}
1474
1475mod internal {
1476    use super::*;
1477}