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 fidl::endpoints::ControlHandle for DeviceControlHandle {
545    fn shutdown(&self) {
546        self.inner.shutdown()
547    }
548
549    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
550        self.inner.shutdown_with_epitaph(status)
551    }
552
553    fn is_closed(&self) -> bool {
554        self.inner.channel().is_closed()
555    }
556    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
557        self.inner.channel().on_closed()
558    }
559
560    #[cfg(target_os = "fuchsia")]
561    fn signal_peer(
562        &self,
563        clear_mask: zx::Signals,
564        set_mask: zx::Signals,
565    ) -> Result<(), zx_status::Status> {
566        use fidl::Peered;
567        self.inner.channel().signal_peer(clear_mask, set_mask)
568    }
569}
570
571impl DeviceControlHandle {}
572
573#[must_use = "FIDL methods require a response to be sent"]
574#[derive(Debug)]
575pub struct DeviceGetFanLevelResponder {
576    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
577    tx_id: u32,
578}
579
580/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
581/// if the responder is dropped without sending a response, so that the client
582/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
583impl std::ops::Drop for DeviceGetFanLevelResponder {
584    fn drop(&mut self) {
585        self.control_handle.shutdown();
586        // Safety: drops once, never accessed again
587        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
588    }
589}
590
591impl fidl::endpoints::Responder for DeviceGetFanLevelResponder {
592    type ControlHandle = DeviceControlHandle;
593
594    fn control_handle(&self) -> &DeviceControlHandle {
595        &self.control_handle
596    }
597
598    fn drop_without_shutdown(mut self) {
599        // Safety: drops once, never accessed again due to mem::forget
600        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
601        // Prevent Drop from running (which would shut down the channel)
602        std::mem::forget(self);
603    }
604}
605
606impl DeviceGetFanLevelResponder {
607    /// Sends a response to the FIDL transaction.
608    ///
609    /// Sets the channel to shutdown if an error occurs.
610    pub fn send(self, mut status: i32, mut fan_level: u32) -> Result<(), fidl::Error> {
611        let _result = self.send_raw(status, fan_level);
612        if _result.is_err() {
613            self.control_handle.shutdown();
614        }
615        self.drop_without_shutdown();
616        _result
617    }
618
619    /// Similar to "send" but does not shutdown the channel if an error occurs.
620    pub fn send_no_shutdown_on_err(
621        self,
622        mut status: i32,
623        mut fan_level: u32,
624    ) -> Result<(), fidl::Error> {
625        let _result = self.send_raw(status, fan_level);
626        self.drop_without_shutdown();
627        _result
628    }
629
630    fn send_raw(&self, mut status: i32, mut fan_level: u32) -> Result<(), fidl::Error> {
631        self.control_handle.inner.send::<FanGetFanLevelResponse>(
632            (status, fan_level),
633            self.tx_id,
634            0x63439dc551ef6dea,
635            fidl::encoding::DynamicFlags::empty(),
636        )
637    }
638}
639
640#[must_use = "FIDL methods require a response to be sent"]
641#[derive(Debug)]
642pub struct DeviceSetFanLevelResponder {
643    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
644    tx_id: u32,
645}
646
647/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
648/// if the responder is dropped without sending a response, so that the client
649/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
650impl std::ops::Drop for DeviceSetFanLevelResponder {
651    fn drop(&mut self) {
652        self.control_handle.shutdown();
653        // Safety: drops once, never accessed again
654        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
655    }
656}
657
658impl fidl::endpoints::Responder for DeviceSetFanLevelResponder {
659    type ControlHandle = DeviceControlHandle;
660
661    fn control_handle(&self) -> &DeviceControlHandle {
662        &self.control_handle
663    }
664
665    fn drop_without_shutdown(mut self) {
666        // Safety: drops once, never accessed again due to mem::forget
667        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
668        // Prevent Drop from running (which would shut down the channel)
669        std::mem::forget(self);
670    }
671}
672
673impl DeviceSetFanLevelResponder {
674    /// Sends a response to the FIDL transaction.
675    ///
676    /// Sets the channel to shutdown if an error occurs.
677    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
678        let _result = self.send_raw(status);
679        if _result.is_err() {
680            self.control_handle.shutdown();
681        }
682        self.drop_without_shutdown();
683        _result
684    }
685
686    /// Similar to "send" but does not shutdown the channel if an error occurs.
687    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
688        let _result = self.send_raw(status);
689        self.drop_without_shutdown();
690        _result
691    }
692
693    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
694        self.control_handle.inner.send::<FanSetFanLevelResponse>(
695            (status,),
696            self.tx_id,
697            0x6552ae76e9703ffb,
698            fidl::encoding::DynamicFlags::empty(),
699        )
700    }
701}
702
703#[must_use = "FIDL methods require a response to be sent"]
704#[derive(Debug)]
705pub struct DeviceGetClientTypeResponder {
706    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
707    tx_id: u32,
708}
709
710/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
711/// if the responder is dropped without sending a response, so that the client
712/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
713impl std::ops::Drop for DeviceGetClientTypeResponder {
714    fn drop(&mut self) {
715        self.control_handle.shutdown();
716        // Safety: drops once, never accessed again
717        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
718    }
719}
720
721impl fidl::endpoints::Responder for DeviceGetClientTypeResponder {
722    type ControlHandle = DeviceControlHandle;
723
724    fn control_handle(&self) -> &DeviceControlHandle {
725        &self.control_handle
726    }
727
728    fn drop_without_shutdown(mut self) {
729        // Safety: drops once, never accessed again due to mem::forget
730        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
731        // Prevent Drop from running (which would shut down the channel)
732        std::mem::forget(self);
733    }
734}
735
736impl DeviceGetClientTypeResponder {
737    /// Sends a response to the FIDL transaction.
738    ///
739    /// Sets the channel to shutdown if an error occurs.
740    pub fn send(self, mut client_type: &str) -> Result<(), fidl::Error> {
741        let _result = self.send_raw(client_type);
742        if _result.is_err() {
743            self.control_handle.shutdown();
744        }
745        self.drop_without_shutdown();
746        _result
747    }
748
749    /// Similar to "send" but does not shutdown the channel if an error occurs.
750    pub fn send_no_shutdown_on_err(self, mut client_type: &str) -> Result<(), fidl::Error> {
751        let _result = self.send_raw(client_type);
752        self.drop_without_shutdown();
753        _result
754    }
755
756    fn send_raw(&self, mut client_type: &str) -> Result<(), fidl::Error> {
757        self.control_handle.inner.send::<DeviceGetClientTypeResponse>(
758            (client_type,),
759            self.tx_id,
760            0x186bc9e14d6c5596,
761            fidl::encoding::DynamicFlags::empty(),
762        )
763    }
764}
765
766#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
767pub struct FanMarker;
768
769impl fidl::endpoints::ProtocolMarker for FanMarker {
770    type Proxy = FanProxy;
771    type RequestStream = FanRequestStream;
772    #[cfg(target_os = "fuchsia")]
773    type SynchronousProxy = FanSynchronousProxy;
774
775    const DEBUG_NAME: &'static str = "(anonymous) Fan";
776}
777
778pub trait FanProxyInterface: Send + Sync {
779    type GetFanLevelResponseFut: std::future::Future<Output = Result<(i32, u32), fidl::Error>>
780        + Send;
781    fn r#get_fan_level(&self) -> Self::GetFanLevelResponseFut;
782    type SetFanLevelResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
783    fn r#set_fan_level(&self, fan_level: u32) -> Self::SetFanLevelResponseFut;
784}
785#[derive(Debug)]
786#[cfg(target_os = "fuchsia")]
787pub struct FanSynchronousProxy {
788    client: fidl::client::sync::Client,
789}
790
791#[cfg(target_os = "fuchsia")]
792impl fidl::endpoints::SynchronousProxy for FanSynchronousProxy {
793    type Proxy = FanProxy;
794    type Protocol = FanMarker;
795
796    fn from_channel(inner: fidl::Channel) -> Self {
797        Self::new(inner)
798    }
799
800    fn into_channel(self) -> fidl::Channel {
801        self.client.into_channel()
802    }
803
804    fn as_channel(&self) -> &fidl::Channel {
805        self.client.as_channel()
806    }
807}
808
809#[cfg(target_os = "fuchsia")]
810impl FanSynchronousProxy {
811    pub fn new(channel: fidl::Channel) -> Self {
812        Self { client: fidl::client::sync::Client::new(channel) }
813    }
814
815    pub fn into_channel(self) -> fidl::Channel {
816        self.client.into_channel()
817    }
818
819    /// Waits until an event arrives and returns it. It is safe for other
820    /// threads to make concurrent requests while waiting for an event.
821    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<FanEvent, fidl::Error> {
822        FanEvent::decode(self.client.wait_for_event::<FanMarker>(deadline)?)
823    }
824
825    /// Get the current fan level.
826    /// - response `status`
827    ///      ZX_ERR_INTERNAL if `fan_level` is not available.
828    ///        This generally means that `fan_level` has not
829    ///        been initialized yet or something has gone
830    ///        terribly wrong.
831    /// - response `fan_level` a uint32 field indicating the
832    ///      current fan level. See fan level description above.
833    pub fn r#get_fan_level(
834        &self,
835        ___deadline: zx::MonotonicInstant,
836    ) -> Result<(i32, u32), fidl::Error> {
837        let _response = self
838            .client
839            .send_query::<fidl::encoding::EmptyPayload, FanGetFanLevelResponse, FanMarker>(
840                (),
841                0x63439dc551ef6dea,
842                fidl::encoding::DynamicFlags::empty(),
843                ___deadline,
844            )?;
845        Ok((_response.status, _response.fan_level))
846    }
847
848    /// Set the fan level.
849    /// + request `fan_level` a uint32 field indicating the
850    ///      requested fan level. See fan level description above.
851    /// - response `status`
852    ///      ZX_ERR_OUT_OF_RANGE if the requested fan_level is not
853    ///        valid.
854    pub fn r#set_fan_level(
855        &self,
856        mut fan_level: u32,
857        ___deadline: zx::MonotonicInstant,
858    ) -> Result<i32, fidl::Error> {
859        let _response =
860            self.client.send_query::<FanSetFanLevelRequest, FanSetFanLevelResponse, FanMarker>(
861                (fan_level,),
862                0x6552ae76e9703ffb,
863                fidl::encoding::DynamicFlags::empty(),
864                ___deadline,
865            )?;
866        Ok(_response.status)
867    }
868}
869
870#[cfg(target_os = "fuchsia")]
871impl From<FanSynchronousProxy> for zx::NullableHandle {
872    fn from(value: FanSynchronousProxy) -> Self {
873        value.into_channel().into()
874    }
875}
876
877#[cfg(target_os = "fuchsia")]
878impl From<fidl::Channel> for FanSynchronousProxy {
879    fn from(value: fidl::Channel) -> Self {
880        Self::new(value)
881    }
882}
883
884#[cfg(target_os = "fuchsia")]
885impl fidl::endpoints::FromClient for FanSynchronousProxy {
886    type Protocol = FanMarker;
887
888    fn from_client(value: fidl::endpoints::ClientEnd<FanMarker>) -> Self {
889        Self::new(value.into_channel())
890    }
891}
892
893#[derive(Debug, Clone)]
894pub struct FanProxy {
895    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
896}
897
898impl fidl::endpoints::Proxy for FanProxy {
899    type Protocol = FanMarker;
900
901    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
902        Self::new(inner)
903    }
904
905    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
906        self.client.into_channel().map_err(|client| Self { client })
907    }
908
909    fn as_channel(&self) -> &::fidl::AsyncChannel {
910        self.client.as_channel()
911    }
912}
913
914impl FanProxy {
915    /// Create a new Proxy for fuchsia.hardware.fan/Fan.
916    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
917        let protocol_name = <FanMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
918        Self { client: fidl::client::Client::new(channel, protocol_name) }
919    }
920
921    /// Get a Stream of events from the remote end of the protocol.
922    ///
923    /// # Panics
924    ///
925    /// Panics if the event stream was already taken.
926    pub fn take_event_stream(&self) -> FanEventStream {
927        FanEventStream { event_receiver: self.client.take_event_receiver() }
928    }
929
930    /// Get the current fan level.
931    /// - response `status`
932    ///      ZX_ERR_INTERNAL if `fan_level` is not available.
933    ///        This generally means that `fan_level` has not
934    ///        been initialized yet or something has gone
935    ///        terribly wrong.
936    /// - response `fan_level` a uint32 field indicating the
937    ///      current fan level. See fan level description above.
938    pub fn r#get_fan_level(
939        &self,
940    ) -> fidl::client::QueryResponseFut<(i32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>
941    {
942        FanProxyInterface::r#get_fan_level(self)
943    }
944
945    /// Set the fan level.
946    /// + request `fan_level` a uint32 field indicating the
947    ///      requested fan level. See fan level description above.
948    /// - response `status`
949    ///      ZX_ERR_OUT_OF_RANGE if the requested fan_level is not
950    ///        valid.
951    pub fn r#set_fan_level(
952        &self,
953        mut fan_level: u32,
954    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
955        FanProxyInterface::r#set_fan_level(self, fan_level)
956    }
957}
958
959impl FanProxyInterface for FanProxy {
960    type GetFanLevelResponseFut =
961        fidl::client::QueryResponseFut<(i32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>;
962    fn r#get_fan_level(&self) -> Self::GetFanLevelResponseFut {
963        fn _decode(
964            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
965        ) -> Result<(i32, u32), fidl::Error> {
966            let _response = fidl::client::decode_transaction_body::<
967                FanGetFanLevelResponse,
968                fidl::encoding::DefaultFuchsiaResourceDialect,
969                0x63439dc551ef6dea,
970            >(_buf?)?;
971            Ok((_response.status, _response.fan_level))
972        }
973        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, u32)>(
974            (),
975            0x63439dc551ef6dea,
976            fidl::encoding::DynamicFlags::empty(),
977            _decode,
978        )
979    }
980
981    type SetFanLevelResponseFut =
982        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
983    fn r#set_fan_level(&self, mut fan_level: u32) -> Self::SetFanLevelResponseFut {
984        fn _decode(
985            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
986        ) -> Result<i32, fidl::Error> {
987            let _response = fidl::client::decode_transaction_body::<
988                FanSetFanLevelResponse,
989                fidl::encoding::DefaultFuchsiaResourceDialect,
990                0x6552ae76e9703ffb,
991            >(_buf?)?;
992            Ok(_response.status)
993        }
994        self.client.send_query_and_decode::<FanSetFanLevelRequest, i32>(
995            (fan_level,),
996            0x6552ae76e9703ffb,
997            fidl::encoding::DynamicFlags::empty(),
998            _decode,
999        )
1000    }
1001}
1002
1003pub struct FanEventStream {
1004    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1005}
1006
1007impl std::marker::Unpin for FanEventStream {}
1008
1009impl futures::stream::FusedStream for FanEventStream {
1010    fn is_terminated(&self) -> bool {
1011        self.event_receiver.is_terminated()
1012    }
1013}
1014
1015impl futures::Stream for FanEventStream {
1016    type Item = Result<FanEvent, fidl::Error>;
1017
1018    fn poll_next(
1019        mut self: std::pin::Pin<&mut Self>,
1020        cx: &mut std::task::Context<'_>,
1021    ) -> std::task::Poll<Option<Self::Item>> {
1022        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1023            &mut self.event_receiver,
1024            cx
1025        )?) {
1026            Some(buf) => std::task::Poll::Ready(Some(FanEvent::decode(buf))),
1027            None => std::task::Poll::Ready(None),
1028        }
1029    }
1030}
1031
1032#[derive(Debug)]
1033pub enum FanEvent {}
1034
1035impl FanEvent {
1036    /// Decodes a message buffer as a [`FanEvent`].
1037    fn decode(
1038        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1039    ) -> Result<FanEvent, fidl::Error> {
1040        let (bytes, _handles) = buf.split_mut();
1041        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1042        debug_assert_eq!(tx_header.tx_id, 0);
1043        match tx_header.ordinal {
1044            _ => Err(fidl::Error::UnknownOrdinal {
1045                ordinal: tx_header.ordinal,
1046                protocol_name: <FanMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1047            }),
1048        }
1049    }
1050}
1051
1052/// A Stream of incoming requests for fuchsia.hardware.fan/Fan.
1053pub struct FanRequestStream {
1054    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1055    is_terminated: bool,
1056}
1057
1058impl std::marker::Unpin for FanRequestStream {}
1059
1060impl futures::stream::FusedStream for FanRequestStream {
1061    fn is_terminated(&self) -> bool {
1062        self.is_terminated
1063    }
1064}
1065
1066impl fidl::endpoints::RequestStream for FanRequestStream {
1067    type Protocol = FanMarker;
1068    type ControlHandle = FanControlHandle;
1069
1070    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1071        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1072    }
1073
1074    fn control_handle(&self) -> Self::ControlHandle {
1075        FanControlHandle { inner: self.inner.clone() }
1076    }
1077
1078    fn into_inner(
1079        self,
1080    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1081    {
1082        (self.inner, self.is_terminated)
1083    }
1084
1085    fn from_inner(
1086        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1087        is_terminated: bool,
1088    ) -> Self {
1089        Self { inner, is_terminated }
1090    }
1091}
1092
1093impl futures::Stream for FanRequestStream {
1094    type Item = Result<FanRequest, fidl::Error>;
1095
1096    fn poll_next(
1097        mut self: std::pin::Pin<&mut Self>,
1098        cx: &mut std::task::Context<'_>,
1099    ) -> std::task::Poll<Option<Self::Item>> {
1100        let this = &mut *self;
1101        if this.inner.check_shutdown(cx) {
1102            this.is_terminated = true;
1103            return std::task::Poll::Ready(None);
1104        }
1105        if this.is_terminated {
1106            panic!("polled FanRequestStream after completion");
1107        }
1108        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1109            |bytes, handles| {
1110                match this.inner.channel().read_etc(cx, bytes, handles) {
1111                    std::task::Poll::Ready(Ok(())) => {}
1112                    std::task::Poll::Pending => return std::task::Poll::Pending,
1113                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1114                        this.is_terminated = true;
1115                        return std::task::Poll::Ready(None);
1116                    }
1117                    std::task::Poll::Ready(Err(e)) => {
1118                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1119                            e.into(),
1120                        ))));
1121                    }
1122                }
1123
1124                // A message has been received from the channel
1125                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1126
1127                std::task::Poll::Ready(Some(match header.ordinal {
1128                    0x63439dc551ef6dea => {
1129                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1130                        let mut req = fidl::new_empty!(
1131                            fidl::encoding::EmptyPayload,
1132                            fidl::encoding::DefaultFuchsiaResourceDialect
1133                        );
1134                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1135                        let control_handle = FanControlHandle { inner: this.inner.clone() };
1136                        Ok(FanRequest::GetFanLevel {
1137                            responder: FanGetFanLevelResponder {
1138                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1139                                tx_id: header.tx_id,
1140                            },
1141                        })
1142                    }
1143                    0x6552ae76e9703ffb => {
1144                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1145                        let mut req = fidl::new_empty!(
1146                            FanSetFanLevelRequest,
1147                            fidl::encoding::DefaultFuchsiaResourceDialect
1148                        );
1149                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FanSetFanLevelRequest>(&header, _body_bytes, handles, &mut req)?;
1150                        let control_handle = FanControlHandle { inner: this.inner.clone() };
1151                        Ok(FanRequest::SetFanLevel {
1152                            fan_level: req.fan_level,
1153
1154                            responder: FanSetFanLevelResponder {
1155                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1156                                tx_id: header.tx_id,
1157                            },
1158                        })
1159                    }
1160                    _ => Err(fidl::Error::UnknownOrdinal {
1161                        ordinal: header.ordinal,
1162                        protocol_name: <FanMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1163                    }),
1164                }))
1165            },
1166        )
1167    }
1168}
1169
1170/// Fan: get and set `fan_level`
1171/// `fan_level`: 0 should be the lowest fan state, generally OFF.
1172///              Fan speed increases with `fan_level` and should
1173///              match the `fuchsia.thermal.ClientStateWatcher`
1174///              states for fans, where the states are defined
1175///              in thermal_config.json for each product.
1176///              Thus, the valid values of `fan_level` is
1177///              determined per product according to the
1178///              corresponding config json file.
1179#[derive(Debug)]
1180pub enum FanRequest {
1181    /// Get the current fan level.
1182    /// - response `status`
1183    ///      ZX_ERR_INTERNAL if `fan_level` is not available.
1184    ///        This generally means that `fan_level` has not
1185    ///        been initialized yet or something has gone
1186    ///        terribly wrong.
1187    /// - response `fan_level` a uint32 field indicating the
1188    ///      current fan level. See fan level description above.
1189    GetFanLevel { responder: FanGetFanLevelResponder },
1190    /// Set the fan level.
1191    /// + request `fan_level` a uint32 field indicating the
1192    ///      requested fan level. See fan level description above.
1193    /// - response `status`
1194    ///      ZX_ERR_OUT_OF_RANGE if the requested fan_level is not
1195    ///        valid.
1196    SetFanLevel { fan_level: u32, responder: FanSetFanLevelResponder },
1197}
1198
1199impl FanRequest {
1200    #[allow(irrefutable_let_patterns)]
1201    pub fn into_get_fan_level(self) -> Option<(FanGetFanLevelResponder)> {
1202        if let FanRequest::GetFanLevel { responder } = self { Some((responder)) } else { None }
1203    }
1204
1205    #[allow(irrefutable_let_patterns)]
1206    pub fn into_set_fan_level(self) -> Option<(u32, FanSetFanLevelResponder)> {
1207        if let FanRequest::SetFanLevel { fan_level, responder } = self {
1208            Some((fan_level, responder))
1209        } else {
1210            None
1211        }
1212    }
1213
1214    /// Name of the method defined in FIDL
1215    pub fn method_name(&self) -> &'static str {
1216        match *self {
1217            FanRequest::GetFanLevel { .. } => "get_fan_level",
1218            FanRequest::SetFanLevel { .. } => "set_fan_level",
1219        }
1220    }
1221}
1222
1223#[derive(Debug, Clone)]
1224pub struct FanControlHandle {
1225    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1226}
1227
1228impl fidl::endpoints::ControlHandle for FanControlHandle {
1229    fn shutdown(&self) {
1230        self.inner.shutdown()
1231    }
1232
1233    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1234        self.inner.shutdown_with_epitaph(status)
1235    }
1236
1237    fn is_closed(&self) -> bool {
1238        self.inner.channel().is_closed()
1239    }
1240    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1241        self.inner.channel().on_closed()
1242    }
1243
1244    #[cfg(target_os = "fuchsia")]
1245    fn signal_peer(
1246        &self,
1247        clear_mask: zx::Signals,
1248        set_mask: zx::Signals,
1249    ) -> Result<(), zx_status::Status> {
1250        use fidl::Peered;
1251        self.inner.channel().signal_peer(clear_mask, set_mask)
1252    }
1253}
1254
1255impl FanControlHandle {}
1256
1257#[must_use = "FIDL methods require a response to be sent"]
1258#[derive(Debug)]
1259pub struct FanGetFanLevelResponder {
1260    control_handle: std::mem::ManuallyDrop<FanControlHandle>,
1261    tx_id: u32,
1262}
1263
1264/// Set the the channel to be shutdown (see [`FanControlHandle::shutdown`])
1265/// if the responder is dropped without sending a response, so that the client
1266/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1267impl std::ops::Drop for FanGetFanLevelResponder {
1268    fn drop(&mut self) {
1269        self.control_handle.shutdown();
1270        // Safety: drops once, never accessed again
1271        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1272    }
1273}
1274
1275impl fidl::endpoints::Responder for FanGetFanLevelResponder {
1276    type ControlHandle = FanControlHandle;
1277
1278    fn control_handle(&self) -> &FanControlHandle {
1279        &self.control_handle
1280    }
1281
1282    fn drop_without_shutdown(mut self) {
1283        // Safety: drops once, never accessed again due to mem::forget
1284        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1285        // Prevent Drop from running (which would shut down the channel)
1286        std::mem::forget(self);
1287    }
1288}
1289
1290impl FanGetFanLevelResponder {
1291    /// Sends a response to the FIDL transaction.
1292    ///
1293    /// Sets the channel to shutdown if an error occurs.
1294    pub fn send(self, mut status: i32, mut fan_level: u32) -> Result<(), fidl::Error> {
1295        let _result = self.send_raw(status, fan_level);
1296        if _result.is_err() {
1297            self.control_handle.shutdown();
1298        }
1299        self.drop_without_shutdown();
1300        _result
1301    }
1302
1303    /// Similar to "send" but does not shutdown the channel if an error occurs.
1304    pub fn send_no_shutdown_on_err(
1305        self,
1306        mut status: i32,
1307        mut fan_level: u32,
1308    ) -> Result<(), fidl::Error> {
1309        let _result = self.send_raw(status, fan_level);
1310        self.drop_without_shutdown();
1311        _result
1312    }
1313
1314    fn send_raw(&self, mut status: i32, mut fan_level: u32) -> Result<(), fidl::Error> {
1315        self.control_handle.inner.send::<FanGetFanLevelResponse>(
1316            (status, fan_level),
1317            self.tx_id,
1318            0x63439dc551ef6dea,
1319            fidl::encoding::DynamicFlags::empty(),
1320        )
1321    }
1322}
1323
1324#[must_use = "FIDL methods require a response to be sent"]
1325#[derive(Debug)]
1326pub struct FanSetFanLevelResponder {
1327    control_handle: std::mem::ManuallyDrop<FanControlHandle>,
1328    tx_id: u32,
1329}
1330
1331/// Set the the channel to be shutdown (see [`FanControlHandle::shutdown`])
1332/// if the responder is dropped without sending a response, so that the client
1333/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1334impl std::ops::Drop for FanSetFanLevelResponder {
1335    fn drop(&mut self) {
1336        self.control_handle.shutdown();
1337        // Safety: drops once, never accessed again
1338        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1339    }
1340}
1341
1342impl fidl::endpoints::Responder for FanSetFanLevelResponder {
1343    type ControlHandle = FanControlHandle;
1344
1345    fn control_handle(&self) -> &FanControlHandle {
1346        &self.control_handle
1347    }
1348
1349    fn drop_without_shutdown(mut self) {
1350        // Safety: drops once, never accessed again due to mem::forget
1351        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1352        // Prevent Drop from running (which would shut down the channel)
1353        std::mem::forget(self);
1354    }
1355}
1356
1357impl FanSetFanLevelResponder {
1358    /// Sends a response to the FIDL transaction.
1359    ///
1360    /// Sets the channel to shutdown if an error occurs.
1361    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
1362        let _result = self.send_raw(status);
1363        if _result.is_err() {
1364            self.control_handle.shutdown();
1365        }
1366        self.drop_without_shutdown();
1367        _result
1368    }
1369
1370    /// Similar to "send" but does not shutdown the channel if an error occurs.
1371    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
1372        let _result = self.send_raw(status);
1373        self.drop_without_shutdown();
1374        _result
1375    }
1376
1377    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
1378        self.control_handle.inner.send::<FanSetFanLevelResponse>(
1379            (status,),
1380            self.tx_id,
1381            0x6552ae76e9703ffb,
1382            fidl::encoding::DynamicFlags::empty(),
1383        )
1384    }
1385}
1386
1387#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1388pub struct ServiceMarker;
1389
1390#[cfg(target_os = "fuchsia")]
1391impl fidl::endpoints::ServiceMarker for ServiceMarker {
1392    type Proxy = ServiceProxy;
1393    type Request = ServiceRequest;
1394    const SERVICE_NAME: &'static str = "fuchsia.hardware.fan.Service";
1395}
1396
1397/// A request for one of the member protocols of Service.
1398///
1399#[cfg(target_os = "fuchsia")]
1400pub enum ServiceRequest {
1401    Device(DeviceRequestStream),
1402}
1403
1404#[cfg(target_os = "fuchsia")]
1405impl fidl::endpoints::ServiceRequest for ServiceRequest {
1406    type Service = ServiceMarker;
1407
1408    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1409        match name {
1410            "device" => Self::Device(
1411                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1412            ),
1413            _ => panic!("no such member protocol name for service Service"),
1414        }
1415    }
1416
1417    fn member_names() -> &'static [&'static str] {
1418        &["device"]
1419    }
1420}
1421#[cfg(target_os = "fuchsia")]
1422pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1423
1424#[cfg(target_os = "fuchsia")]
1425impl fidl::endpoints::ServiceProxy for ServiceProxy {
1426    type Service = ServiceMarker;
1427
1428    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1429        Self(opener)
1430    }
1431}
1432
1433#[cfg(target_os = "fuchsia")]
1434impl ServiceProxy {
1435    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1436        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1437        self.connect_channel_to_device(server_end)?;
1438        Ok(proxy)
1439    }
1440
1441    /// Like `connect_to_device`, but returns a sync proxy.
1442    /// See [`Self::connect_to_device`] for more details.
1443    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1444        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1445        self.connect_channel_to_device(server_end)?;
1446        Ok(proxy)
1447    }
1448
1449    /// Like `connect_to_device`, but accepts a server end.
1450    /// See [`Self::connect_to_device`] for more details.
1451    pub fn connect_channel_to_device(
1452        &self,
1453        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1454    ) -> Result<(), fidl::Error> {
1455        self.0.open_member("device", server_end.into_channel())
1456    }
1457
1458    pub fn instance_name(&self) -> &str {
1459        self.0.instance_name()
1460    }
1461}
1462
1463mod internal {
1464    use super::*;
1465}