1#![warn(clippy::all)]
3#![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)]
4
5pub mod natural {
6
7 pub use fidl_next_common_fuchsia_hardware_gpio::natural::*;
8
9 #[derive(Debug, PartialEq)]
10 #[repr(C)]
11 pub struct GpioGetInterruptResponse {
12 pub interrupt: ::fidl_next::fuchsia::zx::Interrupt,
13 }
14
15 unsafe impl<___E> ::fidl_next::Encode<crate::wire::GpioGetInterruptResponse, ___E>
16 for GpioGetInterruptResponse
17 where
18 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
19 ___E: ::fidl_next::fuchsia::HandleEncoder,
20 {
21 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<
22 Self,
23 crate::wire::GpioGetInterruptResponse,
24 > = unsafe {
25 ::fidl_next::CopyOptimization::enable_if(
26 true && <::fidl_next::fuchsia::zx::Interrupt as ::fidl_next::Encode<
27 ::fidl_next::wire::fuchsia::Interrupt,
28 ___E,
29 >>::COPY_OPTIMIZATION
30 .is_enabled(),
31 )
32 };
33
34 #[inline]
35 fn encode(
36 self,
37 encoder_: &mut ___E,
38 out_: &mut ::core::mem::MaybeUninit<crate::wire::GpioGetInterruptResponse>,
39 _: (),
40 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
41 ::fidl_next::munge! {
42 let crate::wire::GpioGetInterruptResponse {
43 interrupt,
44
45 } = out_;
46 }
47
48 ::fidl_next::Encode::encode(self.interrupt, encoder_, interrupt, ())?;
49
50 let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(interrupt.as_mut_ptr()) };
51
52 Ok(())
53 }
54 }
55
56 unsafe impl<___E>
57 ::fidl_next::EncodeOption<
58 ::fidl_next::wire::Box<'static, crate::wire::GpioGetInterruptResponse>,
59 ___E,
60 > for GpioGetInterruptResponse
61 where
62 ___E: ::fidl_next::Encoder + ?Sized,
63 GpioGetInterruptResponse: ::fidl_next::Encode<crate::wire::GpioGetInterruptResponse, ___E>,
64 {
65 #[inline]
66 fn encode_option(
67 this: ::core::option::Option<Self>,
68 encoder: &mut ___E,
69 out: &mut ::core::mem::MaybeUninit<
70 ::fidl_next::wire::Box<'static, crate::wire::GpioGetInterruptResponse>,
71 >,
72 _: (),
73 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
74 if let Some(inner) = this {
75 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
76 ::fidl_next::wire::Box::encode_present(out);
77 } else {
78 ::fidl_next::wire::Box::encode_absent(out);
79 }
80
81 Ok(())
82 }
83 }
84
85 impl ::fidl_next::FromWire<crate::wire::GpioGetInterruptResponse> for GpioGetInterruptResponse {
86 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<
87 crate::wire::GpioGetInterruptResponse,
88 Self,
89 > = unsafe {
90 ::fidl_next::CopyOptimization::enable_if(
91 true && <::fidl_next::fuchsia::zx::Interrupt as ::fidl_next::FromWire<
92 ::fidl_next::wire::fuchsia::Interrupt,
93 >>::COPY_OPTIMIZATION
94 .is_enabled(),
95 )
96 };
97
98 #[inline]
99 fn from_wire(wire: crate::wire::GpioGetInterruptResponse) -> Self {
100 Self { interrupt: ::fidl_next::FromWire::from_wire(wire.interrupt) }
101 }
102 }
103}
104
105pub mod wire {
106
107 pub use fidl_next_common_fuchsia_hardware_gpio::wire::*;
108
109 #[derive(Debug)]
111 #[repr(C)]
112 pub struct GpioGetInterruptResponse {
113 pub interrupt: ::fidl_next::wire::fuchsia::Interrupt,
114 }
115
116 static_assertions::const_assert_eq!(std::mem::size_of::<GpioGetInterruptResponse>(), 4);
117 static_assertions::const_assert_eq!(std::mem::align_of::<GpioGetInterruptResponse>(), 4);
118
119 static_assertions::const_assert_eq!(
120 std::mem::offset_of!(GpioGetInterruptResponse, interrupt),
121 0
122 );
123
124 impl ::fidl_next::Constrained for GpioGetInterruptResponse {
125 type Constraint = ();
126
127 fn validate(
128 _: ::fidl_next::Slot<'_, Self>,
129 _: Self::Constraint,
130 ) -> Result<(), ::fidl_next::ValidationError> {
131 Ok(())
132 }
133 }
134
135 unsafe impl ::fidl_next::Wire for GpioGetInterruptResponse {
136 type Narrowed<'de> = GpioGetInterruptResponse;
137
138 #[inline]
139 fn zero_padding(out_: &mut ::core::mem::MaybeUninit<Self>) {
140 ::fidl_next::munge! {
141 let Self {
142 interrupt,
143
144 } = &mut *out_;
145 }
146
147 ::fidl_next::Wire::zero_padding(interrupt);
148 }
149 }
150
151 unsafe impl<___D> ::fidl_next::Decode<___D> for GpioGetInterruptResponse
152 where
153 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
154 ___D: ::fidl_next::fuchsia::HandleDecoder,
155 {
156 fn decode(
157 slot_: ::fidl_next::Slot<'_, Self>,
158 decoder_: &mut ___D,
159 _: (),
160 ) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
161 ::fidl_next::munge! {
162 let Self {
163 mut interrupt,
164
165 } = slot_;
166 }
167
168 let _field = interrupt.as_mut();
169
170 ::fidl_next::Decode::decode(interrupt.as_mut(), decoder_, ())?;
171
172 Ok(())
173 }
174 }
175
176 impl ::fidl_next::IntoNatural for GpioGetInterruptResponse {
177 type Natural = crate::natural::GpioGetInterruptResponse;
178 }
179}
180
181pub mod wire_optional {
182
183 pub use fidl_next_common_fuchsia_hardware_gpio::wire_optional::*;
184}
185
186pub mod generic {
187
188 pub use fidl_next_common_fuchsia_hardware_gpio::generic::*;
189
190 pub struct GpioGetInterruptResponse<T0> {
192 pub interrupt: T0,
193 }
194
195 unsafe impl<___E, T0> ::fidl_next::Encode<crate::wire::GpioGetInterruptResponse, ___E>
196 for GpioGetInterruptResponse<T0>
197 where
198 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
199 ___E: ::fidl_next::fuchsia::HandleEncoder,
200 T0: ::fidl_next::Encode<::fidl_next::wire::fuchsia::Interrupt, ___E>,
201 {
202 #[inline]
203 fn encode(
204 self,
205 encoder_: &mut ___E,
206 out_: &mut ::core::mem::MaybeUninit<crate::wire::GpioGetInterruptResponse>,
207 _: (),
208 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
209 ::fidl_next::munge! {
210 let crate::wire::GpioGetInterruptResponse {
211 interrupt,
212
213 } = out_;
214 }
215
216 ::fidl_next::Encode::encode(self.interrupt, encoder_, interrupt, ())?;
217
218 Ok(())
219 }
220 }
221}
222
223pub use self::natural::*;
224
225#[doc = " Common error codes:\n - `ZX_ERR_NOT_SUPPORTED`: The requested operation is not supported by this controller.\n"]
227#[derive(PartialEq, Debug)]
228pub struct Gpio;
229
230#[cfg(target_os = "fuchsia")]
231impl ::fidl_next::HasTransport for Gpio {
232 type Transport = ::fidl_next::fuchsia::zx::Channel;
233}
234
235pub mod gpio {
236 pub mod prelude {
237 pub use crate::{
238 Gpio, GpioClientHandler, GpioLocalClientHandler, GpioLocalServerHandler,
239 GpioServerHandler, gpio,
240 };
241
242 pub use crate::natural::GpioConfigureInterruptRequest;
243
244 pub use crate::natural::GpioGetInterruptRequest;
245
246 pub use crate::natural::GpioSetBufferModeRequest;
247
248 pub use crate::natural::GpioConfigureInterruptResponse;
249
250 pub use crate::natural::GpioGetInterruptResponse;
251
252 pub use crate::natural::GpioReadResponse;
253
254 pub use crate::natural::GpioReleaseInterruptResponse;
255
256 pub use crate::natural::GpioSetBufferModeResponse;
257 }
258
259 pub struct Read;
260
261 impl ::fidl_next::Method for Read {
262 const ORDINAL: u64 = 6908491597971105712;
263 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
264 ::fidl_next::protocol::Flexibility::Strict;
265
266 type Protocol = crate::Gpio;
267
268 type Request = ::fidl_next::wire::EmptyMessageBody;
269 }
270
271 impl ::fidl_next::TwoWayMethod for Read {
272 type Response = ::fidl_next::wire::Result<
273 'static,
274 crate::wire::GpioReadResponse,
275 ::fidl_next::wire::Int32,
276 >;
277 }
278
279 impl<___R> ::fidl_next::Respond<___R> for Read {
280 type Output = ::core::result::Result<
281 crate::generic::GpioReadResponse<___R>,
282 ::fidl_next::util::Never,
283 >;
284
285 fn respond(response: ___R) -> Self::Output {
286 ::core::result::Result::Ok(crate::generic::GpioReadResponse { value: response })
287 }
288 }
289
290 impl<___R> ::fidl_next::RespondErr<___R> for Read {
291 type Output = ::core::result::Result<::fidl_next::util::Never, ___R>;
292
293 fn respond_err(response: ___R) -> Self::Output {
294 ::core::result::Result::Err(response)
295 }
296 }
297
298 pub struct SetBufferMode;
299
300 impl ::fidl_next::Method for SetBufferMode {
301 const ORDINAL: u64 = 7815548855987352771;
302 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
303 ::fidl_next::protocol::Flexibility::Strict;
304
305 type Protocol = crate::Gpio;
306
307 type Request = crate::wire::GpioSetBufferModeRequest;
308 }
309
310 impl ::fidl_next::TwoWayMethod for SetBufferMode {
311 type Response = ::fidl_next::wire::Result<
312 'static,
313 crate::wire::GpioSetBufferModeResponse,
314 ::fidl_next::wire::Int32,
315 >;
316 }
317
318 impl<___R> ::fidl_next::Respond<___R> for SetBufferMode {
319 type Output = ::core::result::Result<___R, ::fidl_next::util::Never>;
320
321 fn respond(response: ___R) -> Self::Output {
322 ::core::result::Result::Ok(response)
323 }
324 }
325
326 impl<___R> ::fidl_next::RespondErr<___R> for SetBufferMode {
327 type Output = ::core::result::Result<::fidl_next::util::Never, ___R>;
328
329 fn respond_err(response: ___R) -> Self::Output {
330 ::core::result::Result::Err(response)
331 }
332 }
333
334 pub struct GetInterrupt;
335
336 impl ::fidl_next::Method for GetInterrupt {
337 const ORDINAL: u64 = 7365855668153908485;
338 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
339 ::fidl_next::protocol::Flexibility::Strict;
340
341 type Protocol = crate::Gpio;
342
343 type Request = crate::wire::GpioGetInterruptRequest;
344 }
345
346 impl ::fidl_next::TwoWayMethod for GetInterrupt {
347 type Response = ::fidl_next::wire::Result<
348 'static,
349 crate::wire::GpioGetInterruptResponse,
350 ::fidl_next::wire::Int32,
351 >;
352 }
353
354 impl<___R> ::fidl_next::Respond<___R> for GetInterrupt {
355 type Output = ::core::result::Result<
356 crate::generic::GpioGetInterruptResponse<___R>,
357 ::fidl_next::util::Never,
358 >;
359
360 fn respond(response: ___R) -> Self::Output {
361 ::core::result::Result::Ok(crate::generic::GpioGetInterruptResponse {
362 interrupt: response,
363 })
364 }
365 }
366
367 impl<___R> ::fidl_next::RespondErr<___R> for GetInterrupt {
368 type Output = ::core::result::Result<::fidl_next::util::Never, ___R>;
369
370 fn respond_err(response: ___R) -> Self::Output {
371 ::core::result::Result::Err(response)
372 }
373 }
374
375 pub struct ConfigureInterrupt;
376
377 impl ::fidl_next::Method for ConfigureInterrupt {
378 const ORDINAL: u64 = 7325286056521055395;
379 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
380 ::fidl_next::protocol::Flexibility::Strict;
381
382 type Protocol = crate::Gpio;
383
384 type Request = crate::wire::GpioConfigureInterruptRequest<'static>;
385 }
386
387 impl ::fidl_next::TwoWayMethod for ConfigureInterrupt {
388 type Response = ::fidl_next::wire::Result<
389 'static,
390 crate::wire::GpioConfigureInterruptResponse,
391 ::fidl_next::wire::Int32,
392 >;
393 }
394
395 impl<___R> ::fidl_next::Respond<___R> for ConfigureInterrupt {
396 type Output = ::core::result::Result<___R, ::fidl_next::util::Never>;
397
398 fn respond(response: ___R) -> Self::Output {
399 ::core::result::Result::Ok(response)
400 }
401 }
402
403 impl<___R> ::fidl_next::RespondErr<___R> for ConfigureInterrupt {
404 type Output = ::core::result::Result<::fidl_next::util::Never, ___R>;
405
406 fn respond_err(response: ___R) -> Self::Output {
407 ::core::result::Result::Err(response)
408 }
409 }
410
411 pub struct ReleaseInterrupt;
412
413 impl ::fidl_next::Method for ReleaseInterrupt {
414 const ORDINAL: u64 = 4772197165771495750;
415 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
416 ::fidl_next::protocol::Flexibility::Strict;
417
418 type Protocol = crate::Gpio;
419
420 type Request = ::fidl_next::wire::EmptyMessageBody;
421 }
422
423 impl ::fidl_next::TwoWayMethod for ReleaseInterrupt {
424 type Response = ::fidl_next::wire::Result<
425 'static,
426 crate::wire::GpioReleaseInterruptResponse,
427 ::fidl_next::wire::Int32,
428 >;
429 }
430
431 impl<___R> ::fidl_next::Respond<___R> for ReleaseInterrupt {
432 type Output = ::core::result::Result<___R, ::fidl_next::util::Never>;
433
434 fn respond(response: ___R) -> Self::Output {
435 ::core::result::Result::Ok(response)
436 }
437 }
438
439 impl<___R> ::fidl_next::RespondErr<___R> for ReleaseInterrupt {
440 type Output = ::core::result::Result<::fidl_next::util::Never, ___R>;
441
442 fn respond_err(response: ___R) -> Self::Output {
443 ::core::result::Result::Err(response)
444 }
445 }
446
447 mod ___detail {
448 unsafe impl<___T> ::fidl_next::HasConnectionHandles<___T> for crate::Gpio
449 where
450 ___T: ::fidl_next::Transport,
451 {
452 type Client = GpioClient<___T>;
453 type Server = GpioServer<___T>;
454 }
455
456 #[repr(transparent)]
458 pub struct GpioClient<___T: ::fidl_next::Transport> {
459 #[allow(dead_code)]
460 client: ::fidl_next::protocol::Client<___T>,
461 }
462
463 impl<___T> GpioClient<___T>
464 where
465 ___T: ::fidl_next::Transport,
466 {
467 #[doc = " Reads the current value of a GPIO, returning `true` for a high voltage and `false` for a\n low voltage.\n"]
468 pub fn read(&self) -> ::fidl_next::TwoWayFuture<'_, super::Read, ___T> {
469 ::fidl_next::TwoWayFuture::from_untyped(
470 self.client.send_two_way::<::fidl_next::wire::EmptyMessageBody>(
471 6908491597971105712,
472 <super::Read as ::fidl_next::Method>::FLEXIBILITY,
473 (),
474 ),
475 )
476 }
477
478 #[doc = " Configures the output buffer as per `mode`.\n"]
479 pub fn set_buffer_mode(
480 &self,
481
482 mode: impl ::fidl_next::Encode<
483 crate::wire::BufferMode,
484 <___T as ::fidl_next::Transport>::SendBuffer,
485 >,
486 ) -> ::fidl_next::TwoWayFuture<'_, super::SetBufferMode, ___T>
487 where
488 <___T as ::fidl_next::Transport>::SendBuffer:
489 ::fidl_next::encoder::InternalHandleEncoder,
490 {
491 self.set_buffer_mode_with(crate::generic::GpioSetBufferModeRequest { mode })
492 }
493
494 #[doc = " Configures the output buffer as per `mode`.\n"]
495 pub fn set_buffer_mode_with<___R>(
496 &self,
497 request: ___R,
498 ) -> ::fidl_next::TwoWayFuture<'_, super::SetBufferMode, ___T>
499 where
500 ___R: ::fidl_next::Encode<
501 crate::wire::GpioSetBufferModeRequest,
502 <___T as ::fidl_next::Transport>::SendBuffer,
503 >,
504 {
505 ::fidl_next::TwoWayFuture::from_untyped(self.client.send_two_way(
506 7815548855987352771,
507 <super::SetBufferMode as ::fidl_next::Method>::FLEXIBILITY,
508 request,
509 ))
510 }
511
512 #[doc = " Gets an interrupt object pertaining to a particular GPIO pin. Only one interrupt may\n be outstanding per pin, and it must be released by calling `ReleaseInterrupt()` before the\n next call to `GetInterrupt()` will succeed. The interrupt is unmasked prior to being\n returned to the caller.\n\n Returns `ZX_ERR_ALREADY_EXISTS` if `GetInterrupt()` has already been called without a\n subsequent call to `ReleaseInterrupt()`, `ZX_ERR_INVALID_ARGS` if `options` is invalid, or\n `ZX_ERR_ACCESS_DENIED` if another client has the interrupt.\n"]
513 pub fn get_interrupt(
514 &self,
515
516 options: impl ::fidl_next::Encode<
517 crate::wire::InterruptOptions,
518 <___T as ::fidl_next::Transport>::SendBuffer,
519 >,
520 ) -> ::fidl_next::TwoWayFuture<'_, super::GetInterrupt, ___T>
521 where
522 <___T as ::fidl_next::Transport>::SendBuffer:
523 ::fidl_next::encoder::InternalHandleEncoder,
524 {
525 self.get_interrupt_with(crate::generic::GpioGetInterruptRequest { options })
526 }
527
528 #[doc = " Gets an interrupt object pertaining to a particular GPIO pin. Only one interrupt may\n be outstanding per pin, and it must be released by calling `ReleaseInterrupt()` before the\n next call to `GetInterrupt()` will succeed. The interrupt is unmasked prior to being\n returned to the caller.\n\n Returns `ZX_ERR_ALREADY_EXISTS` if `GetInterrupt()` has already been called without a\n subsequent call to `ReleaseInterrupt()`, `ZX_ERR_INVALID_ARGS` if `options` is invalid, or\n `ZX_ERR_ACCESS_DENIED` if another client has the interrupt.\n"]
529 pub fn get_interrupt_with<___R>(
530 &self,
531 request: ___R,
532 ) -> ::fidl_next::TwoWayFuture<'_, super::GetInterrupt, ___T>
533 where
534 ___R: ::fidl_next::Encode<
535 crate::wire::GpioGetInterruptRequest,
536 <___T as ::fidl_next::Transport>::SendBuffer,
537 >,
538 {
539 ::fidl_next::TwoWayFuture::from_untyped(self.client.send_two_way(
540 7365855668153908485,
541 <super::GetInterrupt as ::fidl_next::Method>::FLEXIBILITY,
542 request,
543 ))
544 }
545
546 #[doc = " Configures the polarity of an interrupt and whether it is edge- or level-triggered. Only the\n client with the interrupt can call `ConfigureInterrupt()`, unless no client has an\n interrupt.\n\n Returns `ZX_ERR_INVALID_ARGS` if no fields are set in `config`, or `ZX_ERR_ACCESS_DENIED` if\n another client has the interrupt.\n"]
547 pub fn configure_interrupt(
548 &self,
549
550 config: impl ::fidl_next::Encode<
551 crate::wire::InterruptConfiguration<'static>,
552 <___T as ::fidl_next::Transport>::SendBuffer,
553 >,
554 ) -> ::fidl_next::TwoWayFuture<'_, super::ConfigureInterrupt, ___T>
555 where
556 <___T as ::fidl_next::Transport>::SendBuffer:
557 ::fidl_next::encoder::InternalHandleEncoder,
558 <___T as ::fidl_next::Transport>::SendBuffer: ::fidl_next::Encoder,
559 {
560 self.configure_interrupt_with(crate::generic::GpioConfigureInterruptRequest {
561 config,
562 })
563 }
564
565 #[doc = " Configures the polarity of an interrupt and whether it is edge- or level-triggered. Only the\n client with the interrupt can call `ConfigureInterrupt()`, unless no client has an\n interrupt.\n\n Returns `ZX_ERR_INVALID_ARGS` if no fields are set in `config`, or `ZX_ERR_ACCESS_DENIED` if\n another client has the interrupt.\n"]
566 pub fn configure_interrupt_with<___R>(
567 &self,
568 request: ___R,
569 ) -> ::fidl_next::TwoWayFuture<'_, super::ConfigureInterrupt, ___T>
570 where
571 ___R: ::fidl_next::Encode<
572 crate::wire::GpioConfigureInterruptRequest<'static>,
573 <___T as ::fidl_next::Transport>::SendBuffer,
574 >,
575 {
576 ::fidl_next::TwoWayFuture::from_untyped(self.client.send_two_way(
577 7325286056521055395,
578 <super::ConfigureInterrupt as ::fidl_next::Method>::FLEXIBILITY,
579 request,
580 ))
581 }
582
583 #[doc = " Releases the interrupt, allowing `GetInterrupt()` to be called again or by another\n client. A client\'s interrupt is automatically released when it disconnects from the\n server. The interrupt is masked upon release.\n\n Returns `ZX_ERR_NOT_FOUND` if the interrupt has already been released, or if\n `GetInterrupt()` has not been called. Returns `ZX_ERR_ACCESS_DENIED` if another client has\n the interrupt.\n"]
584 pub fn release_interrupt(
585 &self,
586 ) -> ::fidl_next::TwoWayFuture<'_, super::ReleaseInterrupt, ___T> {
587 ::fidl_next::TwoWayFuture::from_untyped(
588 self.client.send_two_way::<::fidl_next::wire::EmptyMessageBody>(
589 4772197165771495750,
590 <super::ReleaseInterrupt as ::fidl_next::Method>::FLEXIBILITY,
591 (),
592 ),
593 )
594 }
595 }
596
597 #[repr(transparent)]
599 pub struct GpioServer<___T: ::fidl_next::Transport> {
600 server: ::fidl_next::protocol::Server<___T>,
601 }
602
603 impl<___T> GpioServer<___T> where ___T: ::fidl_next::Transport {}
604 }
605}
606
607#[diagnostic::on_unimplemented(
608 note = "If {Self} implements the non-local GpioClientHandler trait, use `spawn_as_local` or the `Local` adapter type"
609)]
610
611pub trait GpioLocalClientHandler<
615 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
616 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
617>
618{
619 fn on_unknown_interaction(&mut self, ordinal: u64) -> impl ::core::future::Future<Output = ()> {
620 ::core::future::ready(())
621 }
622}
623
624impl<___H, ___T> ::fidl_next::DispatchLocalClientMessage<___H, ___T> for Gpio
625where
626 ___H: GpioLocalClientHandler<___T>,
627 ___T: ::fidl_next::Transport,
628{
629 async fn on_event(
630 handler: &mut ___H,
631 ordinal: u64,
632 flexibility: ::fidl_next::protocol::Flexibility,
633 body: ::fidl_next::Body<___T>,
634 ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
635 match ordinal {
636 ordinal => {
637 handler.on_unknown_interaction(ordinal).await;
638 if ::core::matches!(flexibility, ::fidl_next::protocol::Flexibility::Strict) {
639 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
640 } else {
641 Ok(())
642 }
643 }
644 }
645 }
646}
647
648#[diagnostic::on_unimplemented(
649 note = "If {Self} implements the non-local GpioServerHandler trait, use `spawn_as_local` or the `Local` adapter type"
650)]
651
652pub trait GpioLocalServerHandler<
656 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
657 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
658>
659{
660 #[doc = " Reads the current value of a GPIO, returning `true` for a high voltage and `false` for a\n low voltage.\n"]
661 fn read(
662 &mut self,
663
664 responder: ::fidl_next::Responder<gpio::Read, ___T>,
665 ) -> impl ::core::future::Future<Output = ()>;
666
667 #[doc = " Configures the output buffer as per `mode`.\n"]
668 fn set_buffer_mode(
669 &mut self,
670
671 request: ::fidl_next::Request<gpio::SetBufferMode, ___T>,
672
673 responder: ::fidl_next::Responder<gpio::SetBufferMode, ___T>,
674 ) -> impl ::core::future::Future<Output = ()>;
675
676 #[doc = " Gets an interrupt object pertaining to a particular GPIO pin. Only one interrupt may\n be outstanding per pin, and it must be released by calling `ReleaseInterrupt()` before the\n next call to `GetInterrupt()` will succeed. The interrupt is unmasked prior to being\n returned to the caller.\n\n Returns `ZX_ERR_ALREADY_EXISTS` if `GetInterrupt()` has already been called without a\n subsequent call to `ReleaseInterrupt()`, `ZX_ERR_INVALID_ARGS` if `options` is invalid, or\n `ZX_ERR_ACCESS_DENIED` if another client has the interrupt.\n"]
677 fn get_interrupt(
678 &mut self,
679
680 request: ::fidl_next::Request<gpio::GetInterrupt, ___T>,
681
682 responder: ::fidl_next::Responder<gpio::GetInterrupt, ___T>,
683 ) -> impl ::core::future::Future<Output = ()>;
684
685 #[doc = " Configures the polarity of an interrupt and whether it is edge- or level-triggered. Only the\n client with the interrupt can call `ConfigureInterrupt()`, unless no client has an\n interrupt.\n\n Returns `ZX_ERR_INVALID_ARGS` if no fields are set in `config`, or `ZX_ERR_ACCESS_DENIED` if\n another client has the interrupt.\n"]
686 fn configure_interrupt(
687 &mut self,
688
689 request: ::fidl_next::Request<gpio::ConfigureInterrupt, ___T>,
690
691 responder: ::fidl_next::Responder<gpio::ConfigureInterrupt, ___T>,
692 ) -> impl ::core::future::Future<Output = ()>;
693
694 #[doc = " Releases the interrupt, allowing `GetInterrupt()` to be called again or by another\n client. A client\'s interrupt is automatically released when it disconnects from the\n server. The interrupt is masked upon release.\n\n Returns `ZX_ERR_NOT_FOUND` if the interrupt has already been released, or if\n `GetInterrupt()` has not been called. Returns `ZX_ERR_ACCESS_DENIED` if another client has\n the interrupt.\n"]
695 fn release_interrupt(
696 &mut self,
697
698 responder: ::fidl_next::Responder<gpio::ReleaseInterrupt, ___T>,
699 ) -> impl ::core::future::Future<Output = ()>;
700
701 fn on_unknown_interaction(&mut self, ordinal: u64) -> impl ::core::future::Future<Output = ()> {
702 ::core::future::ready(())
703 }
704}
705
706impl<___H, ___T> ::fidl_next::DispatchLocalServerMessage<___H, ___T> for Gpio
707where
708 ___H: GpioLocalServerHandler<___T>,
709 ___T: ::fidl_next::Transport,
710 for<'de> crate::wire::GpioSetBufferModeRequest: ::fidl_next::Decode<
711 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
712 Constraint = (),
713 >,
714 for<'de> crate::wire::GpioGetInterruptRequest: ::fidl_next::Decode<
715 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
716 Constraint = (),
717 >,
718 for<'de> crate::wire::GpioConfigureInterruptRequest<'de>: ::fidl_next::Decode<
719 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
720 Constraint = (),
721 >,
722{
723 async fn on_one_way(
724 handler: &mut ___H,
725 ordinal: u64,
726 flexibility: ::fidl_next::protocol::Flexibility,
727 body: ::fidl_next::Body<___T>,
728 ) -> ::core::result::Result<
729 (),
730 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
731 > {
732 match ordinal {
733 ordinal => {
734 handler.on_unknown_interaction(ordinal).await;
735 if ::core::matches!(flexibility, ::fidl_next::protocol::Flexibility::Strict) {
736 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
737 } else {
738 Ok(())
739 }
740 }
741 }
742 }
743
744 async fn on_two_way(
745 handler: &mut ___H,
746 ordinal: u64,
747 flexibility: ::fidl_next::protocol::Flexibility,
748 body: ::fidl_next::Body<___T>,
749 responder: ::fidl_next::protocol::Responder<___T>,
750 ) -> ::core::result::Result<
751 (),
752 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
753 > {
754 match ordinal {
755 6908491597971105712 => {
756 let responder = ::fidl_next::Responder::from_untyped(responder);
757
758 handler.read(responder).await;
759 Ok(())
760 }
761
762 7815548855987352771 => {
763 let responder = ::fidl_next::Responder::from_untyped(responder);
764
765 match ::fidl_next::AsDecoderExt::into_decoded(body) {
766 Ok(decoded) => {
767 handler
768 .set_buffer_mode(::fidl_next::Request::from_decoded(decoded), responder)
769 .await;
770 Ok(())
771 }
772 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
773 ordinal: 7815548855987352771,
774 error,
775 }),
776 }
777 }
778
779 7365855668153908485 => {
780 let responder = ::fidl_next::Responder::from_untyped(responder);
781
782 match ::fidl_next::AsDecoderExt::into_decoded(body) {
783 Ok(decoded) => {
784 handler
785 .get_interrupt(::fidl_next::Request::from_decoded(decoded), responder)
786 .await;
787 Ok(())
788 }
789 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
790 ordinal: 7365855668153908485,
791 error,
792 }),
793 }
794 }
795
796 7325286056521055395 => {
797 let responder = ::fidl_next::Responder::from_untyped(responder);
798
799 match ::fidl_next::AsDecoderExt::into_decoded(body) {
800 Ok(decoded) => {
801 handler
802 .configure_interrupt(
803 ::fidl_next::Request::from_decoded(decoded),
804 responder,
805 )
806 .await;
807 Ok(())
808 }
809 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
810 ordinal: 7325286056521055395,
811 error,
812 }),
813 }
814 }
815
816 4772197165771495750 => {
817 let responder = ::fidl_next::Responder::from_untyped(responder);
818
819 handler.release_interrupt(responder).await;
820 Ok(())
821 }
822
823 ordinal => {
824 handler.on_unknown_interaction(ordinal).await;
825 if ::core::matches!(flexibility, ::fidl_next::protocol::Flexibility::Strict) {
826 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
827 } else {
828 responder.respond::<::fidl_next::wire::Flexible<'_, ::fidl_next::wire::EmptyMessageBody>>(
829 ordinal,
830 flexibility,
831 ::fidl_next::Flexible::<::fidl_next::util::Never>::FrameworkErr(::fidl_next::FrameworkError::UnknownMethod),
832 )
833 .expect("encoding a framework error should never fail")
834 .await?;
835 Ok(())
836 }
837 }
838 }
839 }
840}
841
842pub trait GpioClientHandler<
846 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
847 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
848>
849{
850 fn on_unknown_interaction(
851 &mut self,
852 ordinal: u64,
853 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send {
854 ::core::future::ready(())
855 }
856}
857
858impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Gpio
859where
860 ___H: GpioClientHandler<___T> + ::core::marker::Send,
861 ___T: ::fidl_next::Transport,
862{
863 async fn on_event(
864 handler: &mut ___H,
865 ordinal: u64,
866 flexibility: ::fidl_next::protocol::Flexibility,
867 body: ::fidl_next::Body<___T>,
868 ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
869 match ordinal {
870 ordinal => {
871 handler.on_unknown_interaction(ordinal).await;
872 if ::core::matches!(flexibility, ::fidl_next::protocol::Flexibility::Strict) {
873 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
874 } else {
875 Ok(())
876 }
877 }
878 }
879 }
880}
881
882pub trait GpioServerHandler<
886 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
887 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
888>
889{
890 #[doc = " Reads the current value of a GPIO, returning `true` for a high voltage and `false` for a\n low voltage.\n"]
891 fn read(
892 &mut self,
893
894 responder: ::fidl_next::Responder<gpio::Read, ___T>,
895 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
896
897 #[doc = " Configures the output buffer as per `mode`.\n"]
898 fn set_buffer_mode(
899 &mut self,
900
901 request: ::fidl_next::Request<gpio::SetBufferMode, ___T>,
902
903 responder: ::fidl_next::Responder<gpio::SetBufferMode, ___T>,
904 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
905
906 #[doc = " Gets an interrupt object pertaining to a particular GPIO pin. Only one interrupt may\n be outstanding per pin, and it must be released by calling `ReleaseInterrupt()` before the\n next call to `GetInterrupt()` will succeed. The interrupt is unmasked prior to being\n returned to the caller.\n\n Returns `ZX_ERR_ALREADY_EXISTS` if `GetInterrupt()` has already been called without a\n subsequent call to `ReleaseInterrupt()`, `ZX_ERR_INVALID_ARGS` if `options` is invalid, or\n `ZX_ERR_ACCESS_DENIED` if another client has the interrupt.\n"]
907 fn get_interrupt(
908 &mut self,
909
910 request: ::fidl_next::Request<gpio::GetInterrupt, ___T>,
911
912 responder: ::fidl_next::Responder<gpio::GetInterrupt, ___T>,
913 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
914
915 #[doc = " Configures the polarity of an interrupt and whether it is edge- or level-triggered. Only the\n client with the interrupt can call `ConfigureInterrupt()`, unless no client has an\n interrupt.\n\n Returns `ZX_ERR_INVALID_ARGS` if no fields are set in `config`, or `ZX_ERR_ACCESS_DENIED` if\n another client has the interrupt.\n"]
916 fn configure_interrupt(
917 &mut self,
918
919 request: ::fidl_next::Request<gpio::ConfigureInterrupt, ___T>,
920
921 responder: ::fidl_next::Responder<gpio::ConfigureInterrupt, ___T>,
922 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
923
924 #[doc = " Releases the interrupt, allowing `GetInterrupt()` to be called again or by another\n client. A client\'s interrupt is automatically released when it disconnects from the\n server. The interrupt is masked upon release.\n\n Returns `ZX_ERR_NOT_FOUND` if the interrupt has already been released, or if\n `GetInterrupt()` has not been called. Returns `ZX_ERR_ACCESS_DENIED` if another client has\n the interrupt.\n"]
925 fn release_interrupt(
926 &mut self,
927
928 responder: ::fidl_next::Responder<gpio::ReleaseInterrupt, ___T>,
929 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
930
931 fn on_unknown_interaction(
932 &mut self,
933 ordinal: u64,
934 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send {
935 ::core::future::ready(())
936 }
937}
938
939impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Gpio
940where
941 ___H: GpioServerHandler<___T> + ::core::marker::Send,
942 ___T: ::fidl_next::Transport,
943 for<'de> crate::wire::GpioSetBufferModeRequest: ::fidl_next::Decode<
944 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
945 Constraint = (),
946 >,
947 for<'de> crate::wire::GpioGetInterruptRequest: ::fidl_next::Decode<
948 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
949 Constraint = (),
950 >,
951 for<'de> crate::wire::GpioConfigureInterruptRequest<'de>: ::fidl_next::Decode<
952 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
953 Constraint = (),
954 >,
955{
956 async fn on_one_way(
957 handler: &mut ___H,
958 ordinal: u64,
959 flexibility: ::fidl_next::protocol::Flexibility,
960 body: ::fidl_next::Body<___T>,
961 ) -> ::core::result::Result<
962 (),
963 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
964 > {
965 match ordinal {
966 ordinal => {
967 handler.on_unknown_interaction(ordinal).await;
968 if ::core::matches!(flexibility, ::fidl_next::protocol::Flexibility::Strict) {
969 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
970 } else {
971 Ok(())
972 }
973 }
974 }
975 }
976
977 async fn on_two_way(
978 handler: &mut ___H,
979 ordinal: u64,
980 flexibility: ::fidl_next::protocol::Flexibility,
981 body: ::fidl_next::Body<___T>,
982 responder: ::fidl_next::protocol::Responder<___T>,
983 ) -> ::core::result::Result<
984 (),
985 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
986 > {
987 match ordinal {
988 6908491597971105712 => {
989 let responder = ::fidl_next::Responder::from_untyped(responder);
990
991 handler.read(responder).await;
992 Ok(())
993 }
994
995 7815548855987352771 => {
996 let responder = ::fidl_next::Responder::from_untyped(responder);
997
998 match ::fidl_next::AsDecoderExt::into_decoded(body) {
999 Ok(decoded) => {
1000 handler
1001 .set_buffer_mode(::fidl_next::Request::from_decoded(decoded), responder)
1002 .await;
1003 Ok(())
1004 }
1005 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
1006 ordinal: 7815548855987352771,
1007 error,
1008 }),
1009 }
1010 }
1011
1012 7365855668153908485 => {
1013 let responder = ::fidl_next::Responder::from_untyped(responder);
1014
1015 match ::fidl_next::AsDecoderExt::into_decoded(body) {
1016 Ok(decoded) => {
1017 handler
1018 .get_interrupt(::fidl_next::Request::from_decoded(decoded), responder)
1019 .await;
1020 Ok(())
1021 }
1022 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
1023 ordinal: 7365855668153908485,
1024 error,
1025 }),
1026 }
1027 }
1028
1029 7325286056521055395 => {
1030 let responder = ::fidl_next::Responder::from_untyped(responder);
1031
1032 match ::fidl_next::AsDecoderExt::into_decoded(body) {
1033 Ok(decoded) => {
1034 handler
1035 .configure_interrupt(
1036 ::fidl_next::Request::from_decoded(decoded),
1037 responder,
1038 )
1039 .await;
1040 Ok(())
1041 }
1042 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
1043 ordinal: 7325286056521055395,
1044 error,
1045 }),
1046 }
1047 }
1048
1049 4772197165771495750 => {
1050 let responder = ::fidl_next::Responder::from_untyped(responder);
1051
1052 handler.release_interrupt(responder).await;
1053 Ok(())
1054 }
1055
1056 ordinal => {
1057 handler.on_unknown_interaction(ordinal).await;
1058 if ::core::matches!(flexibility, ::fidl_next::protocol::Flexibility::Strict) {
1059 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
1060 } else {
1061 responder.respond::<::fidl_next::wire::Flexible<'_, ::fidl_next::wire::EmptyMessageBody>>(
1062 ordinal,
1063 flexibility,
1064 ::fidl_next::Flexible::<::fidl_next::util::Never>::FrameworkErr(::fidl_next::FrameworkError::UnknownMethod),
1065 )
1066 .expect("encoding a framework error should never fail")
1067 .await?;
1068 Ok(())
1069 }
1070 }
1071 }
1072 }
1073}
1074
1075impl<___T> GpioClientHandler<___T> for ::fidl_next::IgnoreEvents
1076where
1077 ___T: ::fidl_next::Transport,
1078{
1079 async fn on_unknown_interaction(&mut self, _: u64) {}
1080}
1081
1082impl<___H, ___T> GpioLocalClientHandler<___T> for ::fidl_next::Local<___H>
1083where
1084 ___H: GpioClientHandler<___T>,
1085 ___T: ::fidl_next::Transport,
1086{
1087 async fn on_unknown_interaction(&mut self, ordinal: u64) {
1088 ___H::on_unknown_interaction(&mut self.0, ordinal).await
1089 }
1090}
1091
1092impl<___H, ___T> GpioLocalServerHandler<___T> for ::fidl_next::Local<___H>
1093where
1094 ___H: GpioServerHandler<___T>,
1095 ___T: ::fidl_next::Transport,
1096{
1097 async fn read(&mut self, responder: ::fidl_next::Responder<gpio::Read, ___T>) {
1098 ___H::read(&mut self.0, responder).await
1099 }
1100
1101 async fn set_buffer_mode(
1102 &mut self,
1103
1104 request: ::fidl_next::Request<gpio::SetBufferMode, ___T>,
1105
1106 responder: ::fidl_next::Responder<gpio::SetBufferMode, ___T>,
1107 ) {
1108 ___H::set_buffer_mode(&mut self.0, request, responder).await
1109 }
1110
1111 async fn get_interrupt(
1112 &mut self,
1113
1114 request: ::fidl_next::Request<gpio::GetInterrupt, ___T>,
1115
1116 responder: ::fidl_next::Responder<gpio::GetInterrupt, ___T>,
1117 ) {
1118 ___H::get_interrupt(&mut self.0, request, responder).await
1119 }
1120
1121 async fn configure_interrupt(
1122 &mut self,
1123
1124 request: ::fidl_next::Request<gpio::ConfigureInterrupt, ___T>,
1125
1126 responder: ::fidl_next::Responder<gpio::ConfigureInterrupt, ___T>,
1127 ) {
1128 ___H::configure_interrupt(&mut self.0, request, responder).await
1129 }
1130
1131 async fn release_interrupt(
1132 &mut self,
1133
1134 responder: ::fidl_next::Responder<gpio::ReleaseInterrupt, ___T>,
1135 ) {
1136 ___H::release_interrupt(&mut self.0, responder).await
1137 }
1138
1139 async fn on_unknown_interaction(&mut self, ordinal: u64) {
1140 ___H::on_unknown_interaction(&mut self.0, ordinal).await
1141 }
1142}
1143
1144#[derive(Debug)]
1146pub struct Service;
1147
1148impl ::fidl_next::DiscoverableService for Service {
1149 const SERVICE_NAME: &'static str = "fuchsia.hardware.gpio.Service";
1150 const MEMBER_NAMES: &'static [&'static str] = &["device"];
1151}
1152
1153impl ::fidl_next::HasServiceRequest<::fidl_next::fuchsia::zx::Channel> for Service {}
1154
1155impl<___C> ::fidl_next::Service<___C> for Service
1156where
1157 ___C: ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>,
1158{
1159 type Connector = ServiceConnector<___C>;
1160}
1161
1162#[repr(transparent)]
1164pub struct ServiceConnector<___C> {
1165 #[allow(dead_code)]
1166 connector: ___C,
1167}
1168
1169impl<___C> ServiceConnector<___C>
1170where
1171 ___C: ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>,
1172{
1173 pub fn device(
1175 &self,
1176 server_end: ::fidl_next::ServerEnd<crate::Gpio, ::fidl_next::fuchsia::zx::Channel>,
1177 ) -> ::core::result::Result<
1178 (),
1179 <___C as ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>>::Error,
1180 > {
1181 ::fidl_next::protocol::ServiceConnector::<
1182 ::fidl_next::fuchsia::zx::Channel
1183 >::connect_to_member(
1184 &self.connector,
1185 "device",
1186 server_end.into_untyped(),
1187 )
1188 }
1189}
1190
1191pub trait ServiceHandler {
1193 fn device(
1195 &self,
1196 server_end: ::fidl_next::ServerEnd<crate::Gpio, ::fidl_next::fuchsia::zx::Channel>,
1197 );
1198}
1199
1200impl<___H, ___T> ::fidl_next::DispatchServiceHandler<___H, ___T> for Service
1201where
1202 ___H: ServiceHandler,
1203 ::fidl_next::fuchsia::zx::Channel: ::fidl_next::InstanceFromServiceTransport<___T>,
1204{
1205 fn on_connection(handler: &___H, member: &str, server_end: ___T) {
1206 use ::fidl_next::InstanceFromServiceTransport;
1207 match member {
1208 "device" => handler.device(::fidl_next::ServerEnd::from_untyped(
1209 ::fidl_next::fuchsia::zx::Channel::from_service_transport(server_end),
1210 )),
1211
1212 _ => unreachable!(),
1213 }
1214 }
1215}
1216
1217pub use fidl_next_common_fuchsia_hardware_gpio::*;