fidl_fuchsia_examples_gizmo/
fidl_fuchsia_examples_gizmo.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_examples_gizmo__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DeviceGetEventResponse {
16    pub event: fidl::Event,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceGetEventResponse {}
20
21#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
22pub struct DeviceMarker;
23
24impl fidl::endpoints::ProtocolMarker for DeviceMarker {
25    type Proxy = DeviceProxy;
26    type RequestStream = DeviceRequestStream;
27    #[cfg(target_os = "fuchsia")]
28    type SynchronousProxy = DeviceSynchronousProxy;
29
30    const DEBUG_NAME: &'static str = "(anonymous) Device";
31}
32pub type DeviceGetHardwareIdResult = Result<u32, i32>;
33
34pub trait DeviceProxyInterface: Send + Sync {
35    type GetHardwareIdResponseFut: std::future::Future<Output = Result<DeviceGetHardwareIdResult, fidl::Error>>
36        + Send;
37    fn r#get_hardware_id(&self) -> Self::GetHardwareIdResponseFut;
38    type GetEventResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>> + Send;
39    fn r#get_event(&self) -> Self::GetEventResponseFut;
40}
41#[derive(Debug)]
42#[cfg(target_os = "fuchsia")]
43pub struct DeviceSynchronousProxy {
44    client: fidl::client::sync::Client,
45}
46
47#[cfg(target_os = "fuchsia")]
48impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
49    type Proxy = DeviceProxy;
50    type Protocol = DeviceMarker;
51
52    fn from_channel(inner: fidl::Channel) -> Self {
53        Self::new(inner)
54    }
55
56    fn into_channel(self) -> fidl::Channel {
57        self.client.into_channel()
58    }
59
60    fn as_channel(&self) -> &fidl::Channel {
61        self.client.as_channel()
62    }
63}
64
65#[cfg(target_os = "fuchsia")]
66impl DeviceSynchronousProxy {
67    pub fn new(channel: fidl::Channel) -> Self {
68        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
69        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
70    }
71
72    pub fn into_channel(self) -> fidl::Channel {
73        self.client.into_channel()
74    }
75
76    /// Waits until an event arrives and returns it. It is safe for other
77    /// threads to make concurrent requests while waiting for an event.
78    pub fn wait_for_event(
79        &self,
80        deadline: zx::MonotonicInstant,
81    ) -> Result<DeviceEvent, fidl::Error> {
82        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
83    }
84
85    /// Returns a unique identifier for this device.
86    pub fn r#get_hardware_id(
87        &self,
88        ___deadline: zx::MonotonicInstant,
89    ) -> Result<DeviceGetHardwareIdResult, fidl::Error> {
90        let _response = self.client.send_query::<
91            fidl::encoding::EmptyPayload,
92            fidl::encoding::ResultType<DeviceGetHardwareIdResponse, i32>,
93        >(
94            (),
95            0x6e5b9839214b7e74,
96            fidl::encoding::DynamicFlags::empty(),
97            ___deadline,
98        )?;
99        Ok(_response.map(|x| x.response))
100    }
101
102    /// Returns a zircon event object handle!
103    pub fn r#get_event(
104        &self,
105        ___deadline: zx::MonotonicInstant,
106    ) -> Result<fidl::Event, fidl::Error> {
107        let _response =
108            self.client.send_query::<fidl::encoding::EmptyPayload, DeviceGetEventResponse>(
109                (),
110                0x54a8bb5532184e0e,
111                fidl::encoding::DynamicFlags::empty(),
112                ___deadline,
113            )?;
114        Ok(_response.event)
115    }
116}
117
118#[cfg(target_os = "fuchsia")]
119impl From<DeviceSynchronousProxy> for zx::NullableHandle {
120    fn from(value: DeviceSynchronousProxy) -> Self {
121        value.into_channel().into()
122    }
123}
124
125#[cfg(target_os = "fuchsia")]
126impl From<fidl::Channel> for DeviceSynchronousProxy {
127    fn from(value: fidl::Channel) -> Self {
128        Self::new(value)
129    }
130}
131
132#[cfg(target_os = "fuchsia")]
133impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
134    type Protocol = DeviceMarker;
135
136    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
137        Self::new(value.into_channel())
138    }
139}
140
141#[derive(Debug, Clone)]
142pub struct DeviceProxy {
143    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
144}
145
146impl fidl::endpoints::Proxy for DeviceProxy {
147    type Protocol = DeviceMarker;
148
149    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
150        Self::new(inner)
151    }
152
153    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
154        self.client.into_channel().map_err(|client| Self { client })
155    }
156
157    fn as_channel(&self) -> &::fidl::AsyncChannel {
158        self.client.as_channel()
159    }
160}
161
162impl DeviceProxy {
163    /// Create a new Proxy for fuchsia.examples.gizmo/Device.
164    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
165        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
166        Self { client: fidl::client::Client::new(channel, protocol_name) }
167    }
168
169    /// Get a Stream of events from the remote end of the protocol.
170    ///
171    /// # Panics
172    ///
173    /// Panics if the event stream was already taken.
174    pub fn take_event_stream(&self) -> DeviceEventStream {
175        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
176    }
177
178    /// Returns a unique identifier for this device.
179    pub fn r#get_hardware_id(
180        &self,
181    ) -> fidl::client::QueryResponseFut<
182        DeviceGetHardwareIdResult,
183        fidl::encoding::DefaultFuchsiaResourceDialect,
184    > {
185        DeviceProxyInterface::r#get_hardware_id(self)
186    }
187
188    /// Returns a zircon event object handle!
189    pub fn r#get_event(
190        &self,
191    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
192    {
193        DeviceProxyInterface::r#get_event(self)
194    }
195}
196
197impl DeviceProxyInterface for DeviceProxy {
198    type GetHardwareIdResponseFut = fidl::client::QueryResponseFut<
199        DeviceGetHardwareIdResult,
200        fidl::encoding::DefaultFuchsiaResourceDialect,
201    >;
202    fn r#get_hardware_id(&self) -> Self::GetHardwareIdResponseFut {
203        fn _decode(
204            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
205        ) -> Result<DeviceGetHardwareIdResult, fidl::Error> {
206            let _response = fidl::client::decode_transaction_body::<
207                fidl::encoding::ResultType<DeviceGetHardwareIdResponse, i32>,
208                fidl::encoding::DefaultFuchsiaResourceDialect,
209                0x6e5b9839214b7e74,
210            >(_buf?)?;
211            Ok(_response.map(|x| x.response))
212        }
213        self.client
214            .send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetHardwareIdResult>(
215                (),
216                0x6e5b9839214b7e74,
217                fidl::encoding::DynamicFlags::empty(),
218                _decode,
219            )
220    }
221
222    type GetEventResponseFut =
223        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
224    fn r#get_event(&self) -> Self::GetEventResponseFut {
225        fn _decode(
226            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
227        ) -> Result<fidl::Event, fidl::Error> {
228            let _response = fidl::client::decode_transaction_body::<
229                DeviceGetEventResponse,
230                fidl::encoding::DefaultFuchsiaResourceDialect,
231                0x54a8bb5532184e0e,
232            >(_buf?)?;
233            Ok(_response.event)
234        }
235        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
236            (),
237            0x54a8bb5532184e0e,
238            fidl::encoding::DynamicFlags::empty(),
239            _decode,
240        )
241    }
242}
243
244pub struct DeviceEventStream {
245    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
246}
247
248impl std::marker::Unpin for DeviceEventStream {}
249
250impl futures::stream::FusedStream for DeviceEventStream {
251    fn is_terminated(&self) -> bool {
252        self.event_receiver.is_terminated()
253    }
254}
255
256impl futures::Stream for DeviceEventStream {
257    type Item = Result<DeviceEvent, fidl::Error>;
258
259    fn poll_next(
260        mut self: std::pin::Pin<&mut Self>,
261        cx: &mut std::task::Context<'_>,
262    ) -> std::task::Poll<Option<Self::Item>> {
263        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
264            &mut self.event_receiver,
265            cx
266        )?) {
267            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
268            None => std::task::Poll::Ready(None),
269        }
270    }
271}
272
273#[derive(Debug)]
274pub enum DeviceEvent {}
275
276impl DeviceEvent {
277    /// Decodes a message buffer as a [`DeviceEvent`].
278    fn decode(
279        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
280    ) -> Result<DeviceEvent, fidl::Error> {
281        let (bytes, _handles) = buf.split_mut();
282        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
283        debug_assert_eq!(tx_header.tx_id, 0);
284        match tx_header.ordinal {
285            _ => Err(fidl::Error::UnknownOrdinal {
286                ordinal: tx_header.ordinal,
287                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
288            }),
289        }
290    }
291}
292
293/// A Stream of incoming requests for fuchsia.examples.gizmo/Device.
294pub struct DeviceRequestStream {
295    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
296    is_terminated: bool,
297}
298
299impl std::marker::Unpin for DeviceRequestStream {}
300
301impl futures::stream::FusedStream for DeviceRequestStream {
302    fn is_terminated(&self) -> bool {
303        self.is_terminated
304    }
305}
306
307impl fidl::endpoints::RequestStream for DeviceRequestStream {
308    type Protocol = DeviceMarker;
309    type ControlHandle = DeviceControlHandle;
310
311    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
312        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
313    }
314
315    fn control_handle(&self) -> Self::ControlHandle {
316        DeviceControlHandle { inner: self.inner.clone() }
317    }
318
319    fn into_inner(
320        self,
321    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
322    {
323        (self.inner, self.is_terminated)
324    }
325
326    fn from_inner(
327        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
328        is_terminated: bool,
329    ) -> Self {
330        Self { inner, is_terminated }
331    }
332}
333
334impl futures::Stream for DeviceRequestStream {
335    type Item = Result<DeviceRequest, fidl::Error>;
336
337    fn poll_next(
338        mut self: std::pin::Pin<&mut Self>,
339        cx: &mut std::task::Context<'_>,
340    ) -> std::task::Poll<Option<Self::Item>> {
341        let this = &mut *self;
342        if this.inner.check_shutdown(cx) {
343            this.is_terminated = true;
344            return std::task::Poll::Ready(None);
345        }
346        if this.is_terminated {
347            panic!("polled DeviceRequestStream after completion");
348        }
349        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
350            |bytes, handles| {
351                match this.inner.channel().read_etc(cx, bytes, handles) {
352                    std::task::Poll::Ready(Ok(())) => {}
353                    std::task::Poll::Pending => return std::task::Poll::Pending,
354                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
355                        this.is_terminated = true;
356                        return std::task::Poll::Ready(None);
357                    }
358                    std::task::Poll::Ready(Err(e)) => {
359                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
360                            e.into(),
361                        ))));
362                    }
363                }
364
365                // A message has been received from the channel
366                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
367
368                std::task::Poll::Ready(Some(match header.ordinal {
369                    0x6e5b9839214b7e74 => {
370                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
371                        let mut req = fidl::new_empty!(
372                            fidl::encoding::EmptyPayload,
373                            fidl::encoding::DefaultFuchsiaResourceDialect
374                        );
375                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
376                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
377                        Ok(DeviceRequest::GetHardwareId {
378                            responder: DeviceGetHardwareIdResponder {
379                                control_handle: std::mem::ManuallyDrop::new(control_handle),
380                                tx_id: header.tx_id,
381                            },
382                        })
383                    }
384                    0x54a8bb5532184e0e => {
385                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
386                        let mut req = fidl::new_empty!(
387                            fidl::encoding::EmptyPayload,
388                            fidl::encoding::DefaultFuchsiaResourceDialect
389                        );
390                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
391                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
392                        Ok(DeviceRequest::GetEvent {
393                            responder: DeviceGetEventResponder {
394                                control_handle: std::mem::ManuallyDrop::new(control_handle),
395                                tx_id: header.tx_id,
396                            },
397                        })
398                    }
399                    _ => Err(fidl::Error::UnknownOrdinal {
400                        ordinal: header.ordinal,
401                        protocol_name:
402                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
403                    }),
404                }))
405            },
406        )
407    }
408}
409
410/// The protocol provides access to functions of the driver.
411#[derive(Debug)]
412pub enum DeviceRequest {
413    /// Returns a unique identifier for this device.
414    GetHardwareId { responder: DeviceGetHardwareIdResponder },
415    /// Returns a zircon event object handle!
416    GetEvent { responder: DeviceGetEventResponder },
417}
418
419impl DeviceRequest {
420    #[allow(irrefutable_let_patterns)]
421    pub fn into_get_hardware_id(self) -> Option<(DeviceGetHardwareIdResponder)> {
422        if let DeviceRequest::GetHardwareId { responder } = self { Some((responder)) } else { None }
423    }
424
425    #[allow(irrefutable_let_patterns)]
426    pub fn into_get_event(self) -> Option<(DeviceGetEventResponder)> {
427        if let DeviceRequest::GetEvent { responder } = self { Some((responder)) } else { None }
428    }
429
430    /// Name of the method defined in FIDL
431    pub fn method_name(&self) -> &'static str {
432        match *self {
433            DeviceRequest::GetHardwareId { .. } => "get_hardware_id",
434            DeviceRequest::GetEvent { .. } => "get_event",
435        }
436    }
437}
438
439#[derive(Debug, Clone)]
440pub struct DeviceControlHandle {
441    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
442}
443
444impl fidl::endpoints::ControlHandle for DeviceControlHandle {
445    fn shutdown(&self) {
446        self.inner.shutdown()
447    }
448
449    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
450        self.inner.shutdown_with_epitaph(status)
451    }
452
453    fn is_closed(&self) -> bool {
454        self.inner.channel().is_closed()
455    }
456    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
457        self.inner.channel().on_closed()
458    }
459
460    #[cfg(target_os = "fuchsia")]
461    fn signal_peer(
462        &self,
463        clear_mask: zx::Signals,
464        set_mask: zx::Signals,
465    ) -> Result<(), zx_status::Status> {
466        use fidl::Peered;
467        self.inner.channel().signal_peer(clear_mask, set_mask)
468    }
469}
470
471impl DeviceControlHandle {}
472
473#[must_use = "FIDL methods require a response to be sent"]
474#[derive(Debug)]
475pub struct DeviceGetHardwareIdResponder {
476    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
477    tx_id: u32,
478}
479
480/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
481/// if the responder is dropped without sending a response, so that the client
482/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
483impl std::ops::Drop for DeviceGetHardwareIdResponder {
484    fn drop(&mut self) {
485        self.control_handle.shutdown();
486        // Safety: drops once, never accessed again
487        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
488    }
489}
490
491impl fidl::endpoints::Responder for DeviceGetHardwareIdResponder {
492    type ControlHandle = DeviceControlHandle;
493
494    fn control_handle(&self) -> &DeviceControlHandle {
495        &self.control_handle
496    }
497
498    fn drop_without_shutdown(mut self) {
499        // Safety: drops once, never accessed again due to mem::forget
500        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
501        // Prevent Drop from running (which would shut down the channel)
502        std::mem::forget(self);
503    }
504}
505
506impl DeviceGetHardwareIdResponder {
507    /// Sends a response to the FIDL transaction.
508    ///
509    /// Sets the channel to shutdown if an error occurs.
510    pub fn send(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
511        let _result = self.send_raw(result);
512        if _result.is_err() {
513            self.control_handle.shutdown();
514        }
515        self.drop_without_shutdown();
516        _result
517    }
518
519    /// Similar to "send" but does not shutdown the channel if an error occurs.
520    pub fn send_no_shutdown_on_err(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
521        let _result = self.send_raw(result);
522        self.drop_without_shutdown();
523        _result
524    }
525
526    fn send_raw(&self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
527        self.control_handle
528            .inner
529            .send::<fidl::encoding::ResultType<DeviceGetHardwareIdResponse, i32>>(
530                result.map(|response| (response,)),
531                self.tx_id,
532                0x6e5b9839214b7e74,
533                fidl::encoding::DynamicFlags::empty(),
534            )
535    }
536}
537
538#[must_use = "FIDL methods require a response to be sent"]
539#[derive(Debug)]
540pub struct DeviceGetEventResponder {
541    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
542    tx_id: u32,
543}
544
545/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
546/// if the responder is dropped without sending a response, so that the client
547/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
548impl std::ops::Drop for DeviceGetEventResponder {
549    fn drop(&mut self) {
550        self.control_handle.shutdown();
551        // Safety: drops once, never accessed again
552        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
553    }
554}
555
556impl fidl::endpoints::Responder for DeviceGetEventResponder {
557    type ControlHandle = DeviceControlHandle;
558
559    fn control_handle(&self) -> &DeviceControlHandle {
560        &self.control_handle
561    }
562
563    fn drop_without_shutdown(mut self) {
564        // Safety: drops once, never accessed again due to mem::forget
565        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
566        // Prevent Drop from running (which would shut down the channel)
567        std::mem::forget(self);
568    }
569}
570
571impl DeviceGetEventResponder {
572    /// Sends a response to the FIDL transaction.
573    ///
574    /// Sets the channel to shutdown if an error occurs.
575    pub fn send(self, mut event: fidl::Event) -> Result<(), fidl::Error> {
576        let _result = self.send_raw(event);
577        if _result.is_err() {
578            self.control_handle.shutdown();
579        }
580        self.drop_without_shutdown();
581        _result
582    }
583
584    /// Similar to "send" but does not shutdown the channel if an error occurs.
585    pub fn send_no_shutdown_on_err(self, mut event: fidl::Event) -> Result<(), fidl::Error> {
586        let _result = self.send_raw(event);
587        self.drop_without_shutdown();
588        _result
589    }
590
591    fn send_raw(&self, mut event: fidl::Event) -> Result<(), fidl::Error> {
592        self.control_handle.inner.send::<DeviceGetEventResponse>(
593            (event,),
594            self.tx_id,
595            0x54a8bb5532184e0e,
596            fidl::encoding::DynamicFlags::empty(),
597        )
598    }
599}
600
601mod internal {
602    use super::*;
603
604    impl fidl::encoding::ResourceTypeMarker for DeviceGetEventResponse {
605        type Borrowed<'a> = &'a mut Self;
606        fn take_or_borrow<'a>(
607            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
608        ) -> Self::Borrowed<'a> {
609            value
610        }
611    }
612
613    unsafe impl fidl::encoding::TypeMarker for DeviceGetEventResponse {
614        type Owned = Self;
615
616        #[inline(always)]
617        fn inline_align(_context: fidl::encoding::Context) -> usize {
618            4
619        }
620
621        #[inline(always)]
622        fn inline_size(_context: fidl::encoding::Context) -> usize {
623            4
624        }
625    }
626
627    unsafe impl
628        fidl::encoding::Encode<
629            DeviceGetEventResponse,
630            fidl::encoding::DefaultFuchsiaResourceDialect,
631        > for &mut DeviceGetEventResponse
632    {
633        #[inline]
634        unsafe fn encode(
635            self,
636            encoder: &mut fidl::encoding::Encoder<
637                '_,
638                fidl::encoding::DefaultFuchsiaResourceDialect,
639            >,
640            offset: usize,
641            _depth: fidl::encoding::Depth,
642        ) -> fidl::Result<()> {
643            encoder.debug_check_bounds::<DeviceGetEventResponse>(offset);
644            // Delegate to tuple encoding.
645            fidl::encoding::Encode::<
646                DeviceGetEventResponse,
647                fidl::encoding::DefaultFuchsiaResourceDialect,
648            >::encode(
649                (<fidl::encoding::HandleType<
650                    fidl::Event,
651                    { fidl::ObjectType::EVENT.into_raw() },
652                    2147483648,
653                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
654                    &mut self.event
655                ),),
656                encoder,
657                offset,
658                _depth,
659            )
660        }
661    }
662    unsafe impl<
663        T0: fidl::encoding::Encode<
664                fidl::encoding::HandleType<
665                    fidl::Event,
666                    { fidl::ObjectType::EVENT.into_raw() },
667                    2147483648,
668                >,
669                fidl::encoding::DefaultFuchsiaResourceDialect,
670            >,
671    >
672        fidl::encoding::Encode<
673            DeviceGetEventResponse,
674            fidl::encoding::DefaultFuchsiaResourceDialect,
675        > for (T0,)
676    {
677        #[inline]
678        unsafe fn encode(
679            self,
680            encoder: &mut fidl::encoding::Encoder<
681                '_,
682                fidl::encoding::DefaultFuchsiaResourceDialect,
683            >,
684            offset: usize,
685            depth: fidl::encoding::Depth,
686        ) -> fidl::Result<()> {
687            encoder.debug_check_bounds::<DeviceGetEventResponse>(offset);
688            // Zero out padding regions. There's no need to apply masks
689            // because the unmasked parts will be overwritten by fields.
690            // Write the fields.
691            self.0.encode(encoder, offset + 0, depth)?;
692            Ok(())
693        }
694    }
695
696    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
697        for DeviceGetEventResponse
698    {
699        #[inline(always)]
700        fn new_empty() -> Self {
701            Self {
702                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
703            }
704        }
705
706        #[inline]
707        unsafe fn decode(
708            &mut self,
709            decoder: &mut fidl::encoding::Decoder<
710                '_,
711                fidl::encoding::DefaultFuchsiaResourceDialect,
712            >,
713            offset: usize,
714            _depth: fidl::encoding::Depth,
715        ) -> fidl::Result<()> {
716            decoder.debug_check_bounds::<Self>(offset);
717            // Verify that padding bytes are zero.
718            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
719            Ok(())
720        }
721    }
722}