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 InterruptAttributorControlHandle {
418    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
419        self.inner.shutdown_with_epitaph(status.into())
420    }
421}
422
423impl fidl::endpoints::ControlHandle for InterruptAttributorControlHandle {
424    fn shutdown(&self) {
425        self.inner.shutdown()
426    }
427
428    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
429        self.inner.shutdown_with_epitaph(status)
430    }
431
432    fn is_closed(&self) -> bool {
433        self.inner.channel().is_closed()
434    }
435    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
436        self.inner.channel().on_closed()
437    }
438
439    #[cfg(target_os = "fuchsia")]
440    fn signal_peer(
441        &self,
442        clear_mask: zx::Signals,
443        set_mask: zx::Signals,
444    ) -> Result<(), zx_status::Status> {
445        use fidl::Peered;
446        self.inner.channel().signal_peer(clear_mask, set_mask)
447    }
448}
449
450impl InterruptAttributorControlHandle {}
451
452#[must_use = "FIDL methods require a response to be sent"]
453#[derive(Debug)]
454pub struct InterruptAttributorGetInterruptInfoResponder {
455    control_handle: std::mem::ManuallyDrop<InterruptAttributorControlHandle>,
456    tx_id: u32,
457}
458
459/// Set the the channel to be shutdown (see [`InterruptAttributorControlHandle::shutdown`])
460/// if the responder is dropped without sending a response, so that the client
461/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
462impl std::ops::Drop for InterruptAttributorGetInterruptInfoResponder {
463    fn drop(&mut self) {
464        self.control_handle.shutdown();
465        // Safety: drops once, never accessed again
466        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
467    }
468}
469
470impl fidl::endpoints::Responder for InterruptAttributorGetInterruptInfoResponder {
471    type ControlHandle = InterruptAttributorControlHandle;
472
473    fn control_handle(&self) -> &InterruptAttributorControlHandle {
474        &self.control_handle
475    }
476
477    fn drop_without_shutdown(mut self) {
478        // Safety: drops once, never accessed again due to mem::forget
479        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
480        // Prevent Drop from running (which would shut down the channel)
481        std::mem::forget(self);
482    }
483}
484
485impl InterruptAttributorGetInterruptInfoResponder {
486    /// Sends a response to the FIDL transaction.
487    ///
488    /// Sets the channel to shutdown if an error occurs.
489    pub fn send(
490        self,
491        mut result: Result<(&str, Option<fidl::Event>), i32>,
492    ) -> Result<(), fidl::Error> {
493        let _result = self.send_raw(result);
494        if _result.is_err() {
495            self.control_handle.shutdown();
496        }
497        self.drop_without_shutdown();
498        _result
499    }
500
501    /// Similar to "send" but does not shutdown the channel if an error occurs.
502    pub fn send_no_shutdown_on_err(
503        self,
504        mut result: Result<(&str, Option<fidl::Event>), i32>,
505    ) -> Result<(), fidl::Error> {
506        let _result = self.send_raw(result);
507        self.drop_without_shutdown();
508        _result
509    }
510
511    fn send_raw(
512        &self,
513        mut result: Result<(&str, Option<fidl::Event>), i32>,
514    ) -> Result<(), fidl::Error> {
515        self.control_handle.inner.send::<fidl::encoding::ResultType<
516            InterruptAttributorGetInterruptInfoResponse,
517            i32,
518        >>(
519            result,
520            self.tx_id,
521            0x28561a2dbdb9a3c9,
522            fidl::encoding::DynamicFlags::empty(),
523        )
524    }
525}
526
527#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
528pub struct SysSuspendMarker;
529
530impl fidl::endpoints::ProtocolMarker for SysSuspendMarker {
531    type Proxy = SysSuspendProxy;
532    type RequestStream = SysSuspendRequestStream;
533    #[cfg(target_os = "fuchsia")]
534    type SynchronousProxy = SysSuspendSynchronousProxy;
535
536    const DEBUG_NAME: &'static str = "(anonymous) SysSuspend";
537}
538
539pub trait SysSuspendProxyInterface: Send + Sync {
540    type CallbackResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
541    fn r#callback(&self, enable_wake: bool, suspend_reason: u8) -> Self::CallbackResponseFut;
542}
543#[derive(Debug)]
544#[cfg(target_os = "fuchsia")]
545pub struct SysSuspendSynchronousProxy {
546    client: fidl::client::sync::Client,
547}
548
549#[cfg(target_os = "fuchsia")]
550impl fidl::endpoints::SynchronousProxy for SysSuspendSynchronousProxy {
551    type Proxy = SysSuspendProxy;
552    type Protocol = SysSuspendMarker;
553
554    fn from_channel(inner: fidl::Channel) -> Self {
555        Self::new(inner)
556    }
557
558    fn into_channel(self) -> fidl::Channel {
559        self.client.into_channel()
560    }
561
562    fn as_channel(&self) -> &fidl::Channel {
563        self.client.as_channel()
564    }
565}
566
567#[cfg(target_os = "fuchsia")]
568impl SysSuspendSynchronousProxy {
569    pub fn new(channel: fidl::Channel) -> Self {
570        Self { client: fidl::client::sync::Client::new(channel) }
571    }
572
573    pub fn into_channel(self) -> fidl::Channel {
574        self.client.into_channel()
575    }
576
577    /// Waits until an event arrives and returns it. It is safe for other
578    /// threads to make concurrent requests while waiting for an event.
579    pub fn wait_for_event(
580        &self,
581        deadline: zx::MonotonicInstant,
582    ) -> Result<SysSuspendEvent, fidl::Error> {
583        SysSuspendEvent::decode(self.client.wait_for_event::<SysSuspendMarker>(deadline)?)
584    }
585
586    /// Invoked by the platform bus when its suspend hook is called.
587    pub fn r#callback(
588        &self,
589        mut enable_wake: bool,
590        mut suspend_reason: u8,
591        ___deadline: zx::MonotonicInstant,
592    ) -> Result<i32, fidl::Error> {
593        let _response = self
594            .client
595            .send_query::<SysSuspendCallbackRequest, SysSuspendCallbackResponse, SysSuspendMarker>(
596                (enable_wake, suspend_reason),
597                0x2627dec0f8b3633,
598                fidl::encoding::DynamicFlags::empty(),
599                ___deadline,
600            )?;
601        Ok(_response.out_status)
602    }
603}
604
605#[cfg(target_os = "fuchsia")]
606impl From<SysSuspendSynchronousProxy> for zx::NullableHandle {
607    fn from(value: SysSuspendSynchronousProxy) -> Self {
608        value.into_channel().into()
609    }
610}
611
612#[cfg(target_os = "fuchsia")]
613impl From<fidl::Channel> for SysSuspendSynchronousProxy {
614    fn from(value: fidl::Channel) -> Self {
615        Self::new(value)
616    }
617}
618
619#[cfg(target_os = "fuchsia")]
620impl fidl::endpoints::FromClient for SysSuspendSynchronousProxy {
621    type Protocol = SysSuspendMarker;
622
623    fn from_client(value: fidl::endpoints::ClientEnd<SysSuspendMarker>) -> Self {
624        Self::new(value.into_channel())
625    }
626}
627
628#[derive(Debug, Clone)]
629pub struct SysSuspendProxy {
630    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
631}
632
633impl fidl::endpoints::Proxy for SysSuspendProxy {
634    type Protocol = SysSuspendMarker;
635
636    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
637        Self::new(inner)
638    }
639
640    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
641        self.client.into_channel().map_err(|client| Self { client })
642    }
643
644    fn as_channel(&self) -> &::fidl::AsyncChannel {
645        self.client.as_channel()
646    }
647}
648
649impl SysSuspendProxy {
650    /// Create a new Proxy for fuchsia.hardware.platform.bus/SysSuspend.
651    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
652        let protocol_name = <SysSuspendMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
653        Self { client: fidl::client::Client::new(channel, protocol_name) }
654    }
655
656    /// Get a Stream of events from the remote end of the protocol.
657    ///
658    /// # Panics
659    ///
660    /// Panics if the event stream was already taken.
661    pub fn take_event_stream(&self) -> SysSuspendEventStream {
662        SysSuspendEventStream { event_receiver: self.client.take_event_receiver() }
663    }
664
665    /// Invoked by the platform bus when its suspend hook is called.
666    pub fn r#callback(
667        &self,
668        mut enable_wake: bool,
669        mut suspend_reason: u8,
670    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
671        SysSuspendProxyInterface::r#callback(self, enable_wake, suspend_reason)
672    }
673}
674
675impl SysSuspendProxyInterface for SysSuspendProxy {
676    type CallbackResponseFut =
677        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
678    fn r#callback(
679        &self,
680        mut enable_wake: bool,
681        mut suspend_reason: u8,
682    ) -> Self::CallbackResponseFut {
683        fn _decode(
684            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
685        ) -> Result<i32, fidl::Error> {
686            let _response = fidl::client::decode_transaction_body::<
687                SysSuspendCallbackResponse,
688                fidl::encoding::DefaultFuchsiaResourceDialect,
689                0x2627dec0f8b3633,
690            >(_buf?)?;
691            Ok(_response.out_status)
692        }
693        self.client.send_query_and_decode::<SysSuspendCallbackRequest, i32>(
694            (enable_wake, suspend_reason),
695            0x2627dec0f8b3633,
696            fidl::encoding::DynamicFlags::empty(),
697            _decode,
698        )
699    }
700}
701
702pub struct SysSuspendEventStream {
703    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
704}
705
706impl std::marker::Unpin for SysSuspendEventStream {}
707
708impl futures::stream::FusedStream for SysSuspendEventStream {
709    fn is_terminated(&self) -> bool {
710        self.event_receiver.is_terminated()
711    }
712}
713
714impl futures::Stream for SysSuspendEventStream {
715    type Item = Result<SysSuspendEvent, fidl::Error>;
716
717    fn poll_next(
718        mut self: std::pin::Pin<&mut Self>,
719        cx: &mut std::task::Context<'_>,
720    ) -> std::task::Poll<Option<Self::Item>> {
721        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
722            &mut self.event_receiver,
723            cx
724        )?) {
725            Some(buf) => std::task::Poll::Ready(Some(SysSuspendEvent::decode(buf))),
726            None => std::task::Poll::Ready(None),
727        }
728    }
729}
730
731#[derive(Debug)]
732pub enum SysSuspendEvent {}
733
734impl SysSuspendEvent {
735    /// Decodes a message buffer as a [`SysSuspendEvent`].
736    fn decode(
737        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
738    ) -> Result<SysSuspendEvent, fidl::Error> {
739        let (bytes, _handles) = buf.split_mut();
740        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
741        debug_assert_eq!(tx_header.tx_id, 0);
742        match tx_header.ordinal {
743            _ => Err(fidl::Error::UnknownOrdinal {
744                ordinal: tx_header.ordinal,
745                protocol_name: <SysSuspendMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
746            }),
747        }
748    }
749}
750
751/// A Stream of incoming requests for fuchsia.hardware.platform.bus/SysSuspend.
752pub struct SysSuspendRequestStream {
753    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
754    is_terminated: bool,
755}
756
757impl std::marker::Unpin for SysSuspendRequestStream {}
758
759impl futures::stream::FusedStream for SysSuspendRequestStream {
760    fn is_terminated(&self) -> bool {
761        self.is_terminated
762    }
763}
764
765impl fidl::endpoints::RequestStream for SysSuspendRequestStream {
766    type Protocol = SysSuspendMarker;
767    type ControlHandle = SysSuspendControlHandle;
768
769    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
770        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
771    }
772
773    fn control_handle(&self) -> Self::ControlHandle {
774        SysSuspendControlHandle { inner: self.inner.clone() }
775    }
776
777    fn into_inner(
778        self,
779    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
780    {
781        (self.inner, self.is_terminated)
782    }
783
784    fn from_inner(
785        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
786        is_terminated: bool,
787    ) -> Self {
788        Self { inner, is_terminated }
789    }
790}
791
792impl futures::Stream for SysSuspendRequestStream {
793    type Item = Result<SysSuspendRequest, fidl::Error>;
794
795    fn poll_next(
796        mut self: std::pin::Pin<&mut Self>,
797        cx: &mut std::task::Context<'_>,
798    ) -> std::task::Poll<Option<Self::Item>> {
799        let this = &mut *self;
800        if this.inner.check_shutdown(cx) {
801            this.is_terminated = true;
802            return std::task::Poll::Ready(None);
803        }
804        if this.is_terminated {
805            panic!("polled SysSuspendRequestStream after completion");
806        }
807        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
808            |bytes, handles| {
809                match this.inner.channel().read_etc(cx, bytes, handles) {
810                    std::task::Poll::Ready(Ok(())) => {}
811                    std::task::Poll::Pending => return std::task::Poll::Pending,
812                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
813                        this.is_terminated = true;
814                        return std::task::Poll::Ready(None);
815                    }
816                    std::task::Poll::Ready(Err(e)) => {
817                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
818                            e.into(),
819                        ))));
820                    }
821                }
822
823                // A message has been received from the channel
824                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
825
826                std::task::Poll::Ready(Some(match header.ordinal {
827                    0x2627dec0f8b3633 => {
828                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
829                        let mut req = fidl::new_empty!(
830                            SysSuspendCallbackRequest,
831                            fidl::encoding::DefaultFuchsiaResourceDialect
832                        );
833                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SysSuspendCallbackRequest>(&header, _body_bytes, handles, &mut req)?;
834                        let control_handle = SysSuspendControlHandle { inner: this.inner.clone() };
835                        Ok(SysSuspendRequest::Callback {
836                            enable_wake: req.enable_wake,
837                            suspend_reason: req.suspend_reason,
838
839                            responder: SysSuspendCallbackResponder {
840                                control_handle: std::mem::ManuallyDrop::new(control_handle),
841                                tx_id: header.tx_id,
842                            },
843                        })
844                    }
845                    _ => Err(fidl::Error::UnknownOrdinal {
846                        ordinal: header.ordinal,
847                        protocol_name:
848                            <SysSuspendMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
849                    }),
850                }))
851            },
852        )
853    }
854}
855
856/// Servers that implement this protocol can be registered to the platform
857/// bus to receive callbacks on why the platform bus is suspending.
858#[derive(Debug)]
859pub enum SysSuspendRequest {
860    /// Invoked by the platform bus when its suspend hook is called.
861    Callback { enable_wake: bool, suspend_reason: u8, responder: SysSuspendCallbackResponder },
862}
863
864impl SysSuspendRequest {
865    #[allow(irrefutable_let_patterns)]
866    pub fn into_callback(self) -> Option<(bool, u8, SysSuspendCallbackResponder)> {
867        if let SysSuspendRequest::Callback { enable_wake, suspend_reason, responder } = self {
868            Some((enable_wake, suspend_reason, responder))
869        } else {
870            None
871        }
872    }
873
874    /// Name of the method defined in FIDL
875    pub fn method_name(&self) -> &'static str {
876        match *self {
877            SysSuspendRequest::Callback { .. } => "callback",
878        }
879    }
880}
881
882#[derive(Debug, Clone)]
883pub struct SysSuspendControlHandle {
884    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
885}
886
887impl SysSuspendControlHandle {
888    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
889        self.inner.shutdown_with_epitaph(status.into())
890    }
891}
892
893impl fidl::endpoints::ControlHandle for SysSuspendControlHandle {
894    fn shutdown(&self) {
895        self.inner.shutdown()
896    }
897
898    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
899        self.inner.shutdown_with_epitaph(status)
900    }
901
902    fn is_closed(&self) -> bool {
903        self.inner.channel().is_closed()
904    }
905    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
906        self.inner.channel().on_closed()
907    }
908
909    #[cfg(target_os = "fuchsia")]
910    fn signal_peer(
911        &self,
912        clear_mask: zx::Signals,
913        set_mask: zx::Signals,
914    ) -> Result<(), zx_status::Status> {
915        use fidl::Peered;
916        self.inner.channel().signal_peer(clear_mask, set_mask)
917    }
918}
919
920impl SysSuspendControlHandle {}
921
922#[must_use = "FIDL methods require a response to be sent"]
923#[derive(Debug)]
924pub struct SysSuspendCallbackResponder {
925    control_handle: std::mem::ManuallyDrop<SysSuspendControlHandle>,
926    tx_id: u32,
927}
928
929/// Set the the channel to be shutdown (see [`SysSuspendControlHandle::shutdown`])
930/// if the responder is dropped without sending a response, so that the client
931/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
932impl std::ops::Drop for SysSuspendCallbackResponder {
933    fn drop(&mut self) {
934        self.control_handle.shutdown();
935        // Safety: drops once, never accessed again
936        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
937    }
938}
939
940impl fidl::endpoints::Responder for SysSuspendCallbackResponder {
941    type ControlHandle = SysSuspendControlHandle;
942
943    fn control_handle(&self) -> &SysSuspendControlHandle {
944        &self.control_handle
945    }
946
947    fn drop_without_shutdown(mut self) {
948        // Safety: drops once, never accessed again due to mem::forget
949        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
950        // Prevent Drop from running (which would shut down the channel)
951        std::mem::forget(self);
952    }
953}
954
955impl SysSuspendCallbackResponder {
956    /// Sends a response to the FIDL transaction.
957    ///
958    /// Sets the channel to shutdown if an error occurs.
959    pub fn send(self, mut out_status: i32) -> Result<(), fidl::Error> {
960        let _result = self.send_raw(out_status);
961        if _result.is_err() {
962            self.control_handle.shutdown();
963        }
964        self.drop_without_shutdown();
965        _result
966    }
967
968    /// Similar to "send" but does not shutdown the channel if an error occurs.
969    pub fn send_no_shutdown_on_err(self, mut out_status: i32) -> Result<(), fidl::Error> {
970        let _result = self.send_raw(out_status);
971        self.drop_without_shutdown();
972        _result
973    }
974
975    fn send_raw(&self, mut out_status: i32) -> Result<(), fidl::Error> {
976        self.control_handle.inner.send::<SysSuspendCallbackResponse>(
977            (out_status,),
978            self.tx_id,
979            0x2627dec0f8b3633,
980            fidl::encoding::DynamicFlags::empty(),
981        )
982    }
983}
984
985#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
986pub struct ObservabilityServiceMarker;
987
988#[cfg(target_os = "fuchsia")]
989impl fidl::endpoints::ServiceMarker for ObservabilityServiceMarker {
990    type Proxy = ObservabilityServiceProxy;
991    type Request = ObservabilityServiceRequest;
992    const SERVICE_NAME: &'static str = "fuchsia.hardware.platform.bus.ObservabilityService";
993}
994
995/// A request for one of the member protocols of ObservabilityService.
996///
997#[cfg(target_os = "fuchsia")]
998pub enum ObservabilityServiceRequest {
999    Interrupt(InterruptAttributorRequestStream),
1000}
1001
1002#[cfg(target_os = "fuchsia")]
1003impl fidl::endpoints::ServiceRequest for ObservabilityServiceRequest {
1004    type Service = ObservabilityServiceMarker;
1005
1006    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1007        match name {
1008            "interrupt" => Self::Interrupt(
1009                <InterruptAttributorRequestStream as fidl::endpoints::RequestStream>::from_channel(
1010                    _channel,
1011                ),
1012            ),
1013            _ => panic!("no such member protocol name for service ObservabilityService"),
1014        }
1015    }
1016
1017    fn member_names() -> &'static [&'static str] {
1018        &["interrupt"]
1019    }
1020}
1021#[cfg(target_os = "fuchsia")]
1022pub struct ObservabilityServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1023
1024#[cfg(target_os = "fuchsia")]
1025impl fidl::endpoints::ServiceProxy for ObservabilityServiceProxy {
1026    type Service = ObservabilityServiceMarker;
1027
1028    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1029        Self(opener)
1030    }
1031}
1032
1033#[cfg(target_os = "fuchsia")]
1034impl ObservabilityServiceProxy {
1035    pub fn connect_to_interrupt(&self) -> Result<InterruptAttributorProxy, fidl::Error> {
1036        let (proxy, server_end) = fidl::endpoints::create_proxy::<InterruptAttributorMarker>();
1037        self.connect_channel_to_interrupt(server_end)?;
1038        Ok(proxy)
1039    }
1040
1041    /// Like `connect_to_interrupt`, but returns a sync proxy.
1042    /// See [`Self::connect_to_interrupt`] for more details.
1043    pub fn connect_to_interrupt_sync(
1044        &self,
1045    ) -> Result<InterruptAttributorSynchronousProxy, fidl::Error> {
1046        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<InterruptAttributorMarker>();
1047        self.connect_channel_to_interrupt(server_end)?;
1048        Ok(proxy)
1049    }
1050
1051    /// Like `connect_to_interrupt`, but accepts a server end.
1052    /// See [`Self::connect_to_interrupt`] for more details.
1053    pub fn connect_channel_to_interrupt(
1054        &self,
1055        server_end: fidl::endpoints::ServerEnd<InterruptAttributorMarker>,
1056    ) -> Result<(), fidl::Error> {
1057        self.0.open_member("interrupt", server_end.into_channel())
1058    }
1059
1060    pub fn instance_name(&self) -> &str {
1061        self.0.instance_name()
1062    }
1063}
1064
1065mod internal {
1066    use super::*;
1067
1068    impl fidl::encoding::ResourceTypeMarker for FirmwareBlob {
1069        type Borrowed<'a> = &'a mut Self;
1070        fn take_or_borrow<'a>(
1071            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1072        ) -> Self::Borrowed<'a> {
1073            value
1074        }
1075    }
1076
1077    unsafe impl fidl::encoding::TypeMarker for FirmwareBlob {
1078        type Owned = Self;
1079
1080        #[inline(always)]
1081        fn inline_align(_context: fidl::encoding::Context) -> usize {
1082            8
1083        }
1084
1085        #[inline(always)]
1086        fn inline_size(_context: fidl::encoding::Context) -> usize {
1087            16
1088        }
1089    }
1090
1091    unsafe impl fidl::encoding::Encode<FirmwareBlob, fidl::encoding::DefaultFuchsiaResourceDialect>
1092        for &mut FirmwareBlob
1093    {
1094        #[inline]
1095        unsafe fn encode(
1096            self,
1097            encoder: &mut fidl::encoding::Encoder<
1098                '_,
1099                fidl::encoding::DefaultFuchsiaResourceDialect,
1100            >,
1101            offset: usize,
1102            _depth: fidl::encoding::Depth,
1103        ) -> fidl::Result<()> {
1104            encoder.debug_check_bounds::<FirmwareBlob>(offset);
1105            // Delegate to tuple encoding.
1106            fidl::encoding::Encode::<FirmwareBlob, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1107                (
1108                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
1109                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.length),
1110                ),
1111                encoder, offset, _depth
1112            )
1113        }
1114    }
1115    unsafe impl<
1116        T0: fidl::encoding::Encode<
1117                fidl::encoding::HandleType<
1118                    fidl::Vmo,
1119                    { fidl::ObjectType::VMO.into_raw() },
1120                    2147483648,
1121                >,
1122                fidl::encoding::DefaultFuchsiaResourceDialect,
1123            >,
1124        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
1125    > fidl::encoding::Encode<FirmwareBlob, fidl::encoding::DefaultFuchsiaResourceDialect>
1126        for (T0, T1)
1127    {
1128        #[inline]
1129        unsafe fn encode(
1130            self,
1131            encoder: &mut fidl::encoding::Encoder<
1132                '_,
1133                fidl::encoding::DefaultFuchsiaResourceDialect,
1134            >,
1135            offset: usize,
1136            depth: fidl::encoding::Depth,
1137        ) -> fidl::Result<()> {
1138            encoder.debug_check_bounds::<FirmwareBlob>(offset);
1139            // Zero out padding regions. There's no need to apply masks
1140            // because the unmasked parts will be overwritten by fields.
1141            unsafe {
1142                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1143                (ptr as *mut u64).write_unaligned(0);
1144            }
1145            // Write the fields.
1146            self.0.encode(encoder, offset + 0, depth)?;
1147            self.1.encode(encoder, offset + 8, depth)?;
1148            Ok(())
1149        }
1150    }
1151
1152    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for FirmwareBlob {
1153        #[inline(always)]
1154        fn new_empty() -> Self {
1155            Self {
1156                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1157                length: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
1158            }
1159        }
1160
1161        #[inline]
1162        unsafe fn decode(
1163            &mut self,
1164            decoder: &mut fidl::encoding::Decoder<
1165                '_,
1166                fidl::encoding::DefaultFuchsiaResourceDialect,
1167            >,
1168            offset: usize,
1169            _depth: fidl::encoding::Depth,
1170        ) -> fidl::Result<()> {
1171            decoder.debug_check_bounds::<Self>(offset);
1172            // Verify that padding bytes are zero.
1173            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1174            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1175            let mask = 0xffffffff00000000u64;
1176            let maskedval = padval & mask;
1177            if maskedval != 0 {
1178                return Err(fidl::Error::NonZeroPadding {
1179                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1180                });
1181            }
1182            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
1183            fidl::decode!(
1184                u64,
1185                fidl::encoding::DefaultFuchsiaResourceDialect,
1186                &mut self.length,
1187                decoder,
1188                offset + 8,
1189                _depth
1190            )?;
1191            Ok(())
1192        }
1193    }
1194
1195    impl fidl::encoding::ResourceTypeMarker for InterruptAttributorGetInterruptInfoResponse {
1196        type Borrowed<'a> = &'a mut Self;
1197        fn take_or_borrow<'a>(
1198            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1199        ) -> Self::Borrowed<'a> {
1200            value
1201        }
1202    }
1203
1204    unsafe impl fidl::encoding::TypeMarker for InterruptAttributorGetInterruptInfoResponse {
1205        type Owned = Self;
1206
1207        #[inline(always)]
1208        fn inline_align(_context: fidl::encoding::Context) -> usize {
1209            8
1210        }
1211
1212        #[inline(always)]
1213        fn inline_size(_context: fidl::encoding::Context) -> usize {
1214            24
1215        }
1216    }
1217
1218    unsafe impl
1219        fidl::encoding::Encode<
1220            InterruptAttributorGetInterruptInfoResponse,
1221            fidl::encoding::DefaultFuchsiaResourceDialect,
1222        > for &mut InterruptAttributorGetInterruptInfoResponse
1223    {
1224        #[inline]
1225        unsafe fn encode(
1226            self,
1227            encoder: &mut fidl::encoding::Encoder<
1228                '_,
1229                fidl::encoding::DefaultFuchsiaResourceDialect,
1230            >,
1231            offset: usize,
1232            _depth: fidl::encoding::Depth,
1233        ) -> fidl::Result<()> {
1234            encoder.debug_check_bounds::<InterruptAttributorGetInterruptInfoResponse>(offset);
1235            // Delegate to tuple encoding.
1236            fidl::encoding::Encode::<
1237                InterruptAttributorGetInterruptInfoResponse,
1238                fidl::encoding::DefaultFuchsiaResourceDialect,
1239            >::encode(
1240                (
1241                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow(
1242                        &self.device_name,
1243                    ),
1244                    <fidl::encoding::Optional<
1245                        fidl::encoding::HandleType<
1246                            fidl::Event,
1247                            { fidl::ObjectType::EVENT.into_raw() },
1248                            2147483648,
1249                        >,
1250                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1251                        &mut self.component_token,
1252                    ),
1253                ),
1254                encoder,
1255                offset,
1256                _depth,
1257            )
1258        }
1259    }
1260    unsafe impl<
1261        T0: fidl::encoding::Encode<
1262                fidl::encoding::BoundedString<128>,
1263                fidl::encoding::DefaultFuchsiaResourceDialect,
1264            >,
1265        T1: fidl::encoding::Encode<
1266                fidl::encoding::Optional<
1267                    fidl::encoding::HandleType<
1268                        fidl::Event,
1269                        { fidl::ObjectType::EVENT.into_raw() },
1270                        2147483648,
1271                    >,
1272                >,
1273                fidl::encoding::DefaultFuchsiaResourceDialect,
1274            >,
1275    >
1276        fidl::encoding::Encode<
1277            InterruptAttributorGetInterruptInfoResponse,
1278            fidl::encoding::DefaultFuchsiaResourceDialect,
1279        > for (T0, T1)
1280    {
1281        #[inline]
1282        unsafe fn encode(
1283            self,
1284            encoder: &mut fidl::encoding::Encoder<
1285                '_,
1286                fidl::encoding::DefaultFuchsiaResourceDialect,
1287            >,
1288            offset: usize,
1289            depth: fidl::encoding::Depth,
1290        ) -> fidl::Result<()> {
1291            encoder.debug_check_bounds::<InterruptAttributorGetInterruptInfoResponse>(offset);
1292            // Zero out padding regions. There's no need to apply masks
1293            // because the unmasked parts will be overwritten by fields.
1294            unsafe {
1295                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1296                (ptr as *mut u64).write_unaligned(0);
1297            }
1298            // Write the fields.
1299            self.0.encode(encoder, offset + 0, depth)?;
1300            self.1.encode(encoder, offset + 16, depth)?;
1301            Ok(())
1302        }
1303    }
1304
1305    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1306        for InterruptAttributorGetInterruptInfoResponse
1307    {
1308        #[inline(always)]
1309        fn new_empty() -> Self {
1310            Self {
1311                device_name: fidl::new_empty!(
1312                    fidl::encoding::BoundedString<128>,
1313                    fidl::encoding::DefaultFuchsiaResourceDialect
1314                ),
1315                component_token: fidl::new_empty!(
1316                    fidl::encoding::Optional<
1317                        fidl::encoding::HandleType<
1318                            fidl::Event,
1319                            { fidl::ObjectType::EVENT.into_raw() },
1320                            2147483648,
1321                        >,
1322                    >,
1323                    fidl::encoding::DefaultFuchsiaResourceDialect
1324                ),
1325            }
1326        }
1327
1328        #[inline]
1329        unsafe fn decode(
1330            &mut self,
1331            decoder: &mut fidl::encoding::Decoder<
1332                '_,
1333                fidl::encoding::DefaultFuchsiaResourceDialect,
1334            >,
1335            offset: usize,
1336            _depth: fidl::encoding::Depth,
1337        ) -> fidl::Result<()> {
1338            decoder.debug_check_bounds::<Self>(offset);
1339            // Verify that padding bytes are zero.
1340            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1341            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1342            let mask = 0xffffffff00000000u64;
1343            let maskedval = padval & mask;
1344            if maskedval != 0 {
1345                return Err(fidl::Error::NonZeroPadding {
1346                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1347                });
1348            }
1349            fidl::decode!(
1350                fidl::encoding::BoundedString<128>,
1351                fidl::encoding::DefaultFuchsiaResourceDialect,
1352                &mut self.device_name,
1353                decoder,
1354                offset + 0,
1355                _depth
1356            )?;
1357            fidl::decode!(
1358                fidl::encoding::Optional<
1359                    fidl::encoding::HandleType<
1360                        fidl::Event,
1361                        { fidl::ObjectType::EVENT.into_raw() },
1362                        2147483648,
1363                    >,
1364                >,
1365                fidl::encoding::DefaultFuchsiaResourceDialect,
1366                &mut self.component_token,
1367                decoder,
1368                offset + 16,
1369                _depth
1370            )?;
1371            Ok(())
1372        }
1373    }
1374}