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 unsafe impl<'a, ___E, T0> ::fidl_next::Encode<crate::wire::GpioGetInterruptResponse, ___E>
223 for &'a GpioGetInterruptResponse<T0>
224 where
225 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
226 ___E: ::fidl_next::fuchsia::HandleEncoder,
227 &'a T0: ::fidl_next::Encode<::fidl_next::wire::fuchsia::Interrupt, ___E>,
228 {
229 #[inline]
230 fn encode(
231 self,
232 encoder_: &mut ___E,
233 out_: &mut ::core::mem::MaybeUninit<crate::wire::GpioGetInterruptResponse>,
234 _: (),
235 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
236 ::fidl_next::munge! {
237 let crate::wire::GpioGetInterruptResponse {
238 interrupt,
239
240 } = out_;
241 }
242
243 ::fidl_next::Encode::encode(&self.interrupt, encoder_, interrupt, ())?;
244
245 Ok(())
246 }
247 }
248}
249
250pub use self::natural::*;
251
252#[doc = " Common error codes:\n - `ZX_ERR_NOT_SUPPORTED`: The requested operation is not supported by this controller.\n"]
254#[derive(PartialEq, Debug)]
255pub struct Gpio;
256
257#[cfg(target_os = "fuchsia")]
258impl ::fidl_next::HasTransport for Gpio {
259 type Transport = ::fidl_next::fuchsia::zx::Channel;
260}
261
262pub mod gpio {
263 pub mod prelude {
264 pub use crate::{
265 Gpio, GpioClientHandler, GpioLocalClientHandler, GpioLocalServerHandler,
266 GpioServerHandler, gpio,
267 };
268
269 pub use crate::natural::GpioConfigureInterruptRequest;
270
271 pub use crate::natural::GpioGetInterruptRequest;
272
273 pub use crate::natural::GpioSetBufferModeRequest;
274
275 pub use crate::natural::GpioConfigureInterruptResponse;
276
277 pub use crate::natural::GpioGetInterruptResponse;
278
279 pub use crate::natural::GpioReadResponse;
280
281 pub use crate::natural::GpioReleaseInterruptResponse;
282
283 pub use crate::natural::GpioSetBufferModeResponse;
284 }
285
286 pub struct Read;
287
288 impl ::fidl_next::Method for Read {
289 const ORDINAL: u64 = 6908491597971105712;
290 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
291 ::fidl_next::protocol::Flexibility::Strict;
292
293 type Protocol = crate::Gpio;
294
295 type Request = ::fidl_next::wire::EmptyMessageBody;
296 }
297
298 impl ::fidl_next::TwoWayMethod for Read {
299 type Response = ::fidl_next::wire::Result<
300 'static,
301 crate::wire::GpioReadResponse,
302 ::fidl_next::wire::fuchsia::Status,
303 >;
304 }
305
306 impl<___R> ::fidl_next::Respond<___R> for Read {
307 type Output = ::core::result::Result<
308 crate::generic::GpioReadResponse<___R>,
309 ::fidl_next::never::Never,
310 >;
311
312 fn respond(response: ___R) -> Self::Output {
313 ::core::result::Result::Ok(crate::generic::GpioReadResponse { value: response })
314 }
315 }
316
317 impl<___R> ::fidl_next::RespondErr<___R> for Read {
318 type Output = ::core::result::Result<::fidl_next::never::Never, ___R>;
319
320 fn respond_err(response: ___R) -> Self::Output {
321 ::core::result::Result::Err(response)
322 }
323 }
324
325 pub struct SetBufferMode;
326
327 impl ::fidl_next::Method for SetBufferMode {
328 const ORDINAL: u64 = 7815548855987352771;
329 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
330 ::fidl_next::protocol::Flexibility::Strict;
331
332 type Protocol = crate::Gpio;
333
334 type Request = crate::wire::GpioSetBufferModeRequest;
335 }
336
337 impl ::fidl_next::TwoWayMethod for SetBufferMode {
338 type Response = ::fidl_next::wire::Result<
339 'static,
340 crate::wire::GpioSetBufferModeResponse,
341 ::fidl_next::wire::fuchsia::Status,
342 >;
343 }
344
345 impl<___R> ::fidl_next::Respond<___R> for SetBufferMode {
346 type Output = ::core::result::Result<___R, ::fidl_next::never::Never>;
347
348 fn respond(response: ___R) -> Self::Output {
349 ::core::result::Result::Ok(response)
350 }
351 }
352
353 impl<___R> ::fidl_next::RespondErr<___R> for SetBufferMode {
354 type Output = ::core::result::Result<::fidl_next::never::Never, ___R>;
355
356 fn respond_err(response: ___R) -> Self::Output {
357 ::core::result::Result::Err(response)
358 }
359 }
360
361 pub struct GetInterrupt;
362
363 impl ::fidl_next::Method for GetInterrupt {
364 const ORDINAL: u64 = 7365855668153908485;
365 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
366 ::fidl_next::protocol::Flexibility::Strict;
367
368 type Protocol = crate::Gpio;
369
370 type Request = crate::wire::GpioGetInterruptRequest;
371 }
372
373 impl ::fidl_next::TwoWayMethod for GetInterrupt {
374 type Response = ::fidl_next::wire::Result<
375 'static,
376 crate::wire::GpioGetInterruptResponse,
377 ::fidl_next::wire::fuchsia::Status,
378 >;
379 }
380
381 impl<___R> ::fidl_next::Respond<___R> for GetInterrupt {
382 type Output = ::core::result::Result<
383 crate::generic::GpioGetInterruptResponse<___R>,
384 ::fidl_next::never::Never,
385 >;
386
387 fn respond(response: ___R) -> Self::Output {
388 ::core::result::Result::Ok(crate::generic::GpioGetInterruptResponse {
389 interrupt: response,
390 })
391 }
392 }
393
394 impl<___R> ::fidl_next::RespondErr<___R> for GetInterrupt {
395 type Output = ::core::result::Result<::fidl_next::never::Never, ___R>;
396
397 fn respond_err(response: ___R) -> Self::Output {
398 ::core::result::Result::Err(response)
399 }
400 }
401
402 pub struct ConfigureInterrupt;
403
404 impl ::fidl_next::Method for ConfigureInterrupt {
405 const ORDINAL: u64 = 7325286056521055395;
406 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
407 ::fidl_next::protocol::Flexibility::Strict;
408
409 type Protocol = crate::Gpio;
410
411 type Request = crate::wire::GpioConfigureInterruptRequest<'static>;
412 }
413
414 impl ::fidl_next::TwoWayMethod for ConfigureInterrupt {
415 type Response = ::fidl_next::wire::Result<
416 'static,
417 crate::wire::GpioConfigureInterruptResponse,
418 ::fidl_next::wire::fuchsia::Status,
419 >;
420 }
421
422 impl<___R> ::fidl_next::Respond<___R> for ConfigureInterrupt {
423 type Output = ::core::result::Result<___R, ::fidl_next::never::Never>;
424
425 fn respond(response: ___R) -> Self::Output {
426 ::core::result::Result::Ok(response)
427 }
428 }
429
430 impl<___R> ::fidl_next::RespondErr<___R> for ConfigureInterrupt {
431 type Output = ::core::result::Result<::fidl_next::never::Never, ___R>;
432
433 fn respond_err(response: ___R) -> Self::Output {
434 ::core::result::Result::Err(response)
435 }
436 }
437
438 pub struct ReleaseInterrupt;
439
440 impl ::fidl_next::Method for ReleaseInterrupt {
441 const ORDINAL: u64 = 4772197165771495750;
442 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
443 ::fidl_next::protocol::Flexibility::Strict;
444
445 type Protocol = crate::Gpio;
446
447 type Request = ::fidl_next::wire::EmptyMessageBody;
448 }
449
450 impl ::fidl_next::TwoWayMethod for ReleaseInterrupt {
451 type Response = ::fidl_next::wire::Result<
452 'static,
453 crate::wire::GpioReleaseInterruptResponse,
454 ::fidl_next::wire::fuchsia::Status,
455 >;
456 }
457
458 impl<___R> ::fidl_next::Respond<___R> for ReleaseInterrupt {
459 type Output = ::core::result::Result<___R, ::fidl_next::never::Never>;
460
461 fn respond(response: ___R) -> Self::Output {
462 ::core::result::Result::Ok(response)
463 }
464 }
465
466 impl<___R> ::fidl_next::RespondErr<___R> for ReleaseInterrupt {
467 type Output = ::core::result::Result<::fidl_next::never::Never, ___R>;
468
469 fn respond_err(response: ___R) -> Self::Output {
470 ::core::result::Result::Err(response)
471 }
472 }
473
474 mod ___detail {
475 unsafe impl<___T> ::fidl_next::HasConnectionHandles<___T> for crate::Gpio
476 where
477 ___T: ::fidl_next::Transport,
478 {
479 type Client = GpioClient<___T>;
480 type Server = GpioServer<___T>;
481 }
482
483 #[repr(transparent)]
485 pub struct GpioClient<___T: ::fidl_next::Transport> {
486 #[allow(dead_code)]
487 client: ::fidl_next::protocol::Client<___T>,
488 }
489
490 impl<___T> GpioClient<___T>
491 where
492 ___T: ::fidl_next::Transport,
493 {
494 #[doc = " Reads the current value of a GPIO, returning `true` for a high voltage and `false` for a\n low voltage.\n"]
495 pub fn read(&self) -> ::fidl_next::TwoWayFuture<'_, super::Read, ___T> {
496 ::fidl_next::TwoWayFuture::from_untyped(
497 self.client.send_two_way::<::fidl_next::wire::EmptyMessageBody>(
498 6908491597971105712,
499 <super::Read as ::fidl_next::Method>::FLEXIBILITY,
500 (),
501 ),
502 )
503 }
504
505 #[doc = " Configures the output buffer as per `mode`.\n"]
506 pub fn set_buffer_mode(
507 &self,
508
509 mode: impl ::fidl_next::Encode<
510 crate::wire::BufferMode,
511 <___T as ::fidl_next::Transport>::SendBuffer,
512 >,
513 ) -> ::fidl_next::TwoWayFuture<'_, super::SetBufferMode, ___T>
514 where
515 <___T as ::fidl_next::Transport>::SendBuffer:
516 ::fidl_next::encoder::InternalHandleEncoder,
517 {
518 self.set_buffer_mode_with(crate::generic::GpioSetBufferModeRequest { mode })
519 }
520
521 #[doc = " Configures the output buffer as per `mode`.\n"]
522 pub fn set_buffer_mode_with<___R>(
523 &self,
524 request: ___R,
525 ) -> ::fidl_next::TwoWayFuture<'_, super::SetBufferMode, ___T>
526 where
527 ___R: ::fidl_next::Encode<
528 crate::wire::GpioSetBufferModeRequest,
529 <___T as ::fidl_next::Transport>::SendBuffer,
530 >,
531 {
532 ::fidl_next::TwoWayFuture::from_untyped(self.client.send_two_way(
533 7815548855987352771,
534 <super::SetBufferMode as ::fidl_next::Method>::FLEXIBILITY,
535 request,
536 ))
537 }
538
539 #[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"]
540 pub fn get_interrupt(
541 &self,
542
543 options: impl ::fidl_next::Encode<
544 crate::wire::InterruptOptions,
545 <___T as ::fidl_next::Transport>::SendBuffer,
546 >,
547 ) -> ::fidl_next::TwoWayFuture<'_, super::GetInterrupt, ___T>
548 where
549 <___T as ::fidl_next::Transport>::SendBuffer:
550 ::fidl_next::encoder::InternalHandleEncoder,
551 {
552 self.get_interrupt_with(crate::generic::GpioGetInterruptRequest { options })
553 }
554
555 #[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"]
556 pub fn get_interrupt_with<___R>(
557 &self,
558 request: ___R,
559 ) -> ::fidl_next::TwoWayFuture<'_, super::GetInterrupt, ___T>
560 where
561 ___R: ::fidl_next::Encode<
562 crate::wire::GpioGetInterruptRequest,
563 <___T as ::fidl_next::Transport>::SendBuffer,
564 >,
565 {
566 ::fidl_next::TwoWayFuture::from_untyped(self.client.send_two_way(
567 7365855668153908485,
568 <super::GetInterrupt as ::fidl_next::Method>::FLEXIBILITY,
569 request,
570 ))
571 }
572
573 #[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"]
574 pub fn configure_interrupt(
575 &self,
576
577 config: impl ::fidl_next::Encode<
578 crate::wire::InterruptConfiguration<'static>,
579 <___T as ::fidl_next::Transport>::SendBuffer,
580 >,
581 ) -> ::fidl_next::TwoWayFuture<'_, super::ConfigureInterrupt, ___T>
582 where
583 <___T as ::fidl_next::Transport>::SendBuffer:
584 ::fidl_next::encoder::InternalHandleEncoder,
585 <___T as ::fidl_next::Transport>::SendBuffer: ::fidl_next::Encoder,
586 {
587 self.configure_interrupt_with(crate::generic::GpioConfigureInterruptRequest {
588 config,
589 })
590 }
591
592 #[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"]
593 pub fn configure_interrupt_with<___R>(
594 &self,
595 request: ___R,
596 ) -> ::fidl_next::TwoWayFuture<'_, super::ConfigureInterrupt, ___T>
597 where
598 ___R: ::fidl_next::Encode<
599 crate::wire::GpioConfigureInterruptRequest<'static>,
600 <___T as ::fidl_next::Transport>::SendBuffer,
601 >,
602 {
603 ::fidl_next::TwoWayFuture::from_untyped(self.client.send_two_way(
604 7325286056521055395,
605 <super::ConfigureInterrupt as ::fidl_next::Method>::FLEXIBILITY,
606 request,
607 ))
608 }
609
610 #[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"]
611 pub fn release_interrupt(
612 &self,
613 ) -> ::fidl_next::TwoWayFuture<'_, super::ReleaseInterrupt, ___T> {
614 ::fidl_next::TwoWayFuture::from_untyped(
615 self.client.send_two_way::<::fidl_next::wire::EmptyMessageBody>(
616 4772197165771495750,
617 <super::ReleaseInterrupt as ::fidl_next::Method>::FLEXIBILITY,
618 (),
619 ),
620 )
621 }
622 }
623
624 #[repr(transparent)]
626 pub struct GpioServer<___T: ::fidl_next::Transport> {
627 server: ::fidl_next::protocol::Server<___T>,
628 }
629
630 impl<___T> GpioServer<___T> where ___T: ::fidl_next::Transport {}
631 }
632}
633
634#[diagnostic::on_unimplemented(
635 note = "If {Self} implements the non-local GpioClientHandler trait, use `spawn_as_local` or the `Local` adapter type"
636)]
637
638pub trait GpioLocalClientHandler<
642 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
643 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
644>
645{
646 fn on_unknown_interaction(&mut self, ordinal: u64) -> impl ::core::future::Future<Output = ()> {
647 ::core::future::ready(())
648 }
649}
650
651impl<___H, ___T> ::fidl_next::DispatchLocalClientMessage<___H, ___T> for Gpio
652where
653 ___H: GpioLocalClientHandler<___T>,
654 ___T: ::fidl_next::Transport,
655{
656 async fn on_event(
657 handler: &mut ___H,
658 mut message: ::fidl_next::Message<___T>,
659 ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
660 match *message.header().ordinal {
661 ordinal => {
662 handler.on_unknown_interaction(ordinal).await;
663 if ::core::matches!(
664 message.header().flexibility(),
665 ::fidl_next::protocol::Flexibility::Strict
666 ) {
667 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
668 } else {
669 Ok(())
670 }
671 }
672 }
673 }
674}
675
676#[diagnostic::on_unimplemented(
677 note = "If {Self} implements the non-local GpioServerHandler trait, use `spawn_as_local` or the `Local` adapter type"
678)]
679
680pub trait GpioLocalServerHandler<
684 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
685 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
686>
687{
688 #[doc = " Reads the current value of a GPIO, returning `true` for a high voltage and `false` for a\n low voltage.\n"]
689 fn read(
690 &mut self,
691
692 responder: ::fidl_next::Responder<gpio::Read, ___T>,
693 ) -> impl ::core::future::Future<Output = ()>;
694
695 #[doc = " Configures the output buffer as per `mode`.\n"]
696 fn set_buffer_mode(
697 &mut self,
698
699 request: ::fidl_next::Request<gpio::SetBufferMode, ___T>,
700
701 responder: ::fidl_next::Responder<gpio::SetBufferMode, ___T>,
702 ) -> impl ::core::future::Future<Output = ()>;
703
704 #[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"]
705 fn get_interrupt(
706 &mut self,
707
708 request: ::fidl_next::Request<gpio::GetInterrupt, ___T>,
709
710 responder: ::fidl_next::Responder<gpio::GetInterrupt, ___T>,
711 ) -> impl ::core::future::Future<Output = ()>;
712
713 #[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"]
714 fn configure_interrupt(
715 &mut self,
716
717 request: ::fidl_next::Request<gpio::ConfigureInterrupt, ___T>,
718
719 responder: ::fidl_next::Responder<gpio::ConfigureInterrupt, ___T>,
720 ) -> impl ::core::future::Future<Output = ()>;
721
722 #[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"]
723 fn release_interrupt(
724 &mut self,
725
726 responder: ::fidl_next::Responder<gpio::ReleaseInterrupt, ___T>,
727 ) -> impl ::core::future::Future<Output = ()>;
728
729 fn on_unknown_interaction(&mut self, ordinal: u64) -> impl ::core::future::Future<Output = ()> {
730 ::core::future::ready(())
731 }
732}
733
734impl<___H, ___T> ::fidl_next::DispatchLocalServerMessage<___H, ___T> for Gpio
735where
736 ___H: GpioLocalServerHandler<___T>,
737 ___T: ::fidl_next::Transport,
738 for<'de> crate::wire::GpioSetBufferModeRequest: ::fidl_next::Decode<
739 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
740 Constraint = (),
741 >,
742 for<'de> crate::wire::GpioGetInterruptRequest: ::fidl_next::Decode<
743 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
744 Constraint = (),
745 >,
746 for<'de> crate::wire::GpioConfigureInterruptRequest<'de>: ::fidl_next::Decode<
747 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
748 Constraint = (),
749 >,
750{
751 async fn on_one_way(
752 handler: &mut ___H,
753 mut message: ::fidl_next::Message<___T>,
754 ) -> ::core::result::Result<
755 (),
756 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
757 > {
758 match *message.header().ordinal {
759 ordinal => {
760 handler.on_unknown_interaction(ordinal).await;
761 if ::core::matches!(
762 message.header().flexibility(),
763 ::fidl_next::protocol::Flexibility::Strict
764 ) {
765 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
766 } else {
767 Ok(())
768 }
769 }
770 }
771 }
772
773 async fn on_two_way(
774 handler: &mut ___H,
775 mut message: ::fidl_next::Message<___T>,
776 responder: ::fidl_next::protocol::Responder<___T>,
777 ) -> ::core::result::Result<
778 (),
779 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
780 > {
781 match *message.header().ordinal {
782 6908491597971105712 => {
783 let responder = ::fidl_next::Responder::from_untyped(responder);
784
785 handler.read(responder).await;
786 Ok(())
787 }
788
789 7815548855987352771 => {
790 let responder = ::fidl_next::Responder::from_untyped(responder);
791
792 match ::fidl_next::AsDecoderExt::into_decoded(message) {
793 Ok(decoded) => {
794 handler
795 .set_buffer_mode(::fidl_next::Request::from_decoded(decoded), responder)
796 .await;
797 Ok(())
798 }
799 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
800 ordinal: 7815548855987352771,
801 error,
802 }),
803 }
804 }
805
806 7365855668153908485 => {
807 let responder = ::fidl_next::Responder::from_untyped(responder);
808
809 match ::fidl_next::AsDecoderExt::into_decoded(message) {
810 Ok(decoded) => {
811 handler
812 .get_interrupt(::fidl_next::Request::from_decoded(decoded), responder)
813 .await;
814 Ok(())
815 }
816 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
817 ordinal: 7365855668153908485,
818 error,
819 }),
820 }
821 }
822
823 7325286056521055395 => {
824 let responder = ::fidl_next::Responder::from_untyped(responder);
825
826 match ::fidl_next::AsDecoderExt::into_decoded(message) {
827 Ok(decoded) => {
828 handler
829 .configure_interrupt(
830 ::fidl_next::Request::from_decoded(decoded),
831 responder,
832 )
833 .await;
834 Ok(())
835 }
836 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
837 ordinal: 7325286056521055395,
838 error,
839 }),
840 }
841 }
842
843 4772197165771495750 => {
844 let responder = ::fidl_next::Responder::from_untyped(responder);
845
846 handler.release_interrupt(responder).await;
847 Ok(())
848 }
849
850 ordinal => {
851 handler.on_unknown_interaction(ordinal).await;
852 if ::core::matches!(
853 message.header().flexibility(),
854 ::fidl_next::protocol::Flexibility::Strict
855 ) {
856 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
857 } else {
858 responder
859 .respond_framework_error(
860 ordinal,
861 ::fidl_next::FrameworkError::UnknownMethod,
862 )
863 .expect("encoding a framework error should never fail")
864 .await?;
865 Ok(())
866 }
867 }
868 }
869 }
870}
871
872pub trait GpioClientHandler<
876 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
877 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
878>
879{
880 fn on_unknown_interaction(
881 &mut self,
882 ordinal: u64,
883 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send {
884 ::core::future::ready(())
885 }
886}
887
888impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Gpio
889where
890 ___H: GpioClientHandler<___T> + ::core::marker::Send,
891 ___T: ::fidl_next::Transport,
892{
893 async fn on_event(
894 handler: &mut ___H,
895 mut message: ::fidl_next::Message<___T>,
896 ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
897 match *message.header().ordinal {
898 ordinal => {
899 handler.on_unknown_interaction(ordinal).await;
900 if ::core::matches!(
901 message.header().flexibility(),
902 ::fidl_next::protocol::Flexibility::Strict
903 ) {
904 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
905 } else {
906 Ok(())
907 }
908 }
909 }
910 }
911}
912
913pub trait GpioServerHandler<
917 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
918 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
919>
920{
921 #[doc = " Reads the current value of a GPIO, returning `true` for a high voltage and `false` for a\n low voltage.\n"]
922 fn read(
923 &mut self,
924
925 responder: ::fidl_next::Responder<gpio::Read, ___T>,
926 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
927
928 #[doc = " Configures the output buffer as per `mode`.\n"]
929 fn set_buffer_mode(
930 &mut self,
931
932 request: ::fidl_next::Request<gpio::SetBufferMode, ___T>,
933
934 responder: ::fidl_next::Responder<gpio::SetBufferMode, ___T>,
935 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
936
937 #[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"]
938 fn get_interrupt(
939 &mut self,
940
941 request: ::fidl_next::Request<gpio::GetInterrupt, ___T>,
942
943 responder: ::fidl_next::Responder<gpio::GetInterrupt, ___T>,
944 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
945
946 #[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"]
947 fn configure_interrupt(
948 &mut self,
949
950 request: ::fidl_next::Request<gpio::ConfigureInterrupt, ___T>,
951
952 responder: ::fidl_next::Responder<gpio::ConfigureInterrupt, ___T>,
953 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
954
955 #[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"]
956 fn release_interrupt(
957 &mut self,
958
959 responder: ::fidl_next::Responder<gpio::ReleaseInterrupt, ___T>,
960 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
961
962 fn on_unknown_interaction(
963 &mut self,
964 ordinal: u64,
965 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send {
966 ::core::future::ready(())
967 }
968}
969
970impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Gpio
971where
972 ___H: GpioServerHandler<___T> + ::core::marker::Send,
973 ___T: ::fidl_next::Transport,
974 for<'de> crate::wire::GpioSetBufferModeRequest: ::fidl_next::Decode<
975 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
976 Constraint = (),
977 >,
978 for<'de> crate::wire::GpioGetInterruptRequest: ::fidl_next::Decode<
979 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
980 Constraint = (),
981 >,
982 for<'de> crate::wire::GpioConfigureInterruptRequest<'de>: ::fidl_next::Decode<
983 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
984 Constraint = (),
985 >,
986{
987 async fn on_one_way(
988 handler: &mut ___H,
989 mut message: ::fidl_next::Message<___T>,
990 ) -> ::core::result::Result<
991 (),
992 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
993 > {
994 match *message.header().ordinal {
995 ordinal => {
996 handler.on_unknown_interaction(ordinal).await;
997 if ::core::matches!(
998 message.header().flexibility(),
999 ::fidl_next::protocol::Flexibility::Strict
1000 ) {
1001 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
1002 } else {
1003 Ok(())
1004 }
1005 }
1006 }
1007 }
1008
1009 async fn on_two_way(
1010 handler: &mut ___H,
1011 mut message: ::fidl_next::Message<___T>,
1012 responder: ::fidl_next::protocol::Responder<___T>,
1013 ) -> ::core::result::Result<
1014 (),
1015 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
1016 > {
1017 match *message.header().ordinal {
1018 6908491597971105712 => {
1019 let responder = ::fidl_next::Responder::from_untyped(responder);
1020
1021 handler.read(responder).await;
1022 Ok(())
1023 }
1024
1025 7815548855987352771 => {
1026 let responder = ::fidl_next::Responder::from_untyped(responder);
1027
1028 match ::fidl_next::AsDecoderExt::into_decoded(message) {
1029 Ok(decoded) => {
1030 handler
1031 .set_buffer_mode(::fidl_next::Request::from_decoded(decoded), responder)
1032 .await;
1033 Ok(())
1034 }
1035 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
1036 ordinal: 7815548855987352771,
1037 error,
1038 }),
1039 }
1040 }
1041
1042 7365855668153908485 => {
1043 let responder = ::fidl_next::Responder::from_untyped(responder);
1044
1045 match ::fidl_next::AsDecoderExt::into_decoded(message) {
1046 Ok(decoded) => {
1047 handler
1048 .get_interrupt(::fidl_next::Request::from_decoded(decoded), responder)
1049 .await;
1050 Ok(())
1051 }
1052 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
1053 ordinal: 7365855668153908485,
1054 error,
1055 }),
1056 }
1057 }
1058
1059 7325286056521055395 => {
1060 let responder = ::fidl_next::Responder::from_untyped(responder);
1061
1062 match ::fidl_next::AsDecoderExt::into_decoded(message) {
1063 Ok(decoded) => {
1064 handler
1065 .configure_interrupt(
1066 ::fidl_next::Request::from_decoded(decoded),
1067 responder,
1068 )
1069 .await;
1070 Ok(())
1071 }
1072 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
1073 ordinal: 7325286056521055395,
1074 error,
1075 }),
1076 }
1077 }
1078
1079 4772197165771495750 => {
1080 let responder = ::fidl_next::Responder::from_untyped(responder);
1081
1082 handler.release_interrupt(responder).await;
1083 Ok(())
1084 }
1085
1086 ordinal => {
1087 handler.on_unknown_interaction(ordinal).await;
1088 if ::core::matches!(
1089 message.header().flexibility(),
1090 ::fidl_next::protocol::Flexibility::Strict
1091 ) {
1092 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
1093 } else {
1094 responder
1095 .respond_framework_error(
1096 ordinal,
1097 ::fidl_next::FrameworkError::UnknownMethod,
1098 )
1099 .expect("encoding a framework error should never fail")
1100 .await?;
1101 Ok(())
1102 }
1103 }
1104 }
1105 }
1106}
1107
1108impl<___T> GpioClientHandler<___T> for ::fidl_next::IgnoreEvents
1109where
1110 ___T: ::fidl_next::Transport,
1111{
1112 async fn on_unknown_interaction(&mut self, _: u64) {}
1113}
1114
1115impl<___H, ___T> GpioLocalClientHandler<___T> for ::fidl_next::Local<___H>
1116where
1117 ___H: GpioClientHandler<___T>,
1118 ___T: ::fidl_next::Transport,
1119{
1120 async fn on_unknown_interaction(&mut self, ordinal: u64) {
1121 ___H::on_unknown_interaction(&mut self.0, ordinal).await
1122 }
1123}
1124
1125impl<___H, ___T> GpioLocalServerHandler<___T> for ::fidl_next::Local<___H>
1126where
1127 ___H: GpioServerHandler<___T>,
1128 ___T: ::fidl_next::Transport,
1129{
1130 async fn read(&mut self, responder: ::fidl_next::Responder<gpio::Read, ___T>) {
1131 ___H::read(&mut self.0, responder).await
1132 }
1133
1134 async fn set_buffer_mode(
1135 &mut self,
1136
1137 request: ::fidl_next::Request<gpio::SetBufferMode, ___T>,
1138
1139 responder: ::fidl_next::Responder<gpio::SetBufferMode, ___T>,
1140 ) {
1141 ___H::set_buffer_mode(&mut self.0, request, responder).await
1142 }
1143
1144 async fn get_interrupt(
1145 &mut self,
1146
1147 request: ::fidl_next::Request<gpio::GetInterrupt, ___T>,
1148
1149 responder: ::fidl_next::Responder<gpio::GetInterrupt, ___T>,
1150 ) {
1151 ___H::get_interrupt(&mut self.0, request, responder).await
1152 }
1153
1154 async fn configure_interrupt(
1155 &mut self,
1156
1157 request: ::fidl_next::Request<gpio::ConfigureInterrupt, ___T>,
1158
1159 responder: ::fidl_next::Responder<gpio::ConfigureInterrupt, ___T>,
1160 ) {
1161 ___H::configure_interrupt(&mut self.0, request, responder).await
1162 }
1163
1164 async fn release_interrupt(
1165 &mut self,
1166
1167 responder: ::fidl_next::Responder<gpio::ReleaseInterrupt, ___T>,
1168 ) {
1169 ___H::release_interrupt(&mut self.0, responder).await
1170 }
1171
1172 async fn on_unknown_interaction(&mut self, ordinal: u64) {
1173 ___H::on_unknown_interaction(&mut self.0, ordinal).await
1174 }
1175}
1176
1177#[derive(Debug)]
1179pub struct Service;
1180
1181impl ::fidl_next::DiscoverableService for Service {
1182 const SERVICE_NAME: &'static str = "fuchsia.hardware.gpio.Service";
1183 const MEMBER_NAMES: &'static [&'static str] = &["device"];
1184}
1185
1186impl ::fidl_next::HasServiceRequest<::fidl_next::fuchsia::zx::Channel> for Service {}
1187
1188impl<___C> ::fidl_next::Service<___C> for Service
1189where
1190 ___C: ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>,
1191{
1192 type Connector = ServiceConnector<___C>;
1193}
1194
1195#[repr(transparent)]
1197pub struct ServiceConnector<___C> {
1198 #[allow(dead_code)]
1199 connector: ___C,
1200}
1201
1202impl<___C> ServiceConnector<___C>
1203where
1204 ___C: ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>,
1205{
1206 pub fn device(
1208 &self,
1209 server_end: ::fidl_next::ServerEnd<crate::Gpio, ::fidl_next::fuchsia::zx::Channel>,
1210 ) -> ::core::result::Result<
1211 (),
1212 <___C as ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>>::Error,
1213 > {
1214 ::fidl_next::protocol::ServiceConnector::<
1215 ::fidl_next::fuchsia::zx::Channel
1216 >::connect_to_member(
1217 &self.connector,
1218 "device",
1219 server_end.into_untyped(),
1220 )
1221 }
1222}
1223
1224pub trait ServiceHandler {
1226 fn device(
1228 &self,
1229 server_end: ::fidl_next::ServerEnd<crate::Gpio, ::fidl_next::fuchsia::zx::Channel>,
1230 );
1231}
1232
1233impl<___H, ___T> ::fidl_next::DispatchServiceHandler<___H, ___T> for Service
1234where
1235 ___H: ServiceHandler,
1236 ::fidl_next::fuchsia::zx::Channel: ::fidl_next::InstanceFromServiceTransport<___T>,
1237{
1238 fn on_connection(handler: &___H, member: &str, server_end: ___T) {
1239 use ::fidl_next::InstanceFromServiceTransport;
1240 match member {
1241 "device" => handler.device(::fidl_next::ServerEnd::from_untyped(
1242 ::fidl_next::fuchsia::zx::Channel::from_service_transport(server_end),
1243 )),
1244
1245 _ => unreachable!(),
1246 }
1247 }
1248}
1249
1250pub use fidl_next_common_fuchsia_hardware_gpio::*;