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
5#[derive(Clone, Debug)]
6#[repr(C)]
7pub struct DeviceGetHardwareIdResponse {
8    pub response: u32,
9}
10
11impl ::fidl_next::Encodable for DeviceGetHardwareIdResponse {
12    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self, WireDeviceGetHardwareIdResponse> = unsafe {
13        ::fidl_next::CopyOptimization::enable_if(
14            true && <u32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
15        )
16    };
17
18    type Encoded = WireDeviceGetHardwareIdResponse;
19}
20
21unsafe impl<___E> ::fidl_next::Encode<___E> for DeviceGetHardwareIdResponse
22where
23    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
24{
25    #[inline]
26    fn encode(
27        self,
28        encoder: &mut ___E,
29        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
30    ) -> Result<(), ::fidl_next::EncodeError> {
31        ::fidl_next::munge! {
32            let Self::Encoded {
33                response,
34
35            } = out;
36        }
37
38        ::fidl_next::Encode::encode(self.response, encoder, response)?;
39
40        Ok(())
41    }
42}
43
44unsafe impl<___E> ::fidl_next::EncodeRef<___E> for DeviceGetHardwareIdResponse
45where
46    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
47{
48    #[inline]
49    fn encode_ref(
50        &self,
51        encoder: &mut ___E,
52        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
53    ) -> Result<(), ::fidl_next::EncodeError> {
54        ::fidl_next::munge! {
55            let Self::Encoded {
56                response,
57
58            } = out;
59        }
60
61        ::fidl_next::EncodeRef::encode_ref(&self.response, encoder, response)?;
62
63        Ok(())
64    }
65}
66
67impl ::fidl_next::EncodableOption for DeviceGetHardwareIdResponse {
68    type EncodedOption = ::fidl_next::WireBox<'static, WireDeviceGetHardwareIdResponse>;
69}
70
71unsafe impl<___E> ::fidl_next::EncodeOption<___E> for DeviceGetHardwareIdResponse
72where
73    ___E: ::fidl_next::Encoder + ?Sized,
74    DeviceGetHardwareIdResponse: ::fidl_next::Encode<___E>,
75{
76    #[inline]
77    fn encode_option(
78        this: Option<Self>,
79        encoder: &mut ___E,
80        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
81    ) -> Result<(), ::fidl_next::EncodeError> {
82        if let Some(inner) = this {
83            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
84            ::fidl_next::WireBox::encode_present(out);
85        } else {
86            ::fidl_next::WireBox::encode_absent(out);
87        }
88
89        Ok(())
90    }
91}
92
93unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for DeviceGetHardwareIdResponse
94where
95    ___E: ::fidl_next::Encoder + ?Sized,
96    DeviceGetHardwareIdResponse: ::fidl_next::EncodeRef<___E>,
97{
98    #[inline]
99    fn encode_option_ref(
100        this: Option<&Self>,
101        encoder: &mut ___E,
102        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
103    ) -> Result<(), ::fidl_next::EncodeError> {
104        if let Some(inner) = this {
105            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
106            ::fidl_next::WireBox::encode_present(out);
107        } else {
108            ::fidl_next::WireBox::encode_absent(out);
109        }
110
111        Ok(())
112    }
113}
114
115impl ::fidl_next::FromWire<WireDeviceGetHardwareIdResponse> for DeviceGetHardwareIdResponse {
116    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<WireDeviceGetHardwareIdResponse, Self> = unsafe {
117        ::fidl_next::CopyOptimization::enable_if(
118            true && <u32 as ::fidl_next::FromWire<::fidl_next::WireU32>>::COPY_OPTIMIZATION
119                .is_enabled(),
120        )
121    };
122
123    #[inline]
124    fn from_wire(wire: WireDeviceGetHardwareIdResponse) -> Self {
125        Self { response: ::fidl_next::FromWire::from_wire(wire.response) }
126    }
127}
128
129impl ::fidl_next::FromWireRef<WireDeviceGetHardwareIdResponse> for DeviceGetHardwareIdResponse {
130    #[inline]
131    fn from_wire_ref(wire: &WireDeviceGetHardwareIdResponse) -> Self {
132        Self { response: ::fidl_next::FromWireRef::from_wire_ref(&wire.response) }
133    }
134}
135
136/// The wire type corresponding to [`DeviceGetHardwareIdResponse`].
137#[derive(Clone, Debug)]
138#[repr(C)]
139pub struct WireDeviceGetHardwareIdResponse {
140    pub response: ::fidl_next::WireU32,
141}
142
143unsafe impl ::fidl_next::Wire for WireDeviceGetHardwareIdResponse {
144    type Decoded<'de> = WireDeviceGetHardwareIdResponse;
145
146    #[inline]
147    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
148}
149
150unsafe impl<___D> ::fidl_next::Decode<___D> for WireDeviceGetHardwareIdResponse
151where
152    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
153{
154    fn decode(
155        slot: ::fidl_next::Slot<'_, Self>,
156        decoder: &mut ___D,
157    ) -> Result<(), ::fidl_next::DecodeError> {
158        ::fidl_next::munge! {
159            let Self {
160                mut response,
161
162            } = slot;
163        }
164
165        ::fidl_next::Decode::decode(response.as_mut(), decoder)?;
166
167        Ok(())
168    }
169}
170
171#[derive(Debug)]
172#[repr(C)]
173pub struct DeviceGetEventResponse {
174    pub event: ::fidl_next::fuchsia::zx::Event,
175}
176
177impl ::fidl_next::Encodable for DeviceGetEventResponse {
178    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self, WireDeviceGetEventResponse> = unsafe {
179        ::fidl_next::CopyOptimization::enable_if(
180            true && <::fidl_next::fuchsia::zx::Event as ::fidl_next::Encodable>::COPY_OPTIMIZATION
181                .is_enabled(),
182        )
183    };
184
185    type Encoded = WireDeviceGetEventResponse;
186}
187
188unsafe impl<___E> ::fidl_next::Encode<___E> for DeviceGetEventResponse
189where
190    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
191    ___E: ::fidl_next::fuchsia::HandleEncoder,
192{
193    #[inline]
194    fn encode(
195        self,
196        encoder: &mut ___E,
197        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
198    ) -> Result<(), ::fidl_next::EncodeError> {
199        ::fidl_next::munge! {
200            let Self::Encoded {
201                event,
202
203            } = out;
204        }
205
206        ::fidl_next::Encode::encode(self.event, encoder, event)?;
207
208        Ok(())
209    }
210}
211
212impl ::fidl_next::EncodableOption for DeviceGetEventResponse {
213    type EncodedOption = ::fidl_next::WireBox<'static, WireDeviceGetEventResponse>;
214}
215
216unsafe impl<___E> ::fidl_next::EncodeOption<___E> for DeviceGetEventResponse
217where
218    ___E: ::fidl_next::Encoder + ?Sized,
219    DeviceGetEventResponse: ::fidl_next::Encode<___E>,
220{
221    #[inline]
222    fn encode_option(
223        this: Option<Self>,
224        encoder: &mut ___E,
225        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
226    ) -> Result<(), ::fidl_next::EncodeError> {
227        if let Some(inner) = this {
228            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
229            ::fidl_next::WireBox::encode_present(out);
230        } else {
231            ::fidl_next::WireBox::encode_absent(out);
232        }
233
234        Ok(())
235    }
236}
237
238impl ::fidl_next::FromWire<WireDeviceGetEventResponse> for DeviceGetEventResponse {
239    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<WireDeviceGetEventResponse, Self> = unsafe {
240        ::fidl_next::CopyOptimization::enable_if(
241            true && <::fidl_next::fuchsia::zx::Event as ::fidl_next::FromWire<
242                ::fidl_next::fuchsia::WireEvent,
243            >>::COPY_OPTIMIZATION
244                .is_enabled(),
245        )
246    };
247
248    #[inline]
249    fn from_wire(wire: WireDeviceGetEventResponse) -> Self {
250        Self { event: ::fidl_next::FromWire::from_wire(wire.event) }
251    }
252}
253
254/// The wire type corresponding to [`DeviceGetEventResponse`].
255#[derive(Debug)]
256#[repr(C)]
257pub struct WireDeviceGetEventResponse {
258    pub event: ::fidl_next::fuchsia::WireEvent,
259}
260
261unsafe impl ::fidl_next::Wire for WireDeviceGetEventResponse {
262    type Decoded<'de> = WireDeviceGetEventResponse;
263
264    #[inline]
265    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
266}
267
268unsafe impl<___D> ::fidl_next::Decode<___D> for WireDeviceGetEventResponse
269where
270    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
271    ___D: ::fidl_next::fuchsia::HandleDecoder,
272{
273    fn decode(
274        slot: ::fidl_next::Slot<'_, Self>,
275        decoder: &mut ___D,
276    ) -> Result<(), ::fidl_next::DecodeError> {
277        ::fidl_next::munge! {
278            let Self {
279                mut event,
280
281            } = slot;
282        }
283
284        ::fidl_next::Decode::decode(event.as_mut(), decoder)?;
285
286        Ok(())
287    }
288}
289
290/// The type corresponding to the Device protocol.
291#[doc = " The protocol provides access to functions of the driver.\n"]
292#[derive(Debug)]
293pub struct Device;
294
295pub mod device {
296    pub mod prelude {
297        pub use crate::{Device, DeviceClientHandler, DeviceServerHandler, device};
298
299        pub use crate::DeviceGetEventResponse;
300
301        pub use crate::DeviceGetHardwareIdResponse;
302    }
303
304    pub struct GetHardwareId;
305
306    impl ::fidl_next::Method for GetHardwareId {
307        const ORDINAL: u64 = 7952116938191896180;
308
309        type Protocol = crate::Device;
310
311        type Request = ();
312
313        type Response = ::fidl_next::WireResult<
314            'static,
315            crate::WireDeviceGetHardwareIdResponse,
316            ::fidl_next::WireI32,
317        >;
318    }
319
320    pub struct GetEvent;
321
322    impl ::fidl_next::Method for GetEvent {
323        const ORDINAL: u64 = 6100331669860404750;
324
325        type Protocol = crate::Device;
326
327        type Request = ();
328
329        type Response = crate::WireDeviceGetEventResponse;
330    }
331
332    mod ___detail {
333
334        unsafe impl<___T> ::fidl_next::Protocol<___T> for crate::Device
335        where
336            ___T: ::fidl_next::Transport,
337        {
338            type ClientSender = DeviceClientSender<___T>;
339            type ServerSender = DeviceServerSender<___T>;
340        }
341
342        /// The client sender for the `Device` protocol.
343        #[repr(transparent)]
344        pub struct DeviceClientSender<___T: ::fidl_next::Transport> {
345            #[allow(dead_code)]
346            sender: ::fidl_next::protocol::ClientSender<___T>,
347        }
348
349        impl<___T> DeviceClientSender<___T>
350        where
351            ___T: ::fidl_next::Transport,
352        {
353            #[doc = " Returns a unique identifier for this device.\n"]
354            pub fn get_hardware_id(
355                &self,
356            ) -> ::fidl_next::TwoWayFuture<'_, super::GetHardwareId, ___T> {
357                ::fidl_next::TwoWayFuture::from_untyped(
358                    self.sender.send_two_way(7952116938191896180, ()),
359                )
360            }
361
362            #[doc = " Returns a zircon event object handle!\n"]
363            pub fn get_event(&self) -> ::fidl_next::TwoWayFuture<'_, super::GetEvent, ___T> {
364                ::fidl_next::TwoWayFuture::from_untyped(
365                    self.sender.send_two_way(6100331669860404750, ()),
366                )
367            }
368        }
369
370        /// The server sender for the `Device` protocol.
371        #[repr(transparent)]
372        pub struct DeviceServerSender<___T: ::fidl_next::Transport> {
373            sender: ::fidl_next::protocol::ServerSender<___T>,
374        }
375
376        impl<___T> DeviceServerSender<___T> where ___T: ::fidl_next::Transport {}
377    }
378}
379
380/// A client handler for the Device protocol.
381///
382/// See [`Device`] for more details.
383pub trait DeviceClientHandler<
384    #[cfg(not(feature = "fuchsia"))] ___T: ::fidl_next::Transport,
385    #[cfg(feature = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
386>
387{
388}
389
390impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Device
391where
392    ___H: DeviceClientHandler<___T> + ::core::marker::Send,
393    ___T: ::fidl_next::Transport,
394    <device::GetHardwareId as ::fidl_next::Method>::Response:
395        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
396    <device::GetEvent as ::fidl_next::Method>::Response:
397        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
398{
399    async fn on_event(
400        handler: &mut ___H,
401        sender: &::fidl_next::ClientSender<Self, ___T>,
402        ordinal: u64,
403        buffer: ___T::RecvBuffer,
404    ) {
405        match ordinal {
406            ordinal => sender.close(),
407        }
408    }
409}
410
411/// A server handler for the Device protocol.
412///
413/// See [`Device`] for more details.
414pub trait DeviceServerHandler<
415    #[cfg(not(feature = "fuchsia"))] ___T: ::fidl_next::Transport,
416    #[cfg(feature = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
417>
418{
419    #[doc = " Returns a unique identifier for this device.\n"]
420    fn get_hardware_id(
421        &mut self,
422        sender: &::fidl_next::ServerSender<Device, ___T>,
423
424        responder: ::fidl_next::Responder<device::GetHardwareId>,
425    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
426
427    #[doc = " Returns a zircon event object handle!\n"]
428    fn get_event(
429        &mut self,
430        sender: &::fidl_next::ServerSender<Device, ___T>,
431
432        responder: ::fidl_next::Responder<device::GetEvent>,
433    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
434}
435
436impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Device
437where
438    ___H: DeviceServerHandler<___T> + ::core::marker::Send,
439    ___T: ::fidl_next::Transport,
440{
441    async fn on_one_way(
442        handler: &mut ___H,
443        sender: &::fidl_next::ServerSender<Self, ___T>,
444        ordinal: u64,
445        buffer: ___T::RecvBuffer,
446    ) {
447        match ordinal {
448            ordinal => sender.close(),
449        }
450    }
451
452    async fn on_two_way(
453        handler: &mut ___H,
454        sender: &::fidl_next::ServerSender<Self, ___T>,
455        ordinal: u64,
456        buffer: ___T::RecvBuffer,
457        responder: ::fidl_next::protocol::Responder,
458    ) {
459        match ordinal {
460            7952116938191896180 => {
461                let responder = ::fidl_next::Responder::from_untyped(responder);
462
463                handler.get_hardware_id(sender, responder).await;
464            }
465
466            6100331669860404750 => {
467                let responder = ::fidl_next::Responder::from_untyped(responder);
468
469                handler.get_event(sender, responder).await;
470            }
471
472            ordinal => sender.close(),
473        }
474    }
475}
476
477/// Compatibility shims which mimic some API surfaces of the current Rust bindings.
478pub mod compat {
479
480    #[cfg(feature = "driver")]
481    impl ::fidl_next::CompatFrom<crate::DeviceGetHardwareIdResponse>
482        for ::fidl_fuchsia_examples_gizmo::DeviceGetHardwareIdResponse
483    {
484        #[inline]
485        fn compat_from(value: crate::DeviceGetHardwareIdResponse) -> Self {
486            Self { response: ::fidl_next::CompatFrom::compat_from(value.response) }
487        }
488    }
489
490    #[cfg(feature = "driver")]
491    impl ::fidl_next::CompatFrom<::fidl_fuchsia_examples_gizmo::DeviceGetHardwareIdResponse>
492        for crate::DeviceGetHardwareIdResponse
493    {
494        #[inline]
495        fn compat_from(value: ::fidl_fuchsia_examples_gizmo::DeviceGetHardwareIdResponse) -> Self {
496            Self { response: ::fidl_next::CompatFrom::compat_from(value.response) }
497        }
498    }
499
500    #[cfg(feature = "driver")]
501    impl ::fidl_next::CompatFrom<crate::DeviceGetEventResponse>
502        for ::fidl_fuchsia_examples_gizmo::DeviceGetEventResponse
503    {
504        #[inline]
505        fn compat_from(value: crate::DeviceGetEventResponse) -> Self {
506            Self { event: ::fidl_next::CompatFrom::compat_from(value.event) }
507        }
508    }
509
510    #[cfg(feature = "driver")]
511    impl ::fidl_next::CompatFrom<::fidl_fuchsia_examples_gizmo::DeviceGetEventResponse>
512        for crate::DeviceGetEventResponse
513    {
514        #[inline]
515        fn compat_from(value: ::fidl_fuchsia_examples_gizmo::DeviceGetEventResponse) -> Self {
516            Self { event: ::fidl_next::CompatFrom::compat_from(value.event) }
517        }
518    }
519
520    #[cfg(target_os = "fuchsia")]
521    /// An alias for a client sender over `zx::Channel` for the `Device`
522    /// protocol.
523    pub type DeviceProxy = ::fidl_next::ClientSender<crate::Device>;
524
525    #[cfg(feature = "driver")]
526    impl ::fidl_next::CompatFrom<crate::Device> for ::fidl_fuchsia_examples_gizmo::DeviceMarker {
527        fn compat_from(_: crate::Device) -> Self {
528            Self
529        }
530    }
531
532    #[cfg(feature = "driver")]
533    impl ::fidl_next::CompatFrom<::fidl_fuchsia_examples_gizmo::DeviceMarker> for crate::Device {
534        fn compat_from(_: ::fidl_fuchsia_examples_gizmo::DeviceMarker) -> Self {
535            Self
536        }
537    }
538}