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::fuchsia::Status,
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::never::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::never::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::fuchsia::Status,
315 >;
316 }
317
318 impl<___R> ::fidl_next::Respond<___R> for SetBufferMode {
319 type Output = ::core::result::Result<___R, ::fidl_next::never::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::never::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::fuchsia::Status,
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::never::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::never::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::fuchsia::Status,
392 >;
393 }
394
395 impl<___R> ::fidl_next::Respond<___R> for ConfigureInterrupt {
396 type Output = ::core::result::Result<___R, ::fidl_next::never::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::never::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::fuchsia::Status,
428 >;
429 }
430
431 impl<___R> ::fidl_next::Respond<___R> for ReleaseInterrupt {
432 type Output = ::core::result::Result<___R, ::fidl_next::never::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::never::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 mut message: ::fidl_next::Message<___T>,
632 ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
633 match *message.header().ordinal {
634 ordinal => {
635 handler.on_unknown_interaction(ordinal).await;
636 if ::core::matches!(
637 message.header().flexibility(),
638 ::fidl_next::protocol::Flexibility::Strict
639 ) {
640 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
641 } else {
642 Ok(())
643 }
644 }
645 }
646 }
647}
648
649#[diagnostic::on_unimplemented(
650 note = "If {Self} implements the non-local GpioServerHandler trait, use `spawn_as_local` or the `Local` adapter type"
651)]
652
653pub trait GpioLocalServerHandler<
657 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
658 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
659>
660{
661 #[doc = " Reads the current value of a GPIO, returning `true` for a high voltage and `false` for a\n low voltage.\n"]
662 fn read(
663 &mut self,
664
665 responder: ::fidl_next::Responder<gpio::Read, ___T>,
666 ) -> impl ::core::future::Future<Output = ()>;
667
668 #[doc = " Configures the output buffer as per `mode`.\n"]
669 fn set_buffer_mode(
670 &mut self,
671
672 request: ::fidl_next::Request<gpio::SetBufferMode, ___T>,
673
674 responder: ::fidl_next::Responder<gpio::SetBufferMode, ___T>,
675 ) -> impl ::core::future::Future<Output = ()>;
676
677 #[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"]
678 fn get_interrupt(
679 &mut self,
680
681 request: ::fidl_next::Request<gpio::GetInterrupt, ___T>,
682
683 responder: ::fidl_next::Responder<gpio::GetInterrupt, ___T>,
684 ) -> impl ::core::future::Future<Output = ()>;
685
686 #[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"]
687 fn configure_interrupt(
688 &mut self,
689
690 request: ::fidl_next::Request<gpio::ConfigureInterrupt, ___T>,
691
692 responder: ::fidl_next::Responder<gpio::ConfigureInterrupt, ___T>,
693 ) -> impl ::core::future::Future<Output = ()>;
694
695 #[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"]
696 fn release_interrupt(
697 &mut self,
698
699 responder: ::fidl_next::Responder<gpio::ReleaseInterrupt, ___T>,
700 ) -> impl ::core::future::Future<Output = ()>;
701
702 fn on_unknown_interaction(&mut self, ordinal: u64) -> impl ::core::future::Future<Output = ()> {
703 ::core::future::ready(())
704 }
705}
706
707impl<___H, ___T> ::fidl_next::DispatchLocalServerMessage<___H, ___T> for Gpio
708where
709 ___H: GpioLocalServerHandler<___T>,
710 ___T: ::fidl_next::Transport,
711 for<'de> crate::wire::GpioSetBufferModeRequest: ::fidl_next::Decode<
712 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
713 Constraint = (),
714 >,
715 for<'de> crate::wire::GpioGetInterruptRequest: ::fidl_next::Decode<
716 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
717 Constraint = (),
718 >,
719 for<'de> crate::wire::GpioConfigureInterruptRequest<'de>: ::fidl_next::Decode<
720 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
721 Constraint = (),
722 >,
723{
724 async fn on_one_way(
725 handler: &mut ___H,
726 mut message: ::fidl_next::Message<___T>,
727 ) -> ::core::result::Result<
728 (),
729 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
730 > {
731 match *message.header().ordinal {
732 ordinal => {
733 handler.on_unknown_interaction(ordinal).await;
734 if ::core::matches!(
735 message.header().flexibility(),
736 ::fidl_next::protocol::Flexibility::Strict
737 ) {
738 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
739 } else {
740 Ok(())
741 }
742 }
743 }
744 }
745
746 async fn on_two_way(
747 handler: &mut ___H,
748 mut message: ::fidl_next::Message<___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 *message.header().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(message) {
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(message) {
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(message) {
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!(
826 message.header().flexibility(),
827 ::fidl_next::protocol::Flexibility::Strict
828 ) {
829 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
830 } else {
831 responder
832 .respond_framework_error(
833 ordinal,
834 ::fidl_next::FrameworkError::UnknownMethod,
835 )
836 .expect("encoding a framework error should never fail")
837 .await?;
838 Ok(())
839 }
840 }
841 }
842 }
843}
844
845pub trait GpioClientHandler<
849 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
850 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
851>
852{
853 fn on_unknown_interaction(
854 &mut self,
855 ordinal: u64,
856 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send {
857 ::core::future::ready(())
858 }
859}
860
861impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Gpio
862where
863 ___H: GpioClientHandler<___T> + ::core::marker::Send,
864 ___T: ::fidl_next::Transport,
865{
866 async fn on_event(
867 handler: &mut ___H,
868 mut message: ::fidl_next::Message<___T>,
869 ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
870 match *message.header().ordinal {
871 ordinal => {
872 handler.on_unknown_interaction(ordinal).await;
873 if ::core::matches!(
874 message.header().flexibility(),
875 ::fidl_next::protocol::Flexibility::Strict
876 ) {
877 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
878 } else {
879 Ok(())
880 }
881 }
882 }
883 }
884}
885
886pub trait GpioServerHandler<
890 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
891 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
892>
893{
894 #[doc = " Reads the current value of a GPIO, returning `true` for a high voltage and `false` for a\n low voltage.\n"]
895 fn read(
896 &mut self,
897
898 responder: ::fidl_next::Responder<gpio::Read, ___T>,
899 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
900
901 #[doc = " Configures the output buffer as per `mode`.\n"]
902 fn set_buffer_mode(
903 &mut self,
904
905 request: ::fidl_next::Request<gpio::SetBufferMode, ___T>,
906
907 responder: ::fidl_next::Responder<gpio::SetBufferMode, ___T>,
908 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
909
910 #[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"]
911 fn get_interrupt(
912 &mut self,
913
914 request: ::fidl_next::Request<gpio::GetInterrupt, ___T>,
915
916 responder: ::fidl_next::Responder<gpio::GetInterrupt, ___T>,
917 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
918
919 #[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"]
920 fn configure_interrupt(
921 &mut self,
922
923 request: ::fidl_next::Request<gpio::ConfigureInterrupt, ___T>,
924
925 responder: ::fidl_next::Responder<gpio::ConfigureInterrupt, ___T>,
926 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
927
928 #[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"]
929 fn release_interrupt(
930 &mut self,
931
932 responder: ::fidl_next::Responder<gpio::ReleaseInterrupt, ___T>,
933 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
934
935 fn on_unknown_interaction(
936 &mut self,
937 ordinal: u64,
938 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send {
939 ::core::future::ready(())
940 }
941}
942
943impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Gpio
944where
945 ___H: GpioServerHandler<___T> + ::core::marker::Send,
946 ___T: ::fidl_next::Transport,
947 for<'de> crate::wire::GpioSetBufferModeRequest: ::fidl_next::Decode<
948 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
949 Constraint = (),
950 >,
951 for<'de> crate::wire::GpioGetInterruptRequest: ::fidl_next::Decode<
952 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
953 Constraint = (),
954 >,
955 for<'de> crate::wire::GpioConfigureInterruptRequest<'de>: ::fidl_next::Decode<
956 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
957 Constraint = (),
958 >,
959{
960 async fn on_one_way(
961 handler: &mut ___H,
962 mut message: ::fidl_next::Message<___T>,
963 ) -> ::core::result::Result<
964 (),
965 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
966 > {
967 match *message.header().ordinal {
968 ordinal => {
969 handler.on_unknown_interaction(ordinal).await;
970 if ::core::matches!(
971 message.header().flexibility(),
972 ::fidl_next::protocol::Flexibility::Strict
973 ) {
974 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
975 } else {
976 Ok(())
977 }
978 }
979 }
980 }
981
982 async fn on_two_way(
983 handler: &mut ___H,
984 mut message: ::fidl_next::Message<___T>,
985 responder: ::fidl_next::protocol::Responder<___T>,
986 ) -> ::core::result::Result<
987 (),
988 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
989 > {
990 match *message.header().ordinal {
991 6908491597971105712 => {
992 let responder = ::fidl_next::Responder::from_untyped(responder);
993
994 handler.read(responder).await;
995 Ok(())
996 }
997
998 7815548855987352771 => {
999 let responder = ::fidl_next::Responder::from_untyped(responder);
1000
1001 match ::fidl_next::AsDecoderExt::into_decoded(message) {
1002 Ok(decoded) => {
1003 handler
1004 .set_buffer_mode(::fidl_next::Request::from_decoded(decoded), responder)
1005 .await;
1006 Ok(())
1007 }
1008 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
1009 ordinal: 7815548855987352771,
1010 error,
1011 }),
1012 }
1013 }
1014
1015 7365855668153908485 => {
1016 let responder = ::fidl_next::Responder::from_untyped(responder);
1017
1018 match ::fidl_next::AsDecoderExt::into_decoded(message) {
1019 Ok(decoded) => {
1020 handler
1021 .get_interrupt(::fidl_next::Request::from_decoded(decoded), responder)
1022 .await;
1023 Ok(())
1024 }
1025 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
1026 ordinal: 7365855668153908485,
1027 error,
1028 }),
1029 }
1030 }
1031
1032 7325286056521055395 => {
1033 let responder = ::fidl_next::Responder::from_untyped(responder);
1034
1035 match ::fidl_next::AsDecoderExt::into_decoded(message) {
1036 Ok(decoded) => {
1037 handler
1038 .configure_interrupt(
1039 ::fidl_next::Request::from_decoded(decoded),
1040 responder,
1041 )
1042 .await;
1043 Ok(())
1044 }
1045 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
1046 ordinal: 7325286056521055395,
1047 error,
1048 }),
1049 }
1050 }
1051
1052 4772197165771495750 => {
1053 let responder = ::fidl_next::Responder::from_untyped(responder);
1054
1055 handler.release_interrupt(responder).await;
1056 Ok(())
1057 }
1058
1059 ordinal => {
1060 handler.on_unknown_interaction(ordinal).await;
1061 if ::core::matches!(
1062 message.header().flexibility(),
1063 ::fidl_next::protocol::Flexibility::Strict
1064 ) {
1065 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
1066 } else {
1067 responder
1068 .respond_framework_error(
1069 ordinal,
1070 ::fidl_next::FrameworkError::UnknownMethod,
1071 )
1072 .expect("encoding a framework error should never fail")
1073 .await?;
1074 Ok(())
1075 }
1076 }
1077 }
1078 }
1079}
1080
1081impl<___T> GpioClientHandler<___T> for ::fidl_next::IgnoreEvents
1082where
1083 ___T: ::fidl_next::Transport,
1084{
1085 async fn on_unknown_interaction(&mut self, _: u64) {}
1086}
1087
1088impl<___H, ___T> GpioLocalClientHandler<___T> for ::fidl_next::Local<___H>
1089where
1090 ___H: GpioClientHandler<___T>,
1091 ___T: ::fidl_next::Transport,
1092{
1093 async fn on_unknown_interaction(&mut self, ordinal: u64) {
1094 ___H::on_unknown_interaction(&mut self.0, ordinal).await
1095 }
1096}
1097
1098impl<___H, ___T> GpioLocalServerHandler<___T> for ::fidl_next::Local<___H>
1099where
1100 ___H: GpioServerHandler<___T>,
1101 ___T: ::fidl_next::Transport,
1102{
1103 async fn read(&mut self, responder: ::fidl_next::Responder<gpio::Read, ___T>) {
1104 ___H::read(&mut self.0, responder).await
1105 }
1106
1107 async fn set_buffer_mode(
1108 &mut self,
1109
1110 request: ::fidl_next::Request<gpio::SetBufferMode, ___T>,
1111
1112 responder: ::fidl_next::Responder<gpio::SetBufferMode, ___T>,
1113 ) {
1114 ___H::set_buffer_mode(&mut self.0, request, responder).await
1115 }
1116
1117 async fn get_interrupt(
1118 &mut self,
1119
1120 request: ::fidl_next::Request<gpio::GetInterrupt, ___T>,
1121
1122 responder: ::fidl_next::Responder<gpio::GetInterrupt, ___T>,
1123 ) {
1124 ___H::get_interrupt(&mut self.0, request, responder).await
1125 }
1126
1127 async fn configure_interrupt(
1128 &mut self,
1129
1130 request: ::fidl_next::Request<gpio::ConfigureInterrupt, ___T>,
1131
1132 responder: ::fidl_next::Responder<gpio::ConfigureInterrupt, ___T>,
1133 ) {
1134 ___H::configure_interrupt(&mut self.0, request, responder).await
1135 }
1136
1137 async fn release_interrupt(
1138 &mut self,
1139
1140 responder: ::fidl_next::Responder<gpio::ReleaseInterrupt, ___T>,
1141 ) {
1142 ___H::release_interrupt(&mut self.0, responder).await
1143 }
1144
1145 async fn on_unknown_interaction(&mut self, ordinal: u64) {
1146 ___H::on_unknown_interaction(&mut self.0, ordinal).await
1147 }
1148}
1149
1150#[derive(Debug)]
1152pub struct Service;
1153
1154impl ::fidl_next::DiscoverableService for Service {
1155 const SERVICE_NAME: &'static str = "fuchsia.hardware.gpio.Service";
1156 const MEMBER_NAMES: &'static [&'static str] = &["device"];
1157}
1158
1159impl ::fidl_next::HasServiceRequest<::fidl_next::fuchsia::zx::Channel> for Service {}
1160
1161impl<___C> ::fidl_next::Service<___C> for Service
1162where
1163 ___C: ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>,
1164{
1165 type Connector = ServiceConnector<___C>;
1166}
1167
1168#[repr(transparent)]
1170pub struct ServiceConnector<___C> {
1171 #[allow(dead_code)]
1172 connector: ___C,
1173}
1174
1175impl<___C> ServiceConnector<___C>
1176where
1177 ___C: ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>,
1178{
1179 pub fn device(
1181 &self,
1182 server_end: ::fidl_next::ServerEnd<crate::Gpio, ::fidl_next::fuchsia::zx::Channel>,
1183 ) -> ::core::result::Result<
1184 (),
1185 <___C as ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>>::Error,
1186 > {
1187 ::fidl_next::protocol::ServiceConnector::<
1188 ::fidl_next::fuchsia::zx::Channel
1189 >::connect_to_member(
1190 &self.connector,
1191 "device",
1192 server_end.into_untyped(),
1193 )
1194 }
1195}
1196
1197pub trait ServiceHandler {
1199 fn device(
1201 &self,
1202 server_end: ::fidl_next::ServerEnd<crate::Gpio, ::fidl_next::fuchsia::zx::Channel>,
1203 );
1204}
1205
1206impl<___H, ___T> ::fidl_next::DispatchServiceHandler<___H, ___T> for Service
1207where
1208 ___H: ServiceHandler,
1209 ::fidl_next::fuchsia::zx::Channel: ::fidl_next::InstanceFromServiceTransport<___T>,
1210{
1211 fn on_connection(handler: &___H, member: &str, server_end: ___T) {
1212 use ::fidl_next::InstanceFromServiceTransport;
1213 match member {
1214 "device" => handler.device(::fidl_next::ServerEnd::from_untyped(
1215 ::fidl_next::fuchsia::zx::Channel::from_service_transport(server_end),
1216 )),
1217
1218 _ => unreachable!(),
1219 }
1220 }
1221}
1222
1223pub use fidl_next_common_fuchsia_hardware_gpio::*;