Skip to main content

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