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