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
220pub use self::natural::*;
221
222/// The type corresponding to the Device protocol.
223#[doc = " The protocol provides access to functions of the driver.\n"]
224#[derive(PartialEq, Debug)]
225pub struct Device;
226
227#[cfg(feature = "driver")]
228impl ::fidl_next::HasTransport for Device {
229    type Transport = ::fdf_fidl::DriverChannel;
230}
231
232pub mod device {
233    pub mod prelude {
234        pub use crate::{
235            Device, DeviceClientHandler, DeviceLocalClientHandler, DeviceLocalServerHandler,
236            DeviceServerHandler, device,
237        };
238
239        pub use crate::natural::DeviceGetEventResponse;
240
241        pub use crate::natural::DeviceGetHardwareIdResponse;
242    }
243
244    pub struct GetHardwareId;
245
246    impl ::fidl_next::Method for GetHardwareId {
247        const ORDINAL: u64 = 7952116938191896180;
248        const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
249            ::fidl_next::protocol::Flexibility::Strict;
250
251        type Protocol = crate::Device;
252
253        type Request = ::fidl_next::wire::EmptyMessageBody;
254    }
255
256    impl ::fidl_next::TwoWayMethod for GetHardwareId {
257        type Response = ::fidl_next::wire::Result<
258            'static,
259            crate::wire::DeviceGetHardwareIdResponse,
260            ::fidl_next::wire::fuchsia::Status,
261        >;
262    }
263
264    impl<___R> ::fidl_next::Respond<___R> for GetHardwareId {
265        type Output = ::core::result::Result<
266            crate::generic::DeviceGetHardwareIdResponse<___R>,
267            ::fidl_next::never::Never,
268        >;
269
270        fn respond(response: ___R) -> Self::Output {
271            ::core::result::Result::Ok(crate::generic::DeviceGetHardwareIdResponse {
272                response: response,
273            })
274        }
275    }
276
277    impl<___R> ::fidl_next::RespondErr<___R> for GetHardwareId {
278        type Output = ::core::result::Result<::fidl_next::never::Never, ___R>;
279
280        fn respond_err(response: ___R) -> Self::Output {
281            ::core::result::Result::Err(response)
282        }
283    }
284
285    pub struct GetEvent;
286
287    impl ::fidl_next::Method for GetEvent {
288        const ORDINAL: u64 = 6100331669860404750;
289        const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
290            ::fidl_next::protocol::Flexibility::Strict;
291
292        type Protocol = crate::Device;
293
294        type Request = ::fidl_next::wire::EmptyMessageBody;
295    }
296
297    impl ::fidl_next::TwoWayMethod for GetEvent {
298        type Response = ::fidl_next::wire::Strict<crate::wire::DeviceGetEventResponse>;
299    }
300
301    impl<___R> ::fidl_next::Respond<___R> for GetEvent {
302        type Output = ::fidl_next::Strict<crate::generic::DeviceGetEventResponse<___R>>;
303
304        fn respond(response: ___R) -> Self::Output {
305            ::fidl_next::Strict(crate::generic::DeviceGetEventResponse { event: response })
306        }
307    }
308
309    mod ___detail {
310        unsafe impl<___T> ::fidl_next::HasConnectionHandles<___T> for crate::Device
311        where
312            ___T: ::fidl_next::Transport,
313        {
314            type Client = DeviceClient<___T>;
315            type Server = DeviceServer<___T>;
316        }
317
318        /// The client for the `Device` protocol.
319        #[repr(transparent)]
320        pub struct DeviceClient<___T: ::fidl_next::Transport> {
321            #[allow(dead_code)]
322            client: ::fidl_next::protocol::Client<___T>,
323        }
324
325        impl<___T> DeviceClient<___T>
326        where
327            ___T: ::fidl_next::Transport,
328        {
329            #[doc = " Returns a unique identifier for this device.\n"]
330            pub fn get_hardware_id(
331                &self,
332            ) -> ::fidl_next::TwoWayFuture<'_, super::GetHardwareId, ___T> {
333                ::fidl_next::TwoWayFuture::from_untyped(
334                    self.client.send_two_way::<::fidl_next::wire::EmptyMessageBody>(
335                        7952116938191896180,
336                        <super::GetHardwareId as ::fidl_next::Method>::FLEXIBILITY,
337                        (),
338                    ),
339                )
340            }
341
342            #[doc = " Returns a zircon event object handle!\n"]
343            pub fn get_event(&self) -> ::fidl_next::TwoWayFuture<'_, super::GetEvent, ___T> {
344                ::fidl_next::TwoWayFuture::from_untyped(
345                    self.client.send_two_way::<::fidl_next::wire::EmptyMessageBody>(
346                        6100331669860404750,
347                        <super::GetEvent as ::fidl_next::Method>::FLEXIBILITY,
348                        (),
349                    ),
350                )
351            }
352        }
353
354        /// The server for the `Device` protocol.
355        #[repr(transparent)]
356        pub struct DeviceServer<___T: ::fidl_next::Transport> {
357            server: ::fidl_next::protocol::Server<___T>,
358        }
359
360        impl<___T> DeviceServer<___T> where ___T: ::fidl_next::Transport {}
361    }
362}
363
364#[diagnostic::on_unimplemented(
365    note = "If {Self} implements the non-local DeviceClientHandler trait, use `spawn_as_local` or the `Local` adapter type"
366)]
367
368/// A client handler for the Device protocol.
369///
370/// See [`Device`] for more details.
371pub trait DeviceLocalClientHandler<
372    #[cfg(feature = "driver")] ___T: ::fidl_next::Transport = ::fdf_fidl::DriverChannel,
373    #[cfg(not(feature = "driver"))] ___T: ::fidl_next::Transport,
374>
375{
376}
377
378impl<___H, ___T> ::fidl_next::DispatchLocalClientMessage<___H, ___T> for Device
379where
380    ___H: DeviceLocalClientHandler<___T>,
381    ___T: ::fidl_next::Transport,
382{
383    async fn on_event(
384        handler: &mut ___H,
385        mut message: ::fidl_next::Message<___T>,
386    ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
387        match *message.header().ordinal {
388            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
389        }
390    }
391}
392
393#[diagnostic::on_unimplemented(
394    note = "If {Self} implements the non-local DeviceServerHandler trait, use `spawn_as_local` or the `Local` adapter type"
395)]
396
397/// A server handler for the Device protocol.
398///
399/// See [`Device`] for more details.
400pub trait DeviceLocalServerHandler<
401    #[cfg(feature = "driver")] ___T: ::fidl_next::Transport = ::fdf_fidl::DriverChannel,
402    #[cfg(not(feature = "driver"))] ___T: ::fidl_next::Transport,
403>
404{
405    #[doc = " Returns a unique identifier for this device.\n"]
406    fn get_hardware_id(
407        &mut self,
408
409        responder: ::fidl_next::Responder<device::GetHardwareId, ___T>,
410    ) -> impl ::core::future::Future<Output = ()>;
411
412    #[doc = " Returns a zircon event object handle!\n"]
413    fn get_event(
414        &mut self,
415
416        responder: ::fidl_next::Responder<device::GetEvent, ___T>,
417    ) -> impl ::core::future::Future<Output = ()>;
418}
419
420impl<___H, ___T> ::fidl_next::DispatchLocalServerMessage<___H, ___T> for Device
421where
422    ___H: DeviceLocalServerHandler<___T>,
423    ___T: ::fidl_next::Transport,
424{
425    async fn on_one_way(
426        handler: &mut ___H,
427        mut message: ::fidl_next::Message<___T>,
428    ) -> ::core::result::Result<
429        (),
430        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
431    > {
432        match *message.header().ordinal {
433            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
434        }
435    }
436
437    async fn on_two_way(
438        handler: &mut ___H,
439        mut message: ::fidl_next::Message<___T>,
440        responder: ::fidl_next::protocol::Responder<___T>,
441    ) -> ::core::result::Result<
442        (),
443        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
444    > {
445        match *message.header().ordinal {
446            7952116938191896180 => {
447                let responder = ::fidl_next::Responder::from_untyped(responder);
448
449                handler.get_hardware_id(responder).await;
450                Ok(())
451            }
452
453            6100331669860404750 => {
454                let responder = ::fidl_next::Responder::from_untyped(responder);
455
456                handler.get_event(responder).await;
457                Ok(())
458            }
459
460            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
461        }
462    }
463}
464
465/// A client handler for the Device protocol.
466///
467/// See [`Device`] for more details.
468pub trait DeviceClientHandler<
469    #[cfg(feature = "driver")] ___T: ::fidl_next::Transport = ::fdf_fidl::DriverChannel,
470    #[cfg(not(feature = "driver"))] ___T: ::fidl_next::Transport,
471>
472{
473}
474
475impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Device
476where
477    ___H: DeviceClientHandler<___T> + ::core::marker::Send,
478    ___T: ::fidl_next::Transport,
479{
480    async fn on_event(
481        handler: &mut ___H,
482        mut message: ::fidl_next::Message<___T>,
483    ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
484        match *message.header().ordinal {
485            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
486        }
487    }
488}
489
490/// A server handler for the Device protocol.
491///
492/// See [`Device`] for more details.
493pub trait DeviceServerHandler<
494    #[cfg(feature = "driver")] ___T: ::fidl_next::Transport = ::fdf_fidl::DriverChannel,
495    #[cfg(not(feature = "driver"))] ___T: ::fidl_next::Transport,
496>
497{
498    #[doc = " Returns a unique identifier for this device.\n"]
499    fn get_hardware_id(
500        &mut self,
501
502        responder: ::fidl_next::Responder<device::GetHardwareId, ___T>,
503    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
504
505    #[doc = " Returns a zircon event object handle!\n"]
506    fn get_event(
507        &mut self,
508
509        responder: ::fidl_next::Responder<device::GetEvent, ___T>,
510    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
511}
512
513impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Device
514where
515    ___H: DeviceServerHandler<___T> + ::core::marker::Send,
516    ___T: ::fidl_next::Transport,
517{
518    async fn on_one_way(
519        handler: &mut ___H,
520        mut message: ::fidl_next::Message<___T>,
521    ) -> ::core::result::Result<
522        (),
523        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
524    > {
525        match *message.header().ordinal {
526            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
527        }
528    }
529
530    async fn on_two_way(
531        handler: &mut ___H,
532        mut message: ::fidl_next::Message<___T>,
533        responder: ::fidl_next::protocol::Responder<___T>,
534    ) -> ::core::result::Result<
535        (),
536        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
537    > {
538        match *message.header().ordinal {
539            7952116938191896180 => {
540                let responder = ::fidl_next::Responder::from_untyped(responder);
541
542                handler.get_hardware_id(responder).await;
543                Ok(())
544            }
545
546            6100331669860404750 => {
547                let responder = ::fidl_next::Responder::from_untyped(responder);
548
549                handler.get_event(responder).await;
550                Ok(())
551            }
552
553            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
554        }
555    }
556}
557
558impl<___T> DeviceClientHandler<___T> for ::fidl_next::IgnoreEvents where ___T: ::fidl_next::Transport
559{}
560
561impl<___H, ___T> DeviceLocalClientHandler<___T> for ::fidl_next::Local<___H>
562where
563    ___H: DeviceClientHandler<___T>,
564    ___T: ::fidl_next::Transport,
565{
566}
567
568impl<___H, ___T> DeviceLocalServerHandler<___T> for ::fidl_next::Local<___H>
569where
570    ___H: DeviceServerHandler<___T>,
571    ___T: ::fidl_next::Transport,
572{
573    async fn get_hardware_id(
574        &mut self,
575
576        responder: ::fidl_next::Responder<device::GetHardwareId, ___T>,
577    ) {
578        ___H::get_hardware_id(&mut self.0, responder).await
579    }
580
581    async fn get_event(&mut self, responder: ::fidl_next::Responder<device::GetEvent, ___T>) {
582        ___H::get_event(&mut self.0, responder).await
583    }
584}
585
586pub use fidl_next_common_fuchsia_examples_gizmo::*;