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(target_os = "fuchsia")]
228impl ::fidl_next::HasTransport for Device {
229    type Transport = ::fidl_next::fuchsia::zx::Channel;
230}
231
232pub mod device {
233    pub mod prelude {
234        pub use crate::{Device, DeviceClientHandler, DeviceServerHandler, device};
235
236        pub use crate::natural::DeviceGetEventResponse;
237
238        pub use crate::natural::DeviceGetHardwareIdResponse;
239    }
240
241    pub struct GetHardwareId;
242
243    impl ::fidl_next::Method for GetHardwareId {
244        const ORDINAL: u64 = 7952116938191896180;
245        const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
246            ::fidl_next::protocol::Flexibility::Strict;
247
248        type Protocol = crate::Device;
249
250        type Request = ::fidl_next::wire::EmptyMessageBody;
251    }
252
253    impl ::fidl_next::TwoWayMethod for GetHardwareId {
254        type Response = ::fidl_next::wire::Result<
255            'static,
256            crate::wire::DeviceGetHardwareIdResponse,
257            ::fidl_next::wire::Int32,
258        >;
259    }
260
261    impl<___R> ::fidl_next::Respond<___R> for GetHardwareId {
262        type Output = ::core::result::Result<
263            crate::generic::DeviceGetHardwareIdResponse<___R>,
264            ::fidl_next::util::Never,
265        >;
266
267        fn respond(response: ___R) -> Self::Output {
268            ::core::result::Result::Ok(crate::generic::DeviceGetHardwareIdResponse {
269                response: response,
270            })
271        }
272    }
273
274    impl<___R> ::fidl_next::RespondErr<___R> for GetHardwareId {
275        type Output = ::core::result::Result<::fidl_next::util::Never, ___R>;
276
277        fn respond_err(response: ___R) -> Self::Output {
278            ::core::result::Result::Err(response)
279        }
280    }
281
282    pub struct GetEvent;
283
284    impl ::fidl_next::Method for GetEvent {
285        const ORDINAL: u64 = 6100331669860404750;
286        const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
287            ::fidl_next::protocol::Flexibility::Strict;
288
289        type Protocol = crate::Device;
290
291        type Request = ::fidl_next::wire::EmptyMessageBody;
292    }
293
294    impl ::fidl_next::TwoWayMethod for GetEvent {
295        type Response = crate::wire::DeviceGetEventResponse;
296    }
297
298    impl<___R> ::fidl_next::Respond<___R> for GetEvent {
299        type Output = crate::generic::DeviceGetEventResponse<___R>;
300
301        fn respond(response: ___R) -> Self::Output {
302            crate::generic::DeviceGetEventResponse { event: response }
303        }
304    }
305
306    mod ___detail {
307        unsafe impl<___T> ::fidl_next::HasConnectionHandles<___T> for crate::Device
308        where
309            ___T: ::fidl_next::Transport,
310        {
311            type Client = DeviceClient<___T>;
312            type Server = DeviceServer<___T>;
313        }
314
315        /// The client for the `Device` protocol.
316        #[repr(transparent)]
317        pub struct DeviceClient<___T: ::fidl_next::Transport> {
318            #[allow(dead_code)]
319            client: ::fidl_next::protocol::Client<___T>,
320        }
321
322        impl<___T> DeviceClient<___T>
323        where
324            ___T: ::fidl_next::Transport,
325        {
326            #[doc = " Returns a unique identifier for this device.\n"]
327            pub fn get_hardware_id(
328                &self,
329            ) -> ::fidl_next::TwoWayFuture<'_, super::GetHardwareId, ___T> {
330                ::fidl_next::TwoWayFuture::from_untyped(
331                    self.client.send_two_way::<::fidl_next::wire::EmptyMessageBody>(
332                        7952116938191896180,
333                        <super::GetHardwareId as ::fidl_next::Method>::FLEXIBILITY,
334                        (),
335                    ),
336                )
337            }
338
339            #[doc = " Returns a zircon event object handle!\n"]
340            pub fn get_event(&self) -> ::fidl_next::TwoWayFuture<'_, super::GetEvent, ___T> {
341                ::fidl_next::TwoWayFuture::from_untyped(
342                    self.client.send_two_way::<::fidl_next::wire::EmptyMessageBody>(
343                        6100331669860404750,
344                        <super::GetEvent as ::fidl_next::Method>::FLEXIBILITY,
345                        (),
346                    ),
347                )
348            }
349        }
350
351        /// The server for the `Device` protocol.
352        #[repr(transparent)]
353        pub struct DeviceServer<___T: ::fidl_next::Transport> {
354            server: ::fidl_next::protocol::Server<___T>,
355        }
356
357        impl<___T> DeviceServer<___T> where ___T: ::fidl_next::Transport {}
358    }
359}
360
361/// A client handler for the Device protocol.
362///
363/// See [`Device`] for more details.
364pub trait DeviceClientHandler<
365    #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
366    #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
367>
368{
369}
370
371impl<___T> DeviceClientHandler<___T> for ::fidl_next::IgnoreEvents where ___T: ::fidl_next::Transport
372{}
373
374impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Device
375where
376    ___H: DeviceClientHandler<___T> + ::core::marker::Send,
377    ___T: ::fidl_next::Transport,
378{
379    async fn on_event(
380        handler: &mut ___H,
381        ordinal: u64,
382        flexibility: ::fidl_next::protocol::Flexibility,
383        body: ::fidl_next::Body<___T>,
384    ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
385        match ordinal {
386            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
387        }
388    }
389}
390
391/// A server handler for the Device protocol.
392///
393/// See [`Device`] for more details.
394pub trait DeviceServerHandler<
395    #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
396    #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
397>
398{
399    #[doc = " Returns a unique identifier for this device.\n"]
400    fn get_hardware_id(
401        &mut self,
402
403        responder: ::fidl_next::Responder<device::GetHardwareId, ___T>,
404    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
405
406    #[doc = " Returns a zircon event object handle!\n"]
407    fn get_event(
408        &mut self,
409
410        responder: ::fidl_next::Responder<device::GetEvent, ___T>,
411    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
412}
413
414impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Device
415where
416    ___H: DeviceServerHandler<___T> + ::core::marker::Send,
417    ___T: ::fidl_next::Transport,
418{
419    async fn on_one_way(
420        handler: &mut ___H,
421        ordinal: u64,
422        flexibility: ::fidl_next::protocol::Flexibility,
423        body: ::fidl_next::Body<___T>,
424    ) -> ::core::result::Result<
425        (),
426        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
427    > {
428        match ordinal {
429            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
430        }
431    }
432
433    async fn on_two_way(
434        handler: &mut ___H,
435        ordinal: u64,
436        flexibility: ::fidl_next::protocol::Flexibility,
437        body: ::fidl_next::Body<___T>,
438        responder: ::fidl_next::protocol::Responder<___T>,
439    ) -> ::core::result::Result<
440        (),
441        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
442    > {
443        match ordinal {
444            7952116938191896180 => {
445                let responder = ::fidl_next::Responder::from_untyped(responder);
446
447                handler.get_hardware_id(responder).await;
448                Ok(())
449            }
450
451            6100331669860404750 => {
452                let responder = ::fidl_next::Responder::from_untyped(responder);
453
454                handler.get_event(responder).await;
455                Ok(())
456            }
457
458            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
459        }
460    }
461}
462
463pub use fidl_next_common_fuchsia_examples_gizmo::*;