Skip to main content

fidl_next_fuchsia_examples_gizmo/
fidl_next_fuchsia_examples_gizmo.rs

1// DO NOT EDIT: This file is machine-generated by fidlgen
2#![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_examples_gizmo::natural::*;
8
9    #[derive(Debug, PartialEq)]
10    #[repr(C)]
11    pub struct DeviceGetEventResponse {
12        pub event: ::fidl_next::fuchsia::zx::Event,
13    }
14
15    unsafe impl<___E> ::fidl_next::Encode<crate::wire::DeviceGetEventResponse, ___E>
16        for DeviceGetEventResponse
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::DeviceGetEventResponse,
24        > = unsafe {
25            ::fidl_next::CopyOptimization::enable_if(
26                true && <::fidl_next::fuchsia::zx::Event as ::fidl_next::Encode<
27                    ::fidl_next::wire::fuchsia::Event,
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::DeviceGetEventResponse>,
39            _: (),
40        ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
41            ::fidl_next::munge! {
42                let crate::wire::DeviceGetEventResponse {
43                    event,
44
45                } = out_;
46            }
47
48            ::fidl_next::Encode::encode(self.event, encoder_, event, ())?;
49
50            let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(event.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::DeviceGetEventResponse>,
59            ___E,
60        > for DeviceGetEventResponse
61    where
62        ___E: ::fidl_next::Encoder + ?Sized,
63        DeviceGetEventResponse: ::fidl_next::Encode<crate::wire::DeviceGetEventResponse, ___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::DeviceGetEventResponse>,
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::DeviceGetEventResponse> for DeviceGetEventResponse {
86        const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<
87            crate::wire::DeviceGetEventResponse,
88            Self,
89        > = unsafe {
90            ::fidl_next::CopyOptimization::enable_if(
91                true && <::fidl_next::fuchsia::zx::Event as ::fidl_next::FromWire<
92                    ::fidl_next::wire::fuchsia::Event,
93                >>::COPY_OPTIMIZATION
94                    .is_enabled(),
95            )
96        };
97
98        #[inline]
99        fn from_wire(wire: crate::wire::DeviceGetEventResponse) -> Self {
100            Self { event: ::fidl_next::FromWire::from_wire(wire.event) }
101        }
102    }
103}
104
105pub mod wire {
106
107    pub use fidl_next_common_fuchsia_examples_gizmo::wire::*;
108
109    /// The wire type corresponding to [`DeviceGetEventResponse`].
110    #[derive(Debug)]
111    #[repr(C)]
112    pub struct DeviceGetEventResponse {
113        pub event: ::fidl_next::wire::fuchsia::Event,
114    }
115
116    static_assertions::const_assert_eq!(std::mem::size_of::<DeviceGetEventResponse>(), 4);
117    static_assertions::const_assert_eq!(std::mem::align_of::<DeviceGetEventResponse>(), 4);
118
119    static_assertions::const_assert_eq!(std::mem::offset_of!(DeviceGetEventResponse, event), 0);
120
121    impl ::fidl_next::Constrained for DeviceGetEventResponse {
122        type Constraint = ();
123
124        fn validate(
125            _: ::fidl_next::Slot<'_, Self>,
126            _: Self::Constraint,
127        ) -> Result<(), ::fidl_next::ValidationError> {
128            Ok(())
129        }
130    }
131
132    unsafe impl ::fidl_next::Wire for DeviceGetEventResponse {
133        type Narrowed<'de> = DeviceGetEventResponse;
134
135        #[inline]
136        fn zero_padding(out_: &mut ::core::mem::MaybeUninit<Self>) {
137            ::fidl_next::munge! {
138                let Self {
139                    event,
140
141                } = &mut *out_;
142            }
143
144            ::fidl_next::Wire::zero_padding(event);
145        }
146    }
147
148    unsafe impl<___D> ::fidl_next::Decode<___D> for DeviceGetEventResponse
149    where
150        ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
151        ___D: ::fidl_next::fuchsia::HandleDecoder,
152    {
153        fn decode(
154            slot_: ::fidl_next::Slot<'_, Self>,
155            decoder_: &mut ___D,
156            _: (),
157        ) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
158            ::fidl_next::munge! {
159                let Self {
160                    mut event,
161
162                } = slot_;
163            }
164
165            let _field = event.as_mut();
166
167            ::fidl_next::Decode::decode(event.as_mut(), decoder_, ())?;
168
169            Ok(())
170        }
171    }
172
173    impl ::fidl_next::IntoNatural for DeviceGetEventResponse {
174        type Natural = crate::natural::DeviceGetEventResponse;
175    }
176}
177
178pub mod wire_optional {
179
180    pub use fidl_next_common_fuchsia_examples_gizmo::wire_optional::*;
181}
182
183pub mod generic {
184
185    pub use fidl_next_common_fuchsia_examples_gizmo::generic::*;
186
187    /// The generic type corresponding to [`DeviceGetEventResponse`].
188    pub struct DeviceGetEventResponse<T0> {
189        pub event: T0,
190    }
191
192    unsafe impl<___E, T0> ::fidl_next::Encode<crate::wire::DeviceGetEventResponse, ___E>
193        for DeviceGetEventResponse<T0>
194    where
195        ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
196        ___E: ::fidl_next::fuchsia::HandleEncoder,
197        T0: ::fidl_next::Encode<::fidl_next::wire::fuchsia::Event, ___E>,
198    {
199        #[inline]
200        fn encode(
201            self,
202            encoder_: &mut ___E,
203            out_: &mut ::core::mem::MaybeUninit<crate::wire::DeviceGetEventResponse>,
204            _: (),
205        ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
206            ::fidl_next::munge! {
207                let crate::wire::DeviceGetEventResponse {
208                    event,
209
210                } = out_;
211            }
212
213            ::fidl_next::Encode::encode(self.event, encoder_, event, ())?;
214
215            Ok(())
216        }
217    }
218
219    unsafe impl<'a, ___E, T0> ::fidl_next::Encode<crate::wire::DeviceGetEventResponse, ___E>
220        for &'a DeviceGetEventResponse<T0>
221    where
222        ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
223        ___E: ::fidl_next::fuchsia::HandleEncoder,
224        &'a T0: ::fidl_next::Encode<::fidl_next::wire::fuchsia::Event, ___E>,
225    {
226        #[inline]
227        fn encode(
228            self,
229            encoder_: &mut ___E,
230            out_: &mut ::core::mem::MaybeUninit<crate::wire::DeviceGetEventResponse>,
231            _: (),
232        ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
233            ::fidl_next::munge! {
234                let crate::wire::DeviceGetEventResponse {
235                    event,
236
237                } = out_;
238            }
239
240            ::fidl_next::Encode::encode(&self.event, encoder_, event, ())?;
241
242            Ok(())
243        }
244    }
245}
246
247pub use self::natural::*;
248
249/// The type corresponding to the Device protocol.
250#[doc = " The protocol provides access to functions of the driver.\n"]
251#[derive(PartialEq, Debug)]
252pub struct Device;
253
254#[cfg(feature = "driver")]
255impl ::fidl_next::HasTransport for Device {
256    type Transport = ::fdf_fidl::DriverChannel;
257}
258
259pub mod device {
260    pub mod prelude {
261        pub use crate::{
262            Device, DeviceClientHandler, DeviceLocalClientHandler, DeviceLocalServerHandler,
263            DeviceServerHandler, device,
264        };
265
266        pub use crate::natural::DeviceGetEventResponse;
267
268        pub use crate::natural::DeviceGetHardwareIdResponse;
269    }
270
271    pub struct GetHardwareId;
272
273    impl ::fidl_next::Method for GetHardwareId {
274        const ORDINAL: u64 = 7952116938191896180;
275        const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
276            ::fidl_next::protocol::Flexibility::Strict;
277
278        type Protocol = crate::Device;
279
280        type Request = ::fidl_next::wire::EmptyMessageBody;
281    }
282
283    impl ::fidl_next::TwoWayMethod for GetHardwareId {
284        type Response = ::fidl_next::wire::Result<
285            'static,
286            crate::wire::DeviceGetHardwareIdResponse,
287            ::fidl_next::wire::fuchsia::Status,
288        >;
289    }
290
291    impl<___R> ::fidl_next::Respond<___R> for GetHardwareId {
292        type Output = ::core::result::Result<
293            crate::generic::DeviceGetHardwareIdResponse<___R>,
294            ::fidl_next::never::Never,
295        >;
296
297        fn respond(response: ___R) -> Self::Output {
298            ::core::result::Result::Ok(crate::generic::DeviceGetHardwareIdResponse {
299                response: response,
300            })
301        }
302    }
303
304    impl<___R> ::fidl_next::RespondErr<___R> for GetHardwareId {
305        type Output = ::core::result::Result<::fidl_next::never::Never, ___R>;
306
307        fn respond_err(response: ___R) -> Self::Output {
308            ::core::result::Result::Err(response)
309        }
310    }
311
312    pub struct GetEvent;
313
314    impl ::fidl_next::Method for GetEvent {
315        const ORDINAL: u64 = 6100331669860404750;
316        const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
317            ::fidl_next::protocol::Flexibility::Strict;
318
319        type Protocol = crate::Device;
320
321        type Request = ::fidl_next::wire::EmptyMessageBody;
322    }
323
324    impl ::fidl_next::TwoWayMethod for GetEvent {
325        type Response = ::fidl_next::wire::Strict<crate::wire::DeviceGetEventResponse>;
326    }
327
328    impl<___R> ::fidl_next::Respond<___R> for GetEvent {
329        type Output = ::fidl_next::Strict<crate::generic::DeviceGetEventResponse<___R>>;
330
331        fn respond(response: ___R) -> Self::Output {
332            ::fidl_next::Strict(crate::generic::DeviceGetEventResponse { event: response })
333        }
334    }
335
336    mod ___detail {
337        unsafe impl<___T> ::fidl_next::HasConnectionHandles<___T> for crate::Device
338        where
339            ___T: ::fidl_next::Transport,
340        {
341            type Client = DeviceClient<___T>;
342            type Server = DeviceServer<___T>;
343        }
344
345        /// The client for the `Device` protocol.
346        #[repr(transparent)]
347        pub struct DeviceClient<___T: ::fidl_next::Transport> {
348            #[allow(dead_code)]
349            client: ::fidl_next::protocol::Client<___T>,
350        }
351
352        impl<___T> DeviceClient<___T>
353        where
354            ___T: ::fidl_next::Transport,
355        {
356            #[doc = " Returns a unique identifier for this device.\n"]
357            pub fn get_hardware_id(
358                &self,
359            ) -> ::fidl_next::TwoWayFuture<'_, super::GetHardwareId, ___T> {
360                ::fidl_next::TwoWayFuture::from_untyped(
361                    self.client.send_two_way::<::fidl_next::wire::EmptyMessageBody>(
362                        7952116938191896180,
363                        <super::GetHardwareId as ::fidl_next::Method>::FLEXIBILITY,
364                        (),
365                    ),
366                )
367            }
368
369            #[doc = " Returns a zircon event object handle!\n"]
370            pub fn get_event(&self) -> ::fidl_next::TwoWayFuture<'_, super::GetEvent, ___T> {
371                ::fidl_next::TwoWayFuture::from_untyped(
372                    self.client.send_two_way::<::fidl_next::wire::EmptyMessageBody>(
373                        6100331669860404750,
374                        <super::GetEvent as ::fidl_next::Method>::FLEXIBILITY,
375                        (),
376                    ),
377                )
378            }
379        }
380
381        /// The server for the `Device` protocol.
382        #[repr(transparent)]
383        pub struct DeviceServer<___T: ::fidl_next::Transport> {
384            server: ::fidl_next::protocol::Server<___T>,
385        }
386
387        impl<___T> DeviceServer<___T> where ___T: ::fidl_next::Transport {}
388    }
389}
390
391#[diagnostic::on_unimplemented(
392    note = "If {Self} implements the non-local DeviceClientHandler trait, use `spawn_as_local` or the `Local` adapter type"
393)]
394
395/// A client handler for the Device protocol.
396///
397/// See [`Device`] for more details.
398pub trait DeviceLocalClientHandler<
399    #[cfg(feature = "driver")] ___T: ::fidl_next::Transport = ::fdf_fidl::DriverChannel,
400    #[cfg(not(feature = "driver"))] ___T: ::fidl_next::Transport,
401>
402{
403}
404
405impl<___H, ___T> ::fidl_next::DispatchLocalClientMessage<___H, ___T> for Device
406where
407    ___H: DeviceLocalClientHandler<___T>,
408    ___T: ::fidl_next::Transport,
409{
410    async fn on_event(
411        handler: &mut ___H,
412        mut message: ::fidl_next::Message<___T>,
413    ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
414        match *message.header().ordinal {
415            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
416        }
417    }
418}
419
420#[diagnostic::on_unimplemented(
421    note = "If {Self} implements the non-local DeviceServerHandler trait, use `spawn_as_local` or the `Local` adapter type"
422)]
423
424/// A server handler for the Device protocol.
425///
426/// See [`Device`] for more details.
427pub trait DeviceLocalServerHandler<
428    #[cfg(feature = "driver")] ___T: ::fidl_next::Transport = ::fdf_fidl::DriverChannel,
429    #[cfg(not(feature = "driver"))] ___T: ::fidl_next::Transport,
430>
431{
432    #[doc = " Returns a unique identifier for this device.\n"]
433    fn get_hardware_id(
434        &mut self,
435
436        responder: ::fidl_next::Responder<device::GetHardwareId, ___T>,
437    ) -> impl ::core::future::Future<Output = ()>;
438
439    #[doc = " Returns a zircon event object handle!\n"]
440    fn get_event(
441        &mut self,
442
443        responder: ::fidl_next::Responder<device::GetEvent, ___T>,
444    ) -> impl ::core::future::Future<Output = ()>;
445}
446
447impl<___H, ___T> ::fidl_next::DispatchLocalServerMessage<___H, ___T> for Device
448where
449    ___H: DeviceLocalServerHandler<___T>,
450    ___T: ::fidl_next::Transport,
451{
452    async fn on_one_way(
453        handler: &mut ___H,
454        mut message: ::fidl_next::Message<___T>,
455    ) -> ::core::result::Result<
456        (),
457        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
458    > {
459        match *message.header().ordinal {
460            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
461        }
462    }
463
464    async fn on_two_way(
465        handler: &mut ___H,
466        mut message: ::fidl_next::Message<___T>,
467        responder: ::fidl_next::protocol::Responder<___T>,
468    ) -> ::core::result::Result<
469        (),
470        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
471    > {
472        match *message.header().ordinal {
473            7952116938191896180 => {
474                let responder = ::fidl_next::Responder::from_untyped(responder);
475
476                handler.get_hardware_id(responder).await;
477                Ok(())
478            }
479
480            6100331669860404750 => {
481                let responder = ::fidl_next::Responder::from_untyped(responder);
482
483                handler.get_event(responder).await;
484                Ok(())
485            }
486
487            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
488        }
489    }
490}
491
492/// A client handler for the Device protocol.
493///
494/// See [`Device`] for more details.
495pub trait DeviceClientHandler<
496    #[cfg(feature = "driver")] ___T: ::fidl_next::Transport = ::fdf_fidl::DriverChannel,
497    #[cfg(not(feature = "driver"))] ___T: ::fidl_next::Transport,
498>
499{
500}
501
502impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Device
503where
504    ___H: DeviceClientHandler<___T> + ::core::marker::Send,
505    ___T: ::fidl_next::Transport,
506{
507    async fn on_event(
508        handler: &mut ___H,
509        mut message: ::fidl_next::Message<___T>,
510    ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
511        match *message.header().ordinal {
512            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
513        }
514    }
515}
516
517/// A server handler for the Device protocol.
518///
519/// See [`Device`] for more details.
520pub trait DeviceServerHandler<
521    #[cfg(feature = "driver")] ___T: ::fidl_next::Transport = ::fdf_fidl::DriverChannel,
522    #[cfg(not(feature = "driver"))] ___T: ::fidl_next::Transport,
523>
524{
525    #[doc = " Returns a unique identifier for this device.\n"]
526    fn get_hardware_id(
527        &mut self,
528
529        responder: ::fidl_next::Responder<device::GetHardwareId, ___T>,
530    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
531
532    #[doc = " Returns a zircon event object handle!\n"]
533    fn get_event(
534        &mut self,
535
536        responder: ::fidl_next::Responder<device::GetEvent, ___T>,
537    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
538}
539
540impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Device
541where
542    ___H: DeviceServerHandler<___T> + ::core::marker::Send,
543    ___T: ::fidl_next::Transport,
544{
545    async fn on_one_way(
546        handler: &mut ___H,
547        mut message: ::fidl_next::Message<___T>,
548    ) -> ::core::result::Result<
549        (),
550        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
551    > {
552        match *message.header().ordinal {
553            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
554        }
555    }
556
557    async fn on_two_way(
558        handler: &mut ___H,
559        mut message: ::fidl_next::Message<___T>,
560        responder: ::fidl_next::protocol::Responder<___T>,
561    ) -> ::core::result::Result<
562        (),
563        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
564    > {
565        match *message.header().ordinal {
566            7952116938191896180 => {
567                let responder = ::fidl_next::Responder::from_untyped(responder);
568
569                handler.get_hardware_id(responder).await;
570                Ok(())
571            }
572
573            6100331669860404750 => {
574                let responder = ::fidl_next::Responder::from_untyped(responder);
575
576                handler.get_event(responder).await;
577                Ok(())
578            }
579
580            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
581        }
582    }
583}
584
585impl<___T> DeviceClientHandler<___T> for ::fidl_next::IgnoreEvents where ___T: ::fidl_next::Transport
586{}
587
588impl<___H, ___T> DeviceLocalClientHandler<___T> for ::fidl_next::Local<___H>
589where
590    ___H: DeviceClientHandler<___T>,
591    ___T: ::fidl_next::Transport,
592{
593}
594
595impl<___H, ___T> DeviceLocalServerHandler<___T> for ::fidl_next::Local<___H>
596where
597    ___H: DeviceServerHandler<___T>,
598    ___T: ::fidl_next::Transport,
599{
600    async fn get_hardware_id(
601        &mut self,
602
603        responder: ::fidl_next::Responder<device::GetHardwareId, ___T>,
604    ) {
605        ___H::get_hardware_id(&mut self.0, responder).await
606    }
607
608    async fn get_event(&mut self, responder: ::fidl_next::Responder<device::GetEvent, ___T>) {
609        ___H::get_event(&mut self.0, responder).await
610    }
611}
612
613pub use fidl_next_common_fuchsia_examples_gizmo::*;