Skip to main content

fidl_fuchsia_hardware_platform_bus/
fidl_fuchsia_hardware_platform_bus.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_hardware_platform_bus__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct FirmwareBlob {
16    pub vmo: fidl::Vmo,
17    pub length: u64,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for FirmwareBlob {}
21
22#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
23pub struct InterruptAttributorGetInterruptInfoResponse {
24    /// The name of the device which the board driver gave to the device the interrupt
25    /// was assigned to.
26    pub device_name: String,
27    /// Token that represents the driver component instance which the interrupt was given to.
28    /// It may be be exchanged with the driver framework or component framework to learn more
29    /// information about component, such as it's URL or moniker.
30    ///
31    /// If a driver has not yet bound to the device and taken control of the interrupt yet,
32    /// it will not yet be present.
33    pub component_token: Option<fidl::Event>,
34}
35
36impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
37    for InterruptAttributorGetInterruptInfoResponse
38{
39}
40
41#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
42pub struct InterruptAttributorMarker;
43
44impl fidl::endpoints::ProtocolMarker for InterruptAttributorMarker {
45    type Proxy = InterruptAttributorProxy;
46    type RequestStream = InterruptAttributorRequestStream;
47    #[cfg(target_os = "fuchsia")]
48    type SynchronousProxy = InterruptAttributorSynchronousProxy;
49
50    const DEBUG_NAME: &'static str = "(anonymous) InterruptAttributor";
51}
52pub type InterruptAttributorGetInterruptInfoResult = Result<(String, Option<fidl::Event>), i32>;
53
54pub trait InterruptAttributorProxyInterface: Send + Sync {
55    type GetInterruptInfoResponseFut: std::future::Future<Output = Result<InterruptAttributorGetInterruptInfoResult, fidl::Error>>
56        + Send;
57    fn r#get_interrupt_info(
58        &self,
59        payload: &InterruptAttributorGetInterruptInfoRequest,
60    ) -> Self::GetInterruptInfoResponseFut;
61}
62#[derive(Debug)]
63#[cfg(target_os = "fuchsia")]
64pub struct InterruptAttributorSynchronousProxy {
65    client: fidl::client::sync::Client,
66}
67
68#[cfg(target_os = "fuchsia")]
69impl fidl::endpoints::SynchronousProxy for InterruptAttributorSynchronousProxy {
70    type Proxy = InterruptAttributorProxy;
71    type Protocol = InterruptAttributorMarker;
72
73    fn from_channel(inner: fidl::Channel) -> Self {
74        Self::new(inner)
75    }
76
77    fn into_channel(self) -> fidl::Channel {
78        self.client.into_channel()
79    }
80
81    fn as_channel(&self) -> &fidl::Channel {
82        self.client.as_channel()
83    }
84}
85
86#[cfg(target_os = "fuchsia")]
87impl InterruptAttributorSynchronousProxy {
88    pub fn new(channel: fidl::Channel) -> Self {
89        let protocol_name =
90            <InterruptAttributorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
91        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
92    }
93
94    pub fn into_channel(self) -> fidl::Channel {
95        self.client.into_channel()
96    }
97
98    /// Waits until an event arrives and returns it. It is safe for other
99    /// threads to make concurrent requests while waiting for an event.
100    pub fn wait_for_event(
101        &self,
102        deadline: zx::MonotonicInstant,
103    ) -> Result<InterruptAttributorEvent, fidl::Error> {
104        InterruptAttributorEvent::decode(self.client.wait_for_event(deadline)?)
105    }
106
107    pub fn r#get_interrupt_info(
108        &self,
109        mut payload: &InterruptAttributorGetInterruptInfoRequest,
110        ___deadline: zx::MonotonicInstant,
111    ) -> Result<InterruptAttributorGetInterruptInfoResult, fidl::Error> {
112        let _response = self.client.send_query::<
113            InterruptAttributorGetInterruptInfoRequest,
114            fidl::encoding::ResultType<InterruptAttributorGetInterruptInfoResponse, i32>,
115        >(
116            payload,
117            0x28561a2dbdb9a3c9,
118            fidl::encoding::DynamicFlags::empty(),
119            ___deadline,
120        )?;
121        Ok(_response.map(|x| (x.device_name, x.component_token)))
122    }
123}
124
125#[cfg(target_os = "fuchsia")]
126impl From<InterruptAttributorSynchronousProxy> for zx::NullableHandle {
127    fn from(value: InterruptAttributorSynchronousProxy) -> Self {
128        value.into_channel().into()
129    }
130}
131
132#[cfg(target_os = "fuchsia")]
133impl From<fidl::Channel> for InterruptAttributorSynchronousProxy {
134    fn from(value: fidl::Channel) -> Self {
135        Self::new(value)
136    }
137}
138
139#[cfg(target_os = "fuchsia")]
140impl fidl::endpoints::FromClient for InterruptAttributorSynchronousProxy {
141    type Protocol = InterruptAttributorMarker;
142
143    fn from_client(value: fidl::endpoints::ClientEnd<InterruptAttributorMarker>) -> Self {
144        Self::new(value.into_channel())
145    }
146}
147
148#[derive(Debug, Clone)]
149pub struct InterruptAttributorProxy {
150    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
151}
152
153impl fidl::endpoints::Proxy for InterruptAttributorProxy {
154    type Protocol = InterruptAttributorMarker;
155
156    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
157        Self::new(inner)
158    }
159
160    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
161        self.client.into_channel().map_err(|client| Self { client })
162    }
163
164    fn as_channel(&self) -> &::fidl::AsyncChannel {
165        self.client.as_channel()
166    }
167}
168
169impl InterruptAttributorProxy {
170    /// Create a new Proxy for fuchsia.hardware.platform.bus/InterruptAttributor.
171    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
172        let protocol_name =
173            <InterruptAttributorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
174        Self { client: fidl::client::Client::new(channel, protocol_name) }
175    }
176
177    /// Get a Stream of events from the remote end of the protocol.
178    ///
179    /// # Panics
180    ///
181    /// Panics if the event stream was already taken.
182    pub fn take_event_stream(&self) -> InterruptAttributorEventStream {
183        InterruptAttributorEventStream { event_receiver: self.client.take_event_receiver() }
184    }
185
186    pub fn r#get_interrupt_info(
187        &self,
188        mut payload: &InterruptAttributorGetInterruptInfoRequest,
189    ) -> fidl::client::QueryResponseFut<
190        InterruptAttributorGetInterruptInfoResult,
191        fidl::encoding::DefaultFuchsiaResourceDialect,
192    > {
193        InterruptAttributorProxyInterface::r#get_interrupt_info(self, payload)
194    }
195}
196
197impl InterruptAttributorProxyInterface for InterruptAttributorProxy {
198    type GetInterruptInfoResponseFut = fidl::client::QueryResponseFut<
199        InterruptAttributorGetInterruptInfoResult,
200        fidl::encoding::DefaultFuchsiaResourceDialect,
201    >;
202    fn r#get_interrupt_info(
203        &self,
204        mut payload: &InterruptAttributorGetInterruptInfoRequest,
205    ) -> Self::GetInterruptInfoResponseFut {
206        fn _decode(
207            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
208        ) -> Result<InterruptAttributorGetInterruptInfoResult, fidl::Error> {
209            let _response = fidl::client::decode_transaction_body::<
210                fidl::encoding::ResultType<InterruptAttributorGetInterruptInfoResponse, i32>,
211                fidl::encoding::DefaultFuchsiaResourceDialect,
212                0x28561a2dbdb9a3c9,
213            >(_buf?)?;
214            Ok(_response.map(|x| (x.device_name, x.component_token)))
215        }
216        self.client.send_query_and_decode::<
217            InterruptAttributorGetInterruptInfoRequest,
218            InterruptAttributorGetInterruptInfoResult,
219        >(
220            payload,
221            0x28561a2dbdb9a3c9,
222            fidl::encoding::DynamicFlags::empty(),
223            _decode,
224        )
225    }
226}
227
228pub struct InterruptAttributorEventStream {
229    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
230}
231
232impl std::marker::Unpin for InterruptAttributorEventStream {}
233
234impl futures::stream::FusedStream for InterruptAttributorEventStream {
235    fn is_terminated(&self) -> bool {
236        self.event_receiver.is_terminated()
237    }
238}
239
240impl futures::Stream for InterruptAttributorEventStream {
241    type Item = Result<InterruptAttributorEvent, fidl::Error>;
242
243    fn poll_next(
244        mut self: std::pin::Pin<&mut Self>,
245        cx: &mut std::task::Context<'_>,
246    ) -> std::task::Poll<Option<Self::Item>> {
247        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
248            &mut self.event_receiver,
249            cx
250        )?) {
251            Some(buf) => std::task::Poll::Ready(Some(InterruptAttributorEvent::decode(buf))),
252            None => std::task::Poll::Ready(None),
253        }
254    }
255}
256
257#[derive(Debug)]
258pub enum InterruptAttributorEvent {}
259
260impl InterruptAttributorEvent {
261    /// Decodes a message buffer as a [`InterruptAttributorEvent`].
262    fn decode(
263        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
264    ) -> Result<InterruptAttributorEvent, fidl::Error> {
265        let (bytes, _handles) = buf.split_mut();
266        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
267        debug_assert_eq!(tx_header.tx_id, 0);
268        match tx_header.ordinal {
269            _ => Err(fidl::Error::UnknownOrdinal {
270                ordinal: tx_header.ordinal,
271                protocol_name:
272                    <InterruptAttributorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
273            }),
274        }
275    }
276}
277
278/// A Stream of incoming requests for fuchsia.hardware.platform.bus/InterruptAttributor.
279pub struct InterruptAttributorRequestStream {
280    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
281    is_terminated: bool,
282}
283
284impl std::marker::Unpin for InterruptAttributorRequestStream {}
285
286impl futures::stream::FusedStream for InterruptAttributorRequestStream {
287    fn is_terminated(&self) -> bool {
288        self.is_terminated
289    }
290}
291
292impl fidl::endpoints::RequestStream for InterruptAttributorRequestStream {
293    type Protocol = InterruptAttributorMarker;
294    type ControlHandle = InterruptAttributorControlHandle;
295
296    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
297        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
298    }
299
300    fn control_handle(&self) -> Self::ControlHandle {
301        InterruptAttributorControlHandle { inner: self.inner.clone() }
302    }
303
304    fn into_inner(
305        self,
306    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
307    {
308        (self.inner, self.is_terminated)
309    }
310
311    fn from_inner(
312        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
313        is_terminated: bool,
314    ) -> Self {
315        Self { inner, is_terminated }
316    }
317}
318
319impl futures::Stream for InterruptAttributorRequestStream {
320    type Item = Result<InterruptAttributorRequest, fidl::Error>;
321
322    fn poll_next(
323        mut self: std::pin::Pin<&mut Self>,
324        cx: &mut std::task::Context<'_>,
325    ) -> std::task::Poll<Option<Self::Item>> {
326        let this = &mut *self;
327        if this.inner.check_shutdown(cx) {
328            this.is_terminated = true;
329            return std::task::Poll::Ready(None);
330        }
331        if this.is_terminated {
332            panic!("polled InterruptAttributorRequestStream after completion");
333        }
334        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
335            |bytes, handles| {
336                match this.inner.channel().read_etc(cx, bytes, handles) {
337                    std::task::Poll::Ready(Ok(())) => {}
338                    std::task::Poll::Pending => return std::task::Poll::Pending,
339                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
340                        this.is_terminated = true;
341                        return std::task::Poll::Ready(None);
342                    }
343                    std::task::Poll::Ready(Err(e)) => {
344                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
345                            e.into(),
346                        ))));
347                    }
348                }
349
350                // A message has been received from the channel
351                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
352
353                std::task::Poll::Ready(Some(match header.ordinal {
354                0x28561a2dbdb9a3c9 => {
355                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
356                    let mut req = fidl::new_empty!(InterruptAttributorGetInterruptInfoRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
357                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InterruptAttributorGetInterruptInfoRequest>(&header, _body_bytes, handles, &mut req)?;
358                    let control_handle = InterruptAttributorControlHandle {
359                        inner: this.inner.clone(),
360                    };
361                    Ok(InterruptAttributorRequest::GetInterruptInfo {payload: req,
362                        responder: InterruptAttributorGetInterruptInfoResponder {
363                            control_handle: std::mem::ManuallyDrop::new(control_handle),
364                            tx_id: header.tx_id,
365                        },
366                    })
367                }
368                _ => Err(fidl::Error::UnknownOrdinal {
369                    ordinal: header.ordinal,
370                    protocol_name: <InterruptAttributorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
371                }),
372            }))
373            },
374        )
375    }
376}
377
378/// Provides information related to interrupts assigned by the board driver to various
379/// devices.
380#[derive(Debug)]
381pub enum InterruptAttributorRequest {
382    GetInterruptInfo {
383        payload: InterruptAttributorGetInterruptInfoRequest,
384        responder: InterruptAttributorGetInterruptInfoResponder,
385    },
386}
387
388impl InterruptAttributorRequest {
389    #[allow(irrefutable_let_patterns)]
390    pub fn into_get_interrupt_info(
391        self,
392    ) -> Option<(
393        InterruptAttributorGetInterruptInfoRequest,
394        InterruptAttributorGetInterruptInfoResponder,
395    )> {
396        if let InterruptAttributorRequest::GetInterruptInfo { payload, responder } = self {
397            Some((payload, responder))
398        } else {
399            None
400        }
401    }
402
403    /// Name of the method defined in FIDL
404    pub fn method_name(&self) -> &'static str {
405        match *self {
406            InterruptAttributorRequest::GetInterruptInfo { .. } => "get_interrupt_info",
407        }
408    }
409}
410
411#[derive(Debug, Clone)]
412pub struct InterruptAttributorControlHandle {
413    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
414}
415
416impl fidl::endpoints::ControlHandle for InterruptAttributorControlHandle {
417    fn shutdown(&self) {
418        self.inner.shutdown()
419    }
420
421    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
422        self.inner.shutdown_with_epitaph(status)
423    }
424
425    fn is_closed(&self) -> bool {
426        self.inner.channel().is_closed()
427    }
428    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
429        self.inner.channel().on_closed()
430    }
431
432    #[cfg(target_os = "fuchsia")]
433    fn signal_peer(
434        &self,
435        clear_mask: zx::Signals,
436        set_mask: zx::Signals,
437    ) -> Result<(), zx_status::Status> {
438        use fidl::Peered;
439        self.inner.channel().signal_peer(clear_mask, set_mask)
440    }
441}
442
443impl InterruptAttributorControlHandle {}
444
445#[must_use = "FIDL methods require a response to be sent"]
446#[derive(Debug)]
447pub struct InterruptAttributorGetInterruptInfoResponder {
448    control_handle: std::mem::ManuallyDrop<InterruptAttributorControlHandle>,
449    tx_id: u32,
450}
451
452/// Set the the channel to be shutdown (see [`InterruptAttributorControlHandle::shutdown`])
453/// if the responder is dropped without sending a response, so that the client
454/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
455impl std::ops::Drop for InterruptAttributorGetInterruptInfoResponder {
456    fn drop(&mut self) {
457        self.control_handle.shutdown();
458        // Safety: drops once, never accessed again
459        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
460    }
461}
462
463impl fidl::endpoints::Responder for InterruptAttributorGetInterruptInfoResponder {
464    type ControlHandle = InterruptAttributorControlHandle;
465
466    fn control_handle(&self) -> &InterruptAttributorControlHandle {
467        &self.control_handle
468    }
469
470    fn drop_without_shutdown(mut self) {
471        // Safety: drops once, never accessed again due to mem::forget
472        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
473        // Prevent Drop from running (which would shut down the channel)
474        std::mem::forget(self);
475    }
476}
477
478impl InterruptAttributorGetInterruptInfoResponder {
479    /// Sends a response to the FIDL transaction.
480    ///
481    /// Sets the channel to shutdown if an error occurs.
482    pub fn send(
483        self,
484        mut result: Result<(&str, Option<fidl::Event>), i32>,
485    ) -> Result<(), fidl::Error> {
486        let _result = self.send_raw(result);
487        if _result.is_err() {
488            self.control_handle.shutdown();
489        }
490        self.drop_without_shutdown();
491        _result
492    }
493
494    /// Similar to "send" but does not shutdown the channel if an error occurs.
495    pub fn send_no_shutdown_on_err(
496        self,
497        mut result: Result<(&str, Option<fidl::Event>), i32>,
498    ) -> Result<(), fidl::Error> {
499        let _result = self.send_raw(result);
500        self.drop_without_shutdown();
501        _result
502    }
503
504    fn send_raw(
505        &self,
506        mut result: Result<(&str, Option<fidl::Event>), i32>,
507    ) -> Result<(), fidl::Error> {
508        self.control_handle.inner.send::<fidl::encoding::ResultType<
509            InterruptAttributorGetInterruptInfoResponse,
510            i32,
511        >>(
512            result,
513            self.tx_id,
514            0x28561a2dbdb9a3c9,
515            fidl::encoding::DynamicFlags::empty(),
516        )
517    }
518}
519
520#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
521pub struct SysSuspendMarker;
522
523impl fidl::endpoints::ProtocolMarker for SysSuspendMarker {
524    type Proxy = SysSuspendProxy;
525    type RequestStream = SysSuspendRequestStream;
526    #[cfg(target_os = "fuchsia")]
527    type SynchronousProxy = SysSuspendSynchronousProxy;
528
529    const DEBUG_NAME: &'static str = "(anonymous) SysSuspend";
530}
531
532pub trait SysSuspendProxyInterface: Send + Sync {
533    type CallbackResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
534    fn r#callback(&self, enable_wake: bool, suspend_reason: u8) -> Self::CallbackResponseFut;
535}
536#[derive(Debug)]
537#[cfg(target_os = "fuchsia")]
538pub struct SysSuspendSynchronousProxy {
539    client: fidl::client::sync::Client,
540}
541
542#[cfg(target_os = "fuchsia")]
543impl fidl::endpoints::SynchronousProxy for SysSuspendSynchronousProxy {
544    type Proxy = SysSuspendProxy;
545    type Protocol = SysSuspendMarker;
546
547    fn from_channel(inner: fidl::Channel) -> Self {
548        Self::new(inner)
549    }
550
551    fn into_channel(self) -> fidl::Channel {
552        self.client.into_channel()
553    }
554
555    fn as_channel(&self) -> &fidl::Channel {
556        self.client.as_channel()
557    }
558}
559
560#[cfg(target_os = "fuchsia")]
561impl SysSuspendSynchronousProxy {
562    pub fn new(channel: fidl::Channel) -> Self {
563        let protocol_name = <SysSuspendMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
564        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
565    }
566
567    pub fn into_channel(self) -> fidl::Channel {
568        self.client.into_channel()
569    }
570
571    /// Waits until an event arrives and returns it. It is safe for other
572    /// threads to make concurrent requests while waiting for an event.
573    pub fn wait_for_event(
574        &self,
575        deadline: zx::MonotonicInstant,
576    ) -> Result<SysSuspendEvent, fidl::Error> {
577        SysSuspendEvent::decode(self.client.wait_for_event(deadline)?)
578    }
579
580    /// Invoked by the platform bus when its suspend hook is called.
581    pub fn r#callback(
582        &self,
583        mut enable_wake: bool,
584        mut suspend_reason: u8,
585        ___deadline: zx::MonotonicInstant,
586    ) -> Result<i32, fidl::Error> {
587        let _response =
588            self.client.send_query::<SysSuspendCallbackRequest, SysSuspendCallbackResponse>(
589                (enable_wake, suspend_reason),
590                0x2627dec0f8b3633,
591                fidl::encoding::DynamicFlags::empty(),
592                ___deadline,
593            )?;
594        Ok(_response.out_status)
595    }
596}
597
598#[cfg(target_os = "fuchsia")]
599impl From<SysSuspendSynchronousProxy> for zx::NullableHandle {
600    fn from(value: SysSuspendSynchronousProxy) -> Self {
601        value.into_channel().into()
602    }
603}
604
605#[cfg(target_os = "fuchsia")]
606impl From<fidl::Channel> for SysSuspendSynchronousProxy {
607    fn from(value: fidl::Channel) -> Self {
608        Self::new(value)
609    }
610}
611
612#[cfg(target_os = "fuchsia")]
613impl fidl::endpoints::FromClient for SysSuspendSynchronousProxy {
614    type Protocol = SysSuspendMarker;
615
616    fn from_client(value: fidl::endpoints::ClientEnd<SysSuspendMarker>) -> Self {
617        Self::new(value.into_channel())
618    }
619}
620
621#[derive(Debug, Clone)]
622pub struct SysSuspendProxy {
623    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
624}
625
626impl fidl::endpoints::Proxy for SysSuspendProxy {
627    type Protocol = SysSuspendMarker;
628
629    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
630        Self::new(inner)
631    }
632
633    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
634        self.client.into_channel().map_err(|client| Self { client })
635    }
636
637    fn as_channel(&self) -> &::fidl::AsyncChannel {
638        self.client.as_channel()
639    }
640}
641
642impl SysSuspendProxy {
643    /// Create a new Proxy for fuchsia.hardware.platform.bus/SysSuspend.
644    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
645        let protocol_name = <SysSuspendMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
646        Self { client: fidl::client::Client::new(channel, protocol_name) }
647    }
648
649    /// Get a Stream of events from the remote end of the protocol.
650    ///
651    /// # Panics
652    ///
653    /// Panics if the event stream was already taken.
654    pub fn take_event_stream(&self) -> SysSuspendEventStream {
655        SysSuspendEventStream { event_receiver: self.client.take_event_receiver() }
656    }
657
658    /// Invoked by the platform bus when its suspend hook is called.
659    pub fn r#callback(
660        &self,
661        mut enable_wake: bool,
662        mut suspend_reason: u8,
663    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
664        SysSuspendProxyInterface::r#callback(self, enable_wake, suspend_reason)
665    }
666}
667
668impl SysSuspendProxyInterface for SysSuspendProxy {
669    type CallbackResponseFut =
670        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
671    fn r#callback(
672        &self,
673        mut enable_wake: bool,
674        mut suspend_reason: u8,
675    ) -> Self::CallbackResponseFut {
676        fn _decode(
677            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
678        ) -> Result<i32, fidl::Error> {
679            let _response = fidl::client::decode_transaction_body::<
680                SysSuspendCallbackResponse,
681                fidl::encoding::DefaultFuchsiaResourceDialect,
682                0x2627dec0f8b3633,
683            >(_buf?)?;
684            Ok(_response.out_status)
685        }
686        self.client.send_query_and_decode::<SysSuspendCallbackRequest, i32>(
687            (enable_wake, suspend_reason),
688            0x2627dec0f8b3633,
689            fidl::encoding::DynamicFlags::empty(),
690            _decode,
691        )
692    }
693}
694
695pub struct SysSuspendEventStream {
696    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
697}
698
699impl std::marker::Unpin for SysSuspendEventStream {}
700
701impl futures::stream::FusedStream for SysSuspendEventStream {
702    fn is_terminated(&self) -> bool {
703        self.event_receiver.is_terminated()
704    }
705}
706
707impl futures::Stream for SysSuspendEventStream {
708    type Item = Result<SysSuspendEvent, fidl::Error>;
709
710    fn poll_next(
711        mut self: std::pin::Pin<&mut Self>,
712        cx: &mut std::task::Context<'_>,
713    ) -> std::task::Poll<Option<Self::Item>> {
714        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
715            &mut self.event_receiver,
716            cx
717        )?) {
718            Some(buf) => std::task::Poll::Ready(Some(SysSuspendEvent::decode(buf))),
719            None => std::task::Poll::Ready(None),
720        }
721    }
722}
723
724#[derive(Debug)]
725pub enum SysSuspendEvent {}
726
727impl SysSuspendEvent {
728    /// Decodes a message buffer as a [`SysSuspendEvent`].
729    fn decode(
730        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
731    ) -> Result<SysSuspendEvent, fidl::Error> {
732        let (bytes, _handles) = buf.split_mut();
733        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
734        debug_assert_eq!(tx_header.tx_id, 0);
735        match tx_header.ordinal {
736            _ => Err(fidl::Error::UnknownOrdinal {
737                ordinal: tx_header.ordinal,
738                protocol_name: <SysSuspendMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
739            }),
740        }
741    }
742}
743
744/// A Stream of incoming requests for fuchsia.hardware.platform.bus/SysSuspend.
745pub struct SysSuspendRequestStream {
746    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
747    is_terminated: bool,
748}
749
750impl std::marker::Unpin for SysSuspendRequestStream {}
751
752impl futures::stream::FusedStream for SysSuspendRequestStream {
753    fn is_terminated(&self) -> bool {
754        self.is_terminated
755    }
756}
757
758impl fidl::endpoints::RequestStream for SysSuspendRequestStream {
759    type Protocol = SysSuspendMarker;
760    type ControlHandle = SysSuspendControlHandle;
761
762    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
763        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
764    }
765
766    fn control_handle(&self) -> Self::ControlHandle {
767        SysSuspendControlHandle { inner: self.inner.clone() }
768    }
769
770    fn into_inner(
771        self,
772    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
773    {
774        (self.inner, self.is_terminated)
775    }
776
777    fn from_inner(
778        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
779        is_terminated: bool,
780    ) -> Self {
781        Self { inner, is_terminated }
782    }
783}
784
785impl futures::Stream for SysSuspendRequestStream {
786    type Item = Result<SysSuspendRequest, fidl::Error>;
787
788    fn poll_next(
789        mut self: std::pin::Pin<&mut Self>,
790        cx: &mut std::task::Context<'_>,
791    ) -> std::task::Poll<Option<Self::Item>> {
792        let this = &mut *self;
793        if this.inner.check_shutdown(cx) {
794            this.is_terminated = true;
795            return std::task::Poll::Ready(None);
796        }
797        if this.is_terminated {
798            panic!("polled SysSuspendRequestStream after completion");
799        }
800        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
801            |bytes, handles| {
802                match this.inner.channel().read_etc(cx, bytes, handles) {
803                    std::task::Poll::Ready(Ok(())) => {}
804                    std::task::Poll::Pending => return std::task::Poll::Pending,
805                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
806                        this.is_terminated = true;
807                        return std::task::Poll::Ready(None);
808                    }
809                    std::task::Poll::Ready(Err(e)) => {
810                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
811                            e.into(),
812                        ))));
813                    }
814                }
815
816                // A message has been received from the channel
817                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
818
819                std::task::Poll::Ready(Some(match header.ordinal {
820                    0x2627dec0f8b3633 => {
821                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
822                        let mut req = fidl::new_empty!(
823                            SysSuspendCallbackRequest,
824                            fidl::encoding::DefaultFuchsiaResourceDialect
825                        );
826                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SysSuspendCallbackRequest>(&header, _body_bytes, handles, &mut req)?;
827                        let control_handle = SysSuspendControlHandle { inner: this.inner.clone() };
828                        Ok(SysSuspendRequest::Callback {
829                            enable_wake: req.enable_wake,
830                            suspend_reason: req.suspend_reason,
831
832                            responder: SysSuspendCallbackResponder {
833                                control_handle: std::mem::ManuallyDrop::new(control_handle),
834                                tx_id: header.tx_id,
835                            },
836                        })
837                    }
838                    _ => Err(fidl::Error::UnknownOrdinal {
839                        ordinal: header.ordinal,
840                        protocol_name:
841                            <SysSuspendMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
842                    }),
843                }))
844            },
845        )
846    }
847}
848
849/// Servers that implement this protocol can be registered to the platform
850/// bus to receive callbacks on why the platform bus is suspending.
851#[derive(Debug)]
852pub enum SysSuspendRequest {
853    /// Invoked by the platform bus when its suspend hook is called.
854    Callback { enable_wake: bool, suspend_reason: u8, responder: SysSuspendCallbackResponder },
855}
856
857impl SysSuspendRequest {
858    #[allow(irrefutable_let_patterns)]
859    pub fn into_callback(self) -> Option<(bool, u8, SysSuspendCallbackResponder)> {
860        if let SysSuspendRequest::Callback { enable_wake, suspend_reason, responder } = self {
861            Some((enable_wake, suspend_reason, responder))
862        } else {
863            None
864        }
865    }
866
867    /// Name of the method defined in FIDL
868    pub fn method_name(&self) -> &'static str {
869        match *self {
870            SysSuspendRequest::Callback { .. } => "callback",
871        }
872    }
873}
874
875#[derive(Debug, Clone)]
876pub struct SysSuspendControlHandle {
877    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
878}
879
880impl fidl::endpoints::ControlHandle for SysSuspendControlHandle {
881    fn shutdown(&self) {
882        self.inner.shutdown()
883    }
884
885    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
886        self.inner.shutdown_with_epitaph(status)
887    }
888
889    fn is_closed(&self) -> bool {
890        self.inner.channel().is_closed()
891    }
892    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
893        self.inner.channel().on_closed()
894    }
895
896    #[cfg(target_os = "fuchsia")]
897    fn signal_peer(
898        &self,
899        clear_mask: zx::Signals,
900        set_mask: zx::Signals,
901    ) -> Result<(), zx_status::Status> {
902        use fidl::Peered;
903        self.inner.channel().signal_peer(clear_mask, set_mask)
904    }
905}
906
907impl SysSuspendControlHandle {}
908
909#[must_use = "FIDL methods require a response to be sent"]
910#[derive(Debug)]
911pub struct SysSuspendCallbackResponder {
912    control_handle: std::mem::ManuallyDrop<SysSuspendControlHandle>,
913    tx_id: u32,
914}
915
916/// Set the the channel to be shutdown (see [`SysSuspendControlHandle::shutdown`])
917/// if the responder is dropped without sending a response, so that the client
918/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
919impl std::ops::Drop for SysSuspendCallbackResponder {
920    fn drop(&mut self) {
921        self.control_handle.shutdown();
922        // Safety: drops once, never accessed again
923        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
924    }
925}
926
927impl fidl::endpoints::Responder for SysSuspendCallbackResponder {
928    type ControlHandle = SysSuspendControlHandle;
929
930    fn control_handle(&self) -> &SysSuspendControlHandle {
931        &self.control_handle
932    }
933
934    fn drop_without_shutdown(mut self) {
935        // Safety: drops once, never accessed again due to mem::forget
936        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
937        // Prevent Drop from running (which would shut down the channel)
938        std::mem::forget(self);
939    }
940}
941
942impl SysSuspendCallbackResponder {
943    /// Sends a response to the FIDL transaction.
944    ///
945    /// Sets the channel to shutdown if an error occurs.
946    pub fn send(self, mut out_status: i32) -> Result<(), fidl::Error> {
947        let _result = self.send_raw(out_status);
948        if _result.is_err() {
949            self.control_handle.shutdown();
950        }
951        self.drop_without_shutdown();
952        _result
953    }
954
955    /// Similar to "send" but does not shutdown the channel if an error occurs.
956    pub fn send_no_shutdown_on_err(self, mut out_status: i32) -> Result<(), fidl::Error> {
957        let _result = self.send_raw(out_status);
958        self.drop_without_shutdown();
959        _result
960    }
961
962    fn send_raw(&self, mut out_status: i32) -> Result<(), fidl::Error> {
963        self.control_handle.inner.send::<SysSuspendCallbackResponse>(
964            (out_status,),
965            self.tx_id,
966            0x2627dec0f8b3633,
967            fidl::encoding::DynamicFlags::empty(),
968        )
969    }
970}
971
972#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
973pub struct ObservabilityServiceMarker;
974
975#[cfg(target_os = "fuchsia")]
976impl fidl::endpoints::ServiceMarker for ObservabilityServiceMarker {
977    type Proxy = ObservabilityServiceProxy;
978    type Request = ObservabilityServiceRequest;
979    const SERVICE_NAME: &'static str = "fuchsia.hardware.platform.bus.ObservabilityService";
980}
981
982/// A request for one of the member protocols of ObservabilityService.
983///
984#[cfg(target_os = "fuchsia")]
985pub enum ObservabilityServiceRequest {
986    Interrupt(InterruptAttributorRequestStream),
987}
988
989#[cfg(target_os = "fuchsia")]
990impl fidl::endpoints::ServiceRequest for ObservabilityServiceRequest {
991    type Service = ObservabilityServiceMarker;
992
993    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
994        match name {
995            "interrupt" => Self::Interrupt(
996                <InterruptAttributorRequestStream as fidl::endpoints::RequestStream>::from_channel(
997                    _channel,
998                ),
999            ),
1000            _ => panic!("no such member protocol name for service ObservabilityService"),
1001        }
1002    }
1003
1004    fn member_names() -> &'static [&'static str] {
1005        &["interrupt"]
1006    }
1007}
1008#[cfg(target_os = "fuchsia")]
1009pub struct ObservabilityServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1010
1011#[cfg(target_os = "fuchsia")]
1012impl fidl::endpoints::ServiceProxy for ObservabilityServiceProxy {
1013    type Service = ObservabilityServiceMarker;
1014
1015    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1016        Self(opener)
1017    }
1018}
1019
1020#[cfg(target_os = "fuchsia")]
1021impl ObservabilityServiceProxy {
1022    pub fn connect_to_interrupt(&self) -> Result<InterruptAttributorProxy, fidl::Error> {
1023        let (proxy, server_end) = fidl::endpoints::create_proxy::<InterruptAttributorMarker>();
1024        self.connect_channel_to_interrupt(server_end)?;
1025        Ok(proxy)
1026    }
1027
1028    /// Like `connect_to_interrupt`, but returns a sync proxy.
1029    /// See [`Self::connect_to_interrupt`] for more details.
1030    pub fn connect_to_interrupt_sync(
1031        &self,
1032    ) -> Result<InterruptAttributorSynchronousProxy, fidl::Error> {
1033        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<InterruptAttributorMarker>();
1034        self.connect_channel_to_interrupt(server_end)?;
1035        Ok(proxy)
1036    }
1037
1038    /// Like `connect_to_interrupt`, but accepts a server end.
1039    /// See [`Self::connect_to_interrupt`] for more details.
1040    pub fn connect_channel_to_interrupt(
1041        &self,
1042        server_end: fidl::endpoints::ServerEnd<InterruptAttributorMarker>,
1043    ) -> Result<(), fidl::Error> {
1044        self.0.open_member("interrupt", server_end.into_channel())
1045    }
1046
1047    pub fn instance_name(&self) -> &str {
1048        self.0.instance_name()
1049    }
1050}
1051
1052mod internal {
1053    use super::*;
1054
1055    impl fidl::encoding::ResourceTypeMarker for FirmwareBlob {
1056        type Borrowed<'a> = &'a mut Self;
1057        fn take_or_borrow<'a>(
1058            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1059        ) -> Self::Borrowed<'a> {
1060            value
1061        }
1062    }
1063
1064    unsafe impl fidl::encoding::TypeMarker for FirmwareBlob {
1065        type Owned = Self;
1066
1067        #[inline(always)]
1068        fn inline_align(_context: fidl::encoding::Context) -> usize {
1069            8
1070        }
1071
1072        #[inline(always)]
1073        fn inline_size(_context: fidl::encoding::Context) -> usize {
1074            16
1075        }
1076    }
1077
1078    unsafe impl fidl::encoding::Encode<FirmwareBlob, fidl::encoding::DefaultFuchsiaResourceDialect>
1079        for &mut FirmwareBlob
1080    {
1081        #[inline]
1082        unsafe fn encode(
1083            self,
1084            encoder: &mut fidl::encoding::Encoder<
1085                '_,
1086                fidl::encoding::DefaultFuchsiaResourceDialect,
1087            >,
1088            offset: usize,
1089            _depth: fidl::encoding::Depth,
1090        ) -> fidl::Result<()> {
1091            encoder.debug_check_bounds::<FirmwareBlob>(offset);
1092            // Delegate to tuple encoding.
1093            fidl::encoding::Encode::<FirmwareBlob, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1094                (
1095                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
1096                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.length),
1097                ),
1098                encoder, offset, _depth
1099            )
1100        }
1101    }
1102    unsafe impl<
1103        T0: fidl::encoding::Encode<
1104                fidl::encoding::HandleType<
1105                    fidl::Vmo,
1106                    { fidl::ObjectType::VMO.into_raw() },
1107                    2147483648,
1108                >,
1109                fidl::encoding::DefaultFuchsiaResourceDialect,
1110            >,
1111        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
1112    > fidl::encoding::Encode<FirmwareBlob, fidl::encoding::DefaultFuchsiaResourceDialect>
1113        for (T0, T1)
1114    {
1115        #[inline]
1116        unsafe fn encode(
1117            self,
1118            encoder: &mut fidl::encoding::Encoder<
1119                '_,
1120                fidl::encoding::DefaultFuchsiaResourceDialect,
1121            >,
1122            offset: usize,
1123            depth: fidl::encoding::Depth,
1124        ) -> fidl::Result<()> {
1125            encoder.debug_check_bounds::<FirmwareBlob>(offset);
1126            // Zero out padding regions. There's no need to apply masks
1127            // because the unmasked parts will be overwritten by fields.
1128            unsafe {
1129                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1130                (ptr as *mut u64).write_unaligned(0);
1131            }
1132            // Write the fields.
1133            self.0.encode(encoder, offset + 0, depth)?;
1134            self.1.encode(encoder, offset + 8, depth)?;
1135            Ok(())
1136        }
1137    }
1138
1139    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for FirmwareBlob {
1140        #[inline(always)]
1141        fn new_empty() -> Self {
1142            Self {
1143                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1144                length: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
1145            }
1146        }
1147
1148        #[inline]
1149        unsafe fn decode(
1150            &mut self,
1151            decoder: &mut fidl::encoding::Decoder<
1152                '_,
1153                fidl::encoding::DefaultFuchsiaResourceDialect,
1154            >,
1155            offset: usize,
1156            _depth: fidl::encoding::Depth,
1157        ) -> fidl::Result<()> {
1158            decoder.debug_check_bounds::<Self>(offset);
1159            // Verify that padding bytes are zero.
1160            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1161            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1162            let mask = 0xffffffff00000000u64;
1163            let maskedval = padval & mask;
1164            if maskedval != 0 {
1165                return Err(fidl::Error::NonZeroPadding {
1166                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1167                });
1168            }
1169            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
1170            fidl::decode!(
1171                u64,
1172                fidl::encoding::DefaultFuchsiaResourceDialect,
1173                &mut self.length,
1174                decoder,
1175                offset + 8,
1176                _depth
1177            )?;
1178            Ok(())
1179        }
1180    }
1181
1182    impl fidl::encoding::ResourceTypeMarker for InterruptAttributorGetInterruptInfoResponse {
1183        type Borrowed<'a> = &'a mut Self;
1184        fn take_or_borrow<'a>(
1185            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1186        ) -> Self::Borrowed<'a> {
1187            value
1188        }
1189    }
1190
1191    unsafe impl fidl::encoding::TypeMarker for InterruptAttributorGetInterruptInfoResponse {
1192        type Owned = Self;
1193
1194        #[inline(always)]
1195        fn inline_align(_context: fidl::encoding::Context) -> usize {
1196            8
1197        }
1198
1199        #[inline(always)]
1200        fn inline_size(_context: fidl::encoding::Context) -> usize {
1201            24
1202        }
1203    }
1204
1205    unsafe impl
1206        fidl::encoding::Encode<
1207            InterruptAttributorGetInterruptInfoResponse,
1208            fidl::encoding::DefaultFuchsiaResourceDialect,
1209        > for &mut InterruptAttributorGetInterruptInfoResponse
1210    {
1211        #[inline]
1212        unsafe fn encode(
1213            self,
1214            encoder: &mut fidl::encoding::Encoder<
1215                '_,
1216                fidl::encoding::DefaultFuchsiaResourceDialect,
1217            >,
1218            offset: usize,
1219            _depth: fidl::encoding::Depth,
1220        ) -> fidl::Result<()> {
1221            encoder.debug_check_bounds::<InterruptAttributorGetInterruptInfoResponse>(offset);
1222            // Delegate to tuple encoding.
1223            fidl::encoding::Encode::<
1224                InterruptAttributorGetInterruptInfoResponse,
1225                fidl::encoding::DefaultFuchsiaResourceDialect,
1226            >::encode(
1227                (
1228                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow(
1229                        &self.device_name,
1230                    ),
1231                    <fidl::encoding::Optional<
1232                        fidl::encoding::HandleType<
1233                            fidl::Event,
1234                            { fidl::ObjectType::EVENT.into_raw() },
1235                            2147483648,
1236                        >,
1237                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1238                        &mut self.component_token,
1239                    ),
1240                ),
1241                encoder,
1242                offset,
1243                _depth,
1244            )
1245        }
1246    }
1247    unsafe impl<
1248        T0: fidl::encoding::Encode<
1249                fidl::encoding::BoundedString<128>,
1250                fidl::encoding::DefaultFuchsiaResourceDialect,
1251            >,
1252        T1: fidl::encoding::Encode<
1253                fidl::encoding::Optional<
1254                    fidl::encoding::HandleType<
1255                        fidl::Event,
1256                        { fidl::ObjectType::EVENT.into_raw() },
1257                        2147483648,
1258                    >,
1259                >,
1260                fidl::encoding::DefaultFuchsiaResourceDialect,
1261            >,
1262    >
1263        fidl::encoding::Encode<
1264            InterruptAttributorGetInterruptInfoResponse,
1265            fidl::encoding::DefaultFuchsiaResourceDialect,
1266        > for (T0, T1)
1267    {
1268        #[inline]
1269        unsafe fn encode(
1270            self,
1271            encoder: &mut fidl::encoding::Encoder<
1272                '_,
1273                fidl::encoding::DefaultFuchsiaResourceDialect,
1274            >,
1275            offset: usize,
1276            depth: fidl::encoding::Depth,
1277        ) -> fidl::Result<()> {
1278            encoder.debug_check_bounds::<InterruptAttributorGetInterruptInfoResponse>(offset);
1279            // Zero out padding regions. There's no need to apply masks
1280            // because the unmasked parts will be overwritten by fields.
1281            unsafe {
1282                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1283                (ptr as *mut u64).write_unaligned(0);
1284            }
1285            // Write the fields.
1286            self.0.encode(encoder, offset + 0, depth)?;
1287            self.1.encode(encoder, offset + 16, depth)?;
1288            Ok(())
1289        }
1290    }
1291
1292    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1293        for InterruptAttributorGetInterruptInfoResponse
1294    {
1295        #[inline(always)]
1296        fn new_empty() -> Self {
1297            Self {
1298                device_name: fidl::new_empty!(
1299                    fidl::encoding::BoundedString<128>,
1300                    fidl::encoding::DefaultFuchsiaResourceDialect
1301                ),
1302                component_token: fidl::new_empty!(
1303                    fidl::encoding::Optional<
1304                        fidl::encoding::HandleType<
1305                            fidl::Event,
1306                            { fidl::ObjectType::EVENT.into_raw() },
1307                            2147483648,
1308                        >,
1309                    >,
1310                    fidl::encoding::DefaultFuchsiaResourceDialect
1311                ),
1312            }
1313        }
1314
1315        #[inline]
1316        unsafe fn decode(
1317            &mut self,
1318            decoder: &mut fidl::encoding::Decoder<
1319                '_,
1320                fidl::encoding::DefaultFuchsiaResourceDialect,
1321            >,
1322            offset: usize,
1323            _depth: fidl::encoding::Depth,
1324        ) -> fidl::Result<()> {
1325            decoder.debug_check_bounds::<Self>(offset);
1326            // Verify that padding bytes are zero.
1327            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1328            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1329            let mask = 0xffffffff00000000u64;
1330            let maskedval = padval & mask;
1331            if maskedval != 0 {
1332                return Err(fidl::Error::NonZeroPadding {
1333                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1334                });
1335            }
1336            fidl::decode!(
1337                fidl::encoding::BoundedString<128>,
1338                fidl::encoding::DefaultFuchsiaResourceDialect,
1339                &mut self.device_name,
1340                decoder,
1341                offset + 0,
1342                _depth
1343            )?;
1344            fidl::decode!(
1345                fidl::encoding::Optional<
1346                    fidl::encoding::HandleType<
1347                        fidl::Event,
1348                        { fidl::ObjectType::EVENT.into_raw() },
1349                        2147483648,
1350                    >,
1351                >,
1352                fidl::encoding::DefaultFuchsiaResourceDialect,
1353                &mut self.component_token,
1354                decoder,
1355                offset + 16,
1356                _depth
1357            )?;
1358            Ok(())
1359        }
1360    }
1361}