1#![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 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 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 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 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 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 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 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 pub fn take_event_stream(&self) -> GpioEventStream {
264 GpioEventStream { event_receiver: self.client.take_event_receiver() }
265 }
266
267 pub fn r#read(
270 &self,
271 ) -> fidl::client::QueryResponseFut<GpioReadResult, fidl::encoding::DefaultFuchsiaResourceDialect>
272 {
273 GpioProxyInterface::r#read(self)
274 }
275
276 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 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 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 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: u64,
495 },
496}
497
498impl GpioEvent {
499 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
518pub 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 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#[derive(Debug)]
716pub enum GpioRequest {
717 Read { responder: GpioReadResponder },
720 SetBufferMode { mode: BufferMode, responder: GpioSetBufferModeResponder },
722 GetInterrupt { options: InterruptOptions, responder: GpioGetInterruptResponder },
731 ConfigureInterrupt {
738 config: InterruptConfiguration,
739 responder: GpioConfigureInterruptResponder,
740 },
741 ReleaseInterrupt { responder: GpioReleaseInterruptResponder },
749 #[non_exhaustive]
751 _UnknownMethod {
752 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 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 GpioControlHandle {
827 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
828 self.inner.shutdown_with_epitaph(status.into())
829 }
830}
831
832impl fidl::endpoints::ControlHandle for GpioControlHandle {
833 fn shutdown(&self) {
834 self.inner.shutdown()
835 }
836
837 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
838 self.inner.shutdown_with_epitaph(status)
839 }
840
841 fn is_closed(&self) -> bool {
842 self.inner.channel().is_closed()
843 }
844 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
845 self.inner.channel().on_closed()
846 }
847
848 #[cfg(target_os = "fuchsia")]
849 fn signal_peer(
850 &self,
851 clear_mask: zx::Signals,
852 set_mask: zx::Signals,
853 ) -> Result<(), zx_status::Status> {
854 use fidl::Peered;
855 self.inner.channel().signal_peer(clear_mask, set_mask)
856 }
857}
858
859impl GpioControlHandle {}
860
861#[must_use = "FIDL methods require a response to be sent"]
862#[derive(Debug)]
863pub struct GpioReadResponder {
864 control_handle: std::mem::ManuallyDrop<GpioControlHandle>,
865 tx_id: u32,
866}
867
868impl std::ops::Drop for GpioReadResponder {
872 fn drop(&mut self) {
873 self.control_handle.shutdown();
874 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
876 }
877}
878
879impl fidl::endpoints::Responder for GpioReadResponder {
880 type ControlHandle = GpioControlHandle;
881
882 fn control_handle(&self) -> &GpioControlHandle {
883 &self.control_handle
884 }
885
886 fn drop_without_shutdown(mut self) {
887 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
889 std::mem::forget(self);
891 }
892}
893
894impl GpioReadResponder {
895 pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
899 let _result = self.send_raw(result);
900 if _result.is_err() {
901 self.control_handle.shutdown();
902 }
903 self.drop_without_shutdown();
904 _result
905 }
906
907 pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
909 let _result = self.send_raw(result);
910 self.drop_without_shutdown();
911 _result
912 }
913
914 fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
915 self.control_handle.inner.send::<fidl::encoding::ResultType<GpioReadResponse, i32>>(
916 result.map(|value| (value,)),
917 self.tx_id,
918 0x5fdfe4816ed6a7b0,
919 fidl::encoding::DynamicFlags::empty(),
920 )
921 }
922}
923
924#[must_use = "FIDL methods require a response to be sent"]
925#[derive(Debug)]
926pub struct GpioSetBufferModeResponder {
927 control_handle: std::mem::ManuallyDrop<GpioControlHandle>,
928 tx_id: u32,
929}
930
931impl std::ops::Drop for GpioSetBufferModeResponder {
935 fn drop(&mut self) {
936 self.control_handle.shutdown();
937 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
939 }
940}
941
942impl fidl::endpoints::Responder for GpioSetBufferModeResponder {
943 type ControlHandle = GpioControlHandle;
944
945 fn control_handle(&self) -> &GpioControlHandle {
946 &self.control_handle
947 }
948
949 fn drop_without_shutdown(mut self) {
950 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
952 std::mem::forget(self);
954 }
955}
956
957impl GpioSetBufferModeResponder {
958 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
962 let _result = self.send_raw(result);
963 if _result.is_err() {
964 self.control_handle.shutdown();
965 }
966 self.drop_without_shutdown();
967 _result
968 }
969
970 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
972 let _result = self.send_raw(result);
973 self.drop_without_shutdown();
974 _result
975 }
976
977 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
978 self.control_handle
979 .inner
980 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
981 result,
982 self.tx_id,
983 0x6c766846a5d634c3,
984 fidl::encoding::DynamicFlags::empty(),
985 )
986 }
987}
988
989#[must_use = "FIDL methods require a response to be sent"]
990#[derive(Debug)]
991pub struct GpioGetInterruptResponder {
992 control_handle: std::mem::ManuallyDrop<GpioControlHandle>,
993 tx_id: u32,
994}
995
996impl std::ops::Drop for GpioGetInterruptResponder {
1000 fn drop(&mut self) {
1001 self.control_handle.shutdown();
1002 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1004 }
1005}
1006
1007impl fidl::endpoints::Responder for GpioGetInterruptResponder {
1008 type ControlHandle = GpioControlHandle;
1009
1010 fn control_handle(&self) -> &GpioControlHandle {
1011 &self.control_handle
1012 }
1013
1014 fn drop_without_shutdown(mut self) {
1015 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1017 std::mem::forget(self);
1019 }
1020}
1021
1022impl GpioGetInterruptResponder {
1023 pub fn send(self, mut result: Result<fidl::Interrupt, i32>) -> Result<(), fidl::Error> {
1027 let _result = self.send_raw(result);
1028 if _result.is_err() {
1029 self.control_handle.shutdown();
1030 }
1031 self.drop_without_shutdown();
1032 _result
1033 }
1034
1035 pub fn send_no_shutdown_on_err(
1037 self,
1038 mut result: Result<fidl::Interrupt, i32>,
1039 ) -> Result<(), fidl::Error> {
1040 let _result = self.send_raw(result);
1041 self.drop_without_shutdown();
1042 _result
1043 }
1044
1045 fn send_raw(&self, mut result: Result<fidl::Interrupt, i32>) -> Result<(), fidl::Error> {
1046 self.control_handle.inner.send::<fidl::encoding::ResultType<GpioGetInterruptResponse, i32>>(
1047 result.map(|interrupt| (interrupt,)),
1048 self.tx_id,
1049 0x6638c6b4471c7d05,
1050 fidl::encoding::DynamicFlags::empty(),
1051 )
1052 }
1053}
1054
1055#[must_use = "FIDL methods require a response to be sent"]
1056#[derive(Debug)]
1057pub struct GpioConfigureInterruptResponder {
1058 control_handle: std::mem::ManuallyDrop<GpioControlHandle>,
1059 tx_id: u32,
1060}
1061
1062impl std::ops::Drop for GpioConfigureInterruptResponder {
1066 fn drop(&mut self) {
1067 self.control_handle.shutdown();
1068 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1070 }
1071}
1072
1073impl fidl::endpoints::Responder for GpioConfigureInterruptResponder {
1074 type ControlHandle = GpioControlHandle;
1075
1076 fn control_handle(&self) -> &GpioControlHandle {
1077 &self.control_handle
1078 }
1079
1080 fn drop_without_shutdown(mut self) {
1081 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1083 std::mem::forget(self);
1085 }
1086}
1087
1088impl GpioConfigureInterruptResponder {
1089 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1093 let _result = self.send_raw(result);
1094 if _result.is_err() {
1095 self.control_handle.shutdown();
1096 }
1097 self.drop_without_shutdown();
1098 _result
1099 }
1100
1101 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1103 let _result = self.send_raw(result);
1104 self.drop_without_shutdown();
1105 _result
1106 }
1107
1108 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1109 self.control_handle
1110 .inner
1111 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1112 result,
1113 self.tx_id,
1114 0x65a8a4db7d0f3ca3,
1115 fidl::encoding::DynamicFlags::empty(),
1116 )
1117 }
1118}
1119
1120#[must_use = "FIDL methods require a response to be sent"]
1121#[derive(Debug)]
1122pub struct GpioReleaseInterruptResponder {
1123 control_handle: std::mem::ManuallyDrop<GpioControlHandle>,
1124 tx_id: u32,
1125}
1126
1127impl std::ops::Drop for GpioReleaseInterruptResponder {
1131 fn drop(&mut self) {
1132 self.control_handle.shutdown();
1133 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1135 }
1136}
1137
1138impl fidl::endpoints::Responder for GpioReleaseInterruptResponder {
1139 type ControlHandle = GpioControlHandle;
1140
1141 fn control_handle(&self) -> &GpioControlHandle {
1142 &self.control_handle
1143 }
1144
1145 fn drop_without_shutdown(mut self) {
1146 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1148 std::mem::forget(self);
1150 }
1151}
1152
1153impl GpioReleaseInterruptResponder {
1154 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1158 let _result = self.send_raw(result);
1159 if _result.is_err() {
1160 self.control_handle.shutdown();
1161 }
1162 self.drop_without_shutdown();
1163 _result
1164 }
1165
1166 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1168 let _result = self.send_raw(result);
1169 self.drop_without_shutdown();
1170 _result
1171 }
1172
1173 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1174 self.control_handle
1175 .inner
1176 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1177 result,
1178 self.tx_id,
1179 0x423a4009bfef9946,
1180 fidl::encoding::DynamicFlags::empty(),
1181 )
1182 }
1183}
1184
1185#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1186pub struct ServiceMarker;
1187
1188#[cfg(target_os = "fuchsia")]
1189impl fidl::endpoints::ServiceMarker for ServiceMarker {
1190 type Proxy = ServiceProxy;
1191 type Request = ServiceRequest;
1192 const SERVICE_NAME: &'static str = "fuchsia.hardware.gpio.Service";
1193}
1194
1195#[cfg(target_os = "fuchsia")]
1198pub enum ServiceRequest {
1199 Device(GpioRequestStream),
1200}
1201
1202#[cfg(target_os = "fuchsia")]
1203impl fidl::endpoints::ServiceRequest for ServiceRequest {
1204 type Service = ServiceMarker;
1205
1206 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1207 match name {
1208 "device" => Self::Device(
1209 <GpioRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1210 ),
1211 _ => panic!("no such member protocol name for service Service"),
1212 }
1213 }
1214
1215 fn member_names() -> &'static [&'static str] {
1216 &["device"]
1217 }
1218}
1219#[cfg(target_os = "fuchsia")]
1220pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1221
1222#[cfg(target_os = "fuchsia")]
1223impl fidl::endpoints::ServiceProxy for ServiceProxy {
1224 type Service = ServiceMarker;
1225
1226 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1227 Self(opener)
1228 }
1229}
1230
1231#[cfg(target_os = "fuchsia")]
1232impl ServiceProxy {
1233 pub fn connect_to_device(&self) -> Result<GpioProxy, fidl::Error> {
1234 let (proxy, server_end) = fidl::endpoints::create_proxy::<GpioMarker>();
1235 self.connect_channel_to_device(server_end)?;
1236 Ok(proxy)
1237 }
1238
1239 pub fn connect_to_device_sync(&self) -> Result<GpioSynchronousProxy, fidl::Error> {
1242 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<GpioMarker>();
1243 self.connect_channel_to_device(server_end)?;
1244 Ok(proxy)
1245 }
1246
1247 pub fn connect_channel_to_device(
1250 &self,
1251 server_end: fidl::endpoints::ServerEnd<GpioMarker>,
1252 ) -> Result<(), fidl::Error> {
1253 self.0.open_member("device", server_end.into_channel())
1254 }
1255
1256 pub fn instance_name(&self) -> &str {
1257 self.0.instance_name()
1258 }
1259}
1260
1261mod internal {
1262 use super::*;
1263
1264 impl fidl::encoding::ResourceTypeMarker for GpioGetInterruptResponse {
1265 type Borrowed<'a> = &'a mut Self;
1266 fn take_or_borrow<'a>(
1267 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1268 ) -> Self::Borrowed<'a> {
1269 value
1270 }
1271 }
1272
1273 unsafe impl fidl::encoding::TypeMarker for GpioGetInterruptResponse {
1274 type Owned = Self;
1275
1276 #[inline(always)]
1277 fn inline_align(_context: fidl::encoding::Context) -> usize {
1278 4
1279 }
1280
1281 #[inline(always)]
1282 fn inline_size(_context: fidl::encoding::Context) -> usize {
1283 4
1284 }
1285 }
1286
1287 unsafe impl
1288 fidl::encoding::Encode<
1289 GpioGetInterruptResponse,
1290 fidl::encoding::DefaultFuchsiaResourceDialect,
1291 > for &mut GpioGetInterruptResponse
1292 {
1293 #[inline]
1294 unsafe fn encode(
1295 self,
1296 encoder: &mut fidl::encoding::Encoder<
1297 '_,
1298 fidl::encoding::DefaultFuchsiaResourceDialect,
1299 >,
1300 offset: usize,
1301 _depth: fidl::encoding::Depth,
1302 ) -> fidl::Result<()> {
1303 encoder.debug_check_bounds::<GpioGetInterruptResponse>(offset);
1304 fidl::encoding::Encode::<
1306 GpioGetInterruptResponse,
1307 fidl::encoding::DefaultFuchsiaResourceDialect,
1308 >::encode(
1309 (<fidl::encoding::HandleType<
1310 fidl::Interrupt,
1311 { fidl::ObjectType::INTERRUPT.into_raw() },
1312 2147483648,
1313 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1314 &mut self.interrupt
1315 ),),
1316 encoder,
1317 offset,
1318 _depth,
1319 )
1320 }
1321 }
1322 unsafe impl<
1323 T0: fidl::encoding::Encode<
1324 fidl::encoding::HandleType<
1325 fidl::Interrupt,
1326 { fidl::ObjectType::INTERRUPT.into_raw() },
1327 2147483648,
1328 >,
1329 fidl::encoding::DefaultFuchsiaResourceDialect,
1330 >,
1331 >
1332 fidl::encoding::Encode<
1333 GpioGetInterruptResponse,
1334 fidl::encoding::DefaultFuchsiaResourceDialect,
1335 > for (T0,)
1336 {
1337 #[inline]
1338 unsafe fn encode(
1339 self,
1340 encoder: &mut fidl::encoding::Encoder<
1341 '_,
1342 fidl::encoding::DefaultFuchsiaResourceDialect,
1343 >,
1344 offset: usize,
1345 depth: fidl::encoding::Depth,
1346 ) -> fidl::Result<()> {
1347 encoder.debug_check_bounds::<GpioGetInterruptResponse>(offset);
1348 self.0.encode(encoder, offset + 0, depth)?;
1352 Ok(())
1353 }
1354 }
1355
1356 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1357 for GpioGetInterruptResponse
1358 {
1359 #[inline(always)]
1360 fn new_empty() -> Self {
1361 Self {
1362 interrupt: fidl::new_empty!(fidl::encoding::HandleType<fidl::Interrupt, { fidl::ObjectType::INTERRUPT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1363 }
1364 }
1365
1366 #[inline]
1367 unsafe fn decode(
1368 &mut self,
1369 decoder: &mut fidl::encoding::Decoder<
1370 '_,
1371 fidl::encoding::DefaultFuchsiaResourceDialect,
1372 >,
1373 offset: usize,
1374 _depth: fidl::encoding::Depth,
1375 ) -> fidl::Result<()> {
1376 decoder.debug_check_bounds::<Self>(offset);
1377 fidl::decode!(fidl::encoding::HandleType<fidl::Interrupt, { fidl::ObjectType::INTERRUPT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.interrupt, decoder, offset + 0, _depth)?;
1379 Ok(())
1380 }
1381 }
1382}