fidl_fuchsia_hardware_pci/
fidl_fuchsia_hardware_pci.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_pci__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14/// Describes and provides access to a given Base Address Register for the device.
15#[derive(Debug, PartialEq)]
16pub struct Bar {
17    /// The BAR id, [0-5).
18    pub bar_id: u32,
19    pub size: u64,
20    pub result: BarResult,
21}
22
23impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Bar {}
24
25#[derive(Debug, PartialEq)]
26pub struct DeviceGetBarResponse {
27    pub result: Bar,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceGetBarResponse {}
31
32#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
33pub struct DeviceGetBtiResponse {
34    pub bti: fidl::Bti,
35}
36
37impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceGetBtiResponse {}
38
39#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
40pub struct DeviceMapInterruptResponse {
41    pub interrupt: fidl::Interrupt,
42}
43
44impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
45    for DeviceMapInterruptResponse
46{
47}
48
49#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
50pub struct IoBar {
51    pub address: u64,
52    pub resource: fidl::Resource,
53}
54
55impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for IoBar {}
56
57#[derive(Debug)]
58pub enum BarResult {
59    Io(IoBar),
60    Vmo(fidl::Vmo),
61    #[doc(hidden)]
62    __SourceBreaking {
63        unknown_ordinal: u64,
64    },
65}
66
67/// Pattern that matches an unknown `BarResult` member.
68#[macro_export]
69macro_rules! BarResultUnknown {
70    () => {
71        _
72    };
73}
74
75// Custom PartialEq so that unknown variants are not equal to themselves.
76impl PartialEq for BarResult {
77    fn eq(&self, other: &Self) -> bool {
78        match (self, other) {
79            (Self::Io(x), Self::Io(y)) => *x == *y,
80            (Self::Vmo(x), Self::Vmo(y)) => *x == *y,
81            _ => false,
82        }
83    }
84}
85
86impl BarResult {
87    #[inline]
88    pub fn ordinal(&self) -> u64 {
89        match *self {
90            Self::Io(_) => 1,
91            Self::Vmo(_) => 2,
92            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
93        }
94    }
95
96    #[inline]
97    pub fn unknown_variant_for_testing() -> Self {
98        Self::__SourceBreaking { unknown_ordinal: 0 }
99    }
100
101    #[inline]
102    pub fn is_unknown(&self) -> bool {
103        match self {
104            Self::__SourceBreaking { .. } => true,
105            _ => false,
106        }
107    }
108}
109
110impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BarResult {}
111
112#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
113pub struct BusMarker;
114
115impl fidl::endpoints::ProtocolMarker for BusMarker {
116    type Proxy = BusProxy;
117    type RequestStream = BusRequestStream;
118    #[cfg(target_os = "fuchsia")]
119    type SynchronousProxy = BusSynchronousProxy;
120
121    const DEBUG_NAME: &'static str = "fuchsia.hardware.pci.Bus";
122}
123impl fidl::endpoints::DiscoverableProtocolMarker for BusMarker {}
124pub type BusReadBarResult = Result<Vec<u8>, i32>;
125
126pub trait BusProxyInterface: Send + Sync {
127    type GetHostBridgeInfoResponseFut: std::future::Future<Output = Result<HostBridgeInfo, fidl::Error>>
128        + Send;
129    fn r#get_host_bridge_info(&self) -> Self::GetHostBridgeInfoResponseFut;
130    type GetDevicesResponseFut: std::future::Future<Output = Result<Vec<PciDevice>, fidl::Error>>
131        + Send;
132    fn r#get_devices(&self) -> Self::GetDevicesResponseFut;
133    type ReadBarResponseFut: std::future::Future<Output = Result<BusReadBarResult, fidl::Error>>
134        + Send;
135    fn r#read_bar(
136        &self,
137        device: &Address,
138        bar_id: u8,
139        offset: u64,
140        size: u64,
141    ) -> Self::ReadBarResponseFut;
142}
143#[derive(Debug)]
144#[cfg(target_os = "fuchsia")]
145pub struct BusSynchronousProxy {
146    client: fidl::client::sync::Client,
147}
148
149#[cfg(target_os = "fuchsia")]
150impl fidl::endpoints::SynchronousProxy for BusSynchronousProxy {
151    type Proxy = BusProxy;
152    type Protocol = BusMarker;
153
154    fn from_channel(inner: fidl::Channel) -> Self {
155        Self::new(inner)
156    }
157
158    fn into_channel(self) -> fidl::Channel {
159        self.client.into_channel()
160    }
161
162    fn as_channel(&self) -> &fidl::Channel {
163        self.client.as_channel()
164    }
165}
166
167#[cfg(target_os = "fuchsia")]
168impl BusSynchronousProxy {
169    pub fn new(channel: fidl::Channel) -> Self {
170        let protocol_name = <BusMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
171        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
172    }
173
174    pub fn into_channel(self) -> fidl::Channel {
175        self.client.into_channel()
176    }
177
178    /// Waits until an event arrives and returns it. It is safe for other
179    /// threads to make concurrent requests while waiting for an event.
180    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<BusEvent, fidl::Error> {
181        BusEvent::decode(self.client.wait_for_event(deadline)?)
182    }
183
184    /// Retrieve information about the segment group and buses covered by a Bus.
185    pub fn r#get_host_bridge_info(
186        &self,
187        ___deadline: zx::MonotonicInstant,
188    ) -> Result<HostBridgeInfo, fidl::Error> {
189        let _response =
190            self.client.send_query::<fidl::encoding::EmptyPayload, BusGetHostBridgeInfoResponse>(
191                (),
192                0x39f0b21bcd8c065d,
193                fidl::encoding::DynamicFlags::empty(),
194                ___deadline,
195            )?;
196        Ok(_response.info)
197    }
198
199    /// Retrieve all Devices on the Bus.
200    pub fn r#get_devices(
201        &self,
202        ___deadline: zx::MonotonicInstant,
203    ) -> Result<Vec<PciDevice>, fidl::Error> {
204        let _response =
205            self.client.send_query::<fidl::encoding::EmptyPayload, BusGetDevicesResponse>(
206                (),
207                0x2b39a32926007c92,
208                fidl::encoding::DynamicFlags::empty(),
209                ___deadline,
210            )?;
211        Ok(_response.devices)
212    }
213
214    /// Read from a Device's base address register (BAR). The BAR must be an MMIO type.
215    ///
216    /// Parameters
217    /// |device|: The address of the device to read from.
218    /// |bar_id|: The ID of the BAR to read.
219    /// |offset|: The offset, in bytes, to start the read (default: 0 bytes).
220    /// |size|: The size of the read (default: 128 bytes). The max size for a
221    /// read is |READBAR_MAX_SIZE|.
222    ///
223    /// Errors:
224    /// |ZX_ERR_NOT_FOUND|: |device| was not found, or |bar_id| did not exist in |device|.
225    /// |ZX_ERR_INVALID_ARGS|: |bar_id| is invalid,  or offset / size combined
226    /// are invalid for the given BAR's size.
227    /// |ZX_ERR_NOT_SUPPORTED|: The BAR specified by |bar_id| is not an MMIO BAR.
228    pub fn r#read_bar(
229        &self,
230        mut device: &Address,
231        mut bar_id: u8,
232        mut offset: u64,
233        mut size: u64,
234        ___deadline: zx::MonotonicInstant,
235    ) -> Result<BusReadBarResult, fidl::Error> {
236        let _response = self
237            .client
238            .send_query::<BusReadBarRequest, fidl::encoding::ResultType<BusReadBarResponse, i32>>(
239                (device, bar_id, offset, size),
240                0x798f39b0dfdc4860,
241                fidl::encoding::DynamicFlags::empty(),
242                ___deadline,
243            )?;
244        Ok(_response.map(|x| x.buffer))
245    }
246}
247
248#[cfg(target_os = "fuchsia")]
249impl From<BusSynchronousProxy> for zx::NullableHandle {
250    fn from(value: BusSynchronousProxy) -> Self {
251        value.into_channel().into()
252    }
253}
254
255#[cfg(target_os = "fuchsia")]
256impl From<fidl::Channel> for BusSynchronousProxy {
257    fn from(value: fidl::Channel) -> Self {
258        Self::new(value)
259    }
260}
261
262#[cfg(target_os = "fuchsia")]
263impl fidl::endpoints::FromClient for BusSynchronousProxy {
264    type Protocol = BusMarker;
265
266    fn from_client(value: fidl::endpoints::ClientEnd<BusMarker>) -> Self {
267        Self::new(value.into_channel())
268    }
269}
270
271#[derive(Debug, Clone)]
272pub struct BusProxy {
273    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
274}
275
276impl fidl::endpoints::Proxy for BusProxy {
277    type Protocol = BusMarker;
278
279    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
280        Self::new(inner)
281    }
282
283    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
284        self.client.into_channel().map_err(|client| Self { client })
285    }
286
287    fn as_channel(&self) -> &::fidl::AsyncChannel {
288        self.client.as_channel()
289    }
290}
291
292impl BusProxy {
293    /// Create a new Proxy for fuchsia.hardware.pci/Bus.
294    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
295        let protocol_name = <BusMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
296        Self { client: fidl::client::Client::new(channel, protocol_name) }
297    }
298
299    /// Get a Stream of events from the remote end of the protocol.
300    ///
301    /// # Panics
302    ///
303    /// Panics if the event stream was already taken.
304    pub fn take_event_stream(&self) -> BusEventStream {
305        BusEventStream { event_receiver: self.client.take_event_receiver() }
306    }
307
308    /// Retrieve information about the segment group and buses covered by a Bus.
309    pub fn r#get_host_bridge_info(
310        &self,
311    ) -> fidl::client::QueryResponseFut<HostBridgeInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
312    {
313        BusProxyInterface::r#get_host_bridge_info(self)
314    }
315
316    /// Retrieve all Devices on the Bus.
317    pub fn r#get_devices(
318        &self,
319    ) -> fidl::client::QueryResponseFut<Vec<PciDevice>, fidl::encoding::DefaultFuchsiaResourceDialect>
320    {
321        BusProxyInterface::r#get_devices(self)
322    }
323
324    /// Read from a Device's base address register (BAR). The BAR must be an MMIO type.
325    ///
326    /// Parameters
327    /// |device|: The address of the device to read from.
328    /// |bar_id|: The ID of the BAR to read.
329    /// |offset|: The offset, in bytes, to start the read (default: 0 bytes).
330    /// |size|: The size of the read (default: 128 bytes). The max size for a
331    /// read is |READBAR_MAX_SIZE|.
332    ///
333    /// Errors:
334    /// |ZX_ERR_NOT_FOUND|: |device| was not found, or |bar_id| did not exist in |device|.
335    /// |ZX_ERR_INVALID_ARGS|: |bar_id| is invalid,  or offset / size combined
336    /// are invalid for the given BAR's size.
337    /// |ZX_ERR_NOT_SUPPORTED|: The BAR specified by |bar_id| is not an MMIO BAR.
338    pub fn r#read_bar(
339        &self,
340        mut device: &Address,
341        mut bar_id: u8,
342        mut offset: u64,
343        mut size: u64,
344    ) -> fidl::client::QueryResponseFut<
345        BusReadBarResult,
346        fidl::encoding::DefaultFuchsiaResourceDialect,
347    > {
348        BusProxyInterface::r#read_bar(self, device, bar_id, offset, size)
349    }
350}
351
352impl BusProxyInterface for BusProxy {
353    type GetHostBridgeInfoResponseFut = fidl::client::QueryResponseFut<
354        HostBridgeInfo,
355        fidl::encoding::DefaultFuchsiaResourceDialect,
356    >;
357    fn r#get_host_bridge_info(&self) -> Self::GetHostBridgeInfoResponseFut {
358        fn _decode(
359            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
360        ) -> Result<HostBridgeInfo, fidl::Error> {
361            let _response = fidl::client::decode_transaction_body::<
362                BusGetHostBridgeInfoResponse,
363                fidl::encoding::DefaultFuchsiaResourceDialect,
364                0x39f0b21bcd8c065d,
365            >(_buf?)?;
366            Ok(_response.info)
367        }
368        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, HostBridgeInfo>(
369            (),
370            0x39f0b21bcd8c065d,
371            fidl::encoding::DynamicFlags::empty(),
372            _decode,
373        )
374    }
375
376    type GetDevicesResponseFut = fidl::client::QueryResponseFut<
377        Vec<PciDevice>,
378        fidl::encoding::DefaultFuchsiaResourceDialect,
379    >;
380    fn r#get_devices(&self) -> Self::GetDevicesResponseFut {
381        fn _decode(
382            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
383        ) -> Result<Vec<PciDevice>, fidl::Error> {
384            let _response = fidl::client::decode_transaction_body::<
385                BusGetDevicesResponse,
386                fidl::encoding::DefaultFuchsiaResourceDialect,
387                0x2b39a32926007c92,
388            >(_buf?)?;
389            Ok(_response.devices)
390        }
391        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<PciDevice>>(
392            (),
393            0x2b39a32926007c92,
394            fidl::encoding::DynamicFlags::empty(),
395            _decode,
396        )
397    }
398
399    type ReadBarResponseFut = fidl::client::QueryResponseFut<
400        BusReadBarResult,
401        fidl::encoding::DefaultFuchsiaResourceDialect,
402    >;
403    fn r#read_bar(
404        &self,
405        mut device: &Address,
406        mut bar_id: u8,
407        mut offset: u64,
408        mut size: u64,
409    ) -> Self::ReadBarResponseFut {
410        fn _decode(
411            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
412        ) -> Result<BusReadBarResult, fidl::Error> {
413            let _response = fidl::client::decode_transaction_body::<
414                fidl::encoding::ResultType<BusReadBarResponse, i32>,
415                fidl::encoding::DefaultFuchsiaResourceDialect,
416                0x798f39b0dfdc4860,
417            >(_buf?)?;
418            Ok(_response.map(|x| x.buffer))
419        }
420        self.client.send_query_and_decode::<BusReadBarRequest, BusReadBarResult>(
421            (device, bar_id, offset, size),
422            0x798f39b0dfdc4860,
423            fidl::encoding::DynamicFlags::empty(),
424            _decode,
425        )
426    }
427}
428
429pub struct BusEventStream {
430    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
431}
432
433impl std::marker::Unpin for BusEventStream {}
434
435impl futures::stream::FusedStream for BusEventStream {
436    fn is_terminated(&self) -> bool {
437        self.event_receiver.is_terminated()
438    }
439}
440
441impl futures::Stream for BusEventStream {
442    type Item = Result<BusEvent, fidl::Error>;
443
444    fn poll_next(
445        mut self: std::pin::Pin<&mut Self>,
446        cx: &mut std::task::Context<'_>,
447    ) -> std::task::Poll<Option<Self::Item>> {
448        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
449            &mut self.event_receiver,
450            cx
451        )?) {
452            Some(buf) => std::task::Poll::Ready(Some(BusEvent::decode(buf))),
453            None => std::task::Poll::Ready(None),
454        }
455    }
456}
457
458#[derive(Debug)]
459pub enum BusEvent {}
460
461impl BusEvent {
462    /// Decodes a message buffer as a [`BusEvent`].
463    fn decode(
464        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
465    ) -> Result<BusEvent, fidl::Error> {
466        let (bytes, _handles) = buf.split_mut();
467        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
468        debug_assert_eq!(tx_header.tx_id, 0);
469        match tx_header.ordinal {
470            _ => Err(fidl::Error::UnknownOrdinal {
471                ordinal: tx_header.ordinal,
472                protocol_name: <BusMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
473            }),
474        }
475    }
476}
477
478/// A Stream of incoming requests for fuchsia.hardware.pci/Bus.
479pub struct BusRequestStream {
480    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
481    is_terminated: bool,
482}
483
484impl std::marker::Unpin for BusRequestStream {}
485
486impl futures::stream::FusedStream for BusRequestStream {
487    fn is_terminated(&self) -> bool {
488        self.is_terminated
489    }
490}
491
492impl fidl::endpoints::RequestStream for BusRequestStream {
493    type Protocol = BusMarker;
494    type ControlHandle = BusControlHandle;
495
496    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
497        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
498    }
499
500    fn control_handle(&self) -> Self::ControlHandle {
501        BusControlHandle { inner: self.inner.clone() }
502    }
503
504    fn into_inner(
505        self,
506    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
507    {
508        (self.inner, self.is_terminated)
509    }
510
511    fn from_inner(
512        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
513        is_terminated: bool,
514    ) -> Self {
515        Self { inner, is_terminated }
516    }
517}
518
519impl futures::Stream for BusRequestStream {
520    type Item = Result<BusRequest, fidl::Error>;
521
522    fn poll_next(
523        mut self: std::pin::Pin<&mut Self>,
524        cx: &mut std::task::Context<'_>,
525    ) -> std::task::Poll<Option<Self::Item>> {
526        let this = &mut *self;
527        if this.inner.check_shutdown(cx) {
528            this.is_terminated = true;
529            return std::task::Poll::Ready(None);
530        }
531        if this.is_terminated {
532            panic!("polled BusRequestStream after completion");
533        }
534        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
535            |bytes, handles| {
536                match this.inner.channel().read_etc(cx, bytes, handles) {
537                    std::task::Poll::Ready(Ok(())) => {}
538                    std::task::Poll::Pending => return std::task::Poll::Pending,
539                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
540                        this.is_terminated = true;
541                        return std::task::Poll::Ready(None);
542                    }
543                    std::task::Poll::Ready(Err(e)) => {
544                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
545                            e.into(),
546                        ))));
547                    }
548                }
549
550                // A message has been received from the channel
551                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
552
553                std::task::Poll::Ready(Some(match header.ordinal {
554                    0x39f0b21bcd8c065d => {
555                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
556                        let mut req = fidl::new_empty!(
557                            fidl::encoding::EmptyPayload,
558                            fidl::encoding::DefaultFuchsiaResourceDialect
559                        );
560                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
561                        let control_handle = BusControlHandle { inner: this.inner.clone() };
562                        Ok(BusRequest::GetHostBridgeInfo {
563                            responder: BusGetHostBridgeInfoResponder {
564                                control_handle: std::mem::ManuallyDrop::new(control_handle),
565                                tx_id: header.tx_id,
566                            },
567                        })
568                    }
569                    0x2b39a32926007c92 => {
570                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
571                        let mut req = fidl::new_empty!(
572                            fidl::encoding::EmptyPayload,
573                            fidl::encoding::DefaultFuchsiaResourceDialect
574                        );
575                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
576                        let control_handle = BusControlHandle { inner: this.inner.clone() };
577                        Ok(BusRequest::GetDevices {
578                            responder: BusGetDevicesResponder {
579                                control_handle: std::mem::ManuallyDrop::new(control_handle),
580                                tx_id: header.tx_id,
581                            },
582                        })
583                    }
584                    0x798f39b0dfdc4860 => {
585                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
586                        let mut req = fidl::new_empty!(
587                            BusReadBarRequest,
588                            fidl::encoding::DefaultFuchsiaResourceDialect
589                        );
590                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BusReadBarRequest>(&header, _body_bytes, handles, &mut req)?;
591                        let control_handle = BusControlHandle { inner: this.inner.clone() };
592                        Ok(BusRequest::ReadBar {
593                            device: req.device,
594                            bar_id: req.bar_id,
595                            offset: req.offset,
596                            size: req.size,
597
598                            responder: BusReadBarResponder {
599                                control_handle: std::mem::ManuallyDrop::new(control_handle),
600                                tx_id: header.tx_id,
601                            },
602                        })
603                    }
604                    _ => Err(fidl::Error::UnknownOrdinal {
605                        ordinal: header.ordinal,
606                        protocol_name: <BusMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
607                    }),
608                }))
609            },
610        )
611    }
612}
613
614/// The Bus protocol provides information about PCI device children on the PCI
615/// providing the service.
616#[derive(Debug)]
617pub enum BusRequest {
618    /// Retrieve information about the segment group and buses covered by a Bus.
619    GetHostBridgeInfo { responder: BusGetHostBridgeInfoResponder },
620    /// Retrieve all Devices on the Bus.
621    GetDevices { responder: BusGetDevicesResponder },
622    /// Read from a Device's base address register (BAR). The BAR must be an MMIO type.
623    ///
624    /// Parameters
625    /// |device|: The address of the device to read from.
626    /// |bar_id|: The ID of the BAR to read.
627    /// |offset|: The offset, in bytes, to start the read (default: 0 bytes).
628    /// |size|: The size of the read (default: 128 bytes). The max size for a
629    /// read is |READBAR_MAX_SIZE|.
630    ///
631    /// Errors:
632    /// |ZX_ERR_NOT_FOUND|: |device| was not found, or |bar_id| did not exist in |device|.
633    /// |ZX_ERR_INVALID_ARGS|: |bar_id| is invalid,  or offset / size combined
634    /// are invalid for the given BAR's size.
635    /// |ZX_ERR_NOT_SUPPORTED|: The BAR specified by |bar_id| is not an MMIO BAR.
636    ReadBar { device: Address, bar_id: u8, offset: u64, size: u64, responder: BusReadBarResponder },
637}
638
639impl BusRequest {
640    #[allow(irrefutable_let_patterns)]
641    pub fn into_get_host_bridge_info(self) -> Option<(BusGetHostBridgeInfoResponder)> {
642        if let BusRequest::GetHostBridgeInfo { responder } = self {
643            Some((responder))
644        } else {
645            None
646        }
647    }
648
649    #[allow(irrefutable_let_patterns)]
650    pub fn into_get_devices(self) -> Option<(BusGetDevicesResponder)> {
651        if let BusRequest::GetDevices { responder } = self { Some((responder)) } else { None }
652    }
653
654    #[allow(irrefutable_let_patterns)]
655    pub fn into_read_bar(self) -> Option<(Address, u8, u64, u64, BusReadBarResponder)> {
656        if let BusRequest::ReadBar { device, bar_id, offset, size, responder } = self {
657            Some((device, bar_id, offset, size, responder))
658        } else {
659            None
660        }
661    }
662
663    /// Name of the method defined in FIDL
664    pub fn method_name(&self) -> &'static str {
665        match *self {
666            BusRequest::GetHostBridgeInfo { .. } => "get_host_bridge_info",
667            BusRequest::GetDevices { .. } => "get_devices",
668            BusRequest::ReadBar { .. } => "read_bar",
669        }
670    }
671}
672
673#[derive(Debug, Clone)]
674pub struct BusControlHandle {
675    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
676}
677
678impl fidl::endpoints::ControlHandle for BusControlHandle {
679    fn shutdown(&self) {
680        self.inner.shutdown()
681    }
682
683    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
684        self.inner.shutdown_with_epitaph(status)
685    }
686
687    fn is_closed(&self) -> bool {
688        self.inner.channel().is_closed()
689    }
690    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
691        self.inner.channel().on_closed()
692    }
693
694    #[cfg(target_os = "fuchsia")]
695    fn signal_peer(
696        &self,
697        clear_mask: zx::Signals,
698        set_mask: zx::Signals,
699    ) -> Result<(), zx_status::Status> {
700        use fidl::Peered;
701        self.inner.channel().signal_peer(clear_mask, set_mask)
702    }
703}
704
705impl BusControlHandle {}
706
707#[must_use = "FIDL methods require a response to be sent"]
708#[derive(Debug)]
709pub struct BusGetHostBridgeInfoResponder {
710    control_handle: std::mem::ManuallyDrop<BusControlHandle>,
711    tx_id: u32,
712}
713
714/// Set the the channel to be shutdown (see [`BusControlHandle::shutdown`])
715/// if the responder is dropped without sending a response, so that the client
716/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
717impl std::ops::Drop for BusGetHostBridgeInfoResponder {
718    fn drop(&mut self) {
719        self.control_handle.shutdown();
720        // Safety: drops once, never accessed again
721        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
722    }
723}
724
725impl fidl::endpoints::Responder for BusGetHostBridgeInfoResponder {
726    type ControlHandle = BusControlHandle;
727
728    fn control_handle(&self) -> &BusControlHandle {
729        &self.control_handle
730    }
731
732    fn drop_without_shutdown(mut self) {
733        // Safety: drops once, never accessed again due to mem::forget
734        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
735        // Prevent Drop from running (which would shut down the channel)
736        std::mem::forget(self);
737    }
738}
739
740impl BusGetHostBridgeInfoResponder {
741    /// Sends a response to the FIDL transaction.
742    ///
743    /// Sets the channel to shutdown if an error occurs.
744    pub fn send(self, mut info: &HostBridgeInfo) -> Result<(), fidl::Error> {
745        let _result = self.send_raw(info);
746        if _result.is_err() {
747            self.control_handle.shutdown();
748        }
749        self.drop_without_shutdown();
750        _result
751    }
752
753    /// Similar to "send" but does not shutdown the channel if an error occurs.
754    pub fn send_no_shutdown_on_err(self, mut info: &HostBridgeInfo) -> Result<(), fidl::Error> {
755        let _result = self.send_raw(info);
756        self.drop_without_shutdown();
757        _result
758    }
759
760    fn send_raw(&self, mut info: &HostBridgeInfo) -> Result<(), fidl::Error> {
761        self.control_handle.inner.send::<BusGetHostBridgeInfoResponse>(
762            (info,),
763            self.tx_id,
764            0x39f0b21bcd8c065d,
765            fidl::encoding::DynamicFlags::empty(),
766        )
767    }
768}
769
770#[must_use = "FIDL methods require a response to be sent"]
771#[derive(Debug)]
772pub struct BusGetDevicesResponder {
773    control_handle: std::mem::ManuallyDrop<BusControlHandle>,
774    tx_id: u32,
775}
776
777/// Set the the channel to be shutdown (see [`BusControlHandle::shutdown`])
778/// if the responder is dropped without sending a response, so that the client
779/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
780impl std::ops::Drop for BusGetDevicesResponder {
781    fn drop(&mut self) {
782        self.control_handle.shutdown();
783        // Safety: drops once, never accessed again
784        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
785    }
786}
787
788impl fidl::endpoints::Responder for BusGetDevicesResponder {
789    type ControlHandle = BusControlHandle;
790
791    fn control_handle(&self) -> &BusControlHandle {
792        &self.control_handle
793    }
794
795    fn drop_without_shutdown(mut self) {
796        // Safety: drops once, never accessed again due to mem::forget
797        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
798        // Prevent Drop from running (which would shut down the channel)
799        std::mem::forget(self);
800    }
801}
802
803impl BusGetDevicesResponder {
804    /// Sends a response to the FIDL transaction.
805    ///
806    /// Sets the channel to shutdown if an error occurs.
807    pub fn send(self, mut devices: &[PciDevice]) -> Result<(), fidl::Error> {
808        let _result = self.send_raw(devices);
809        if _result.is_err() {
810            self.control_handle.shutdown();
811        }
812        self.drop_without_shutdown();
813        _result
814    }
815
816    /// Similar to "send" but does not shutdown the channel if an error occurs.
817    pub fn send_no_shutdown_on_err(self, mut devices: &[PciDevice]) -> Result<(), fidl::Error> {
818        let _result = self.send_raw(devices);
819        self.drop_without_shutdown();
820        _result
821    }
822
823    fn send_raw(&self, mut devices: &[PciDevice]) -> Result<(), fidl::Error> {
824        self.control_handle.inner.send::<BusGetDevicesResponse>(
825            (devices,),
826            self.tx_id,
827            0x2b39a32926007c92,
828            fidl::encoding::DynamicFlags::empty(),
829        )
830    }
831}
832
833#[must_use = "FIDL methods require a response to be sent"]
834#[derive(Debug)]
835pub struct BusReadBarResponder {
836    control_handle: std::mem::ManuallyDrop<BusControlHandle>,
837    tx_id: u32,
838}
839
840/// Set the the channel to be shutdown (see [`BusControlHandle::shutdown`])
841/// if the responder is dropped without sending a response, so that the client
842/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
843impl std::ops::Drop for BusReadBarResponder {
844    fn drop(&mut self) {
845        self.control_handle.shutdown();
846        // Safety: drops once, never accessed again
847        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
848    }
849}
850
851impl fidl::endpoints::Responder for BusReadBarResponder {
852    type ControlHandle = BusControlHandle;
853
854    fn control_handle(&self) -> &BusControlHandle {
855        &self.control_handle
856    }
857
858    fn drop_without_shutdown(mut self) {
859        // Safety: drops once, never accessed again due to mem::forget
860        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
861        // Prevent Drop from running (which would shut down the channel)
862        std::mem::forget(self);
863    }
864}
865
866impl BusReadBarResponder {
867    /// Sends a response to the FIDL transaction.
868    ///
869    /// Sets the channel to shutdown if an error occurs.
870    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
871        let _result = self.send_raw(result);
872        if _result.is_err() {
873            self.control_handle.shutdown();
874        }
875        self.drop_without_shutdown();
876        _result
877    }
878
879    /// Similar to "send" but does not shutdown the channel if an error occurs.
880    pub fn send_no_shutdown_on_err(
881        self,
882        mut result: Result<&[u8], i32>,
883    ) -> Result<(), fidl::Error> {
884        let _result = self.send_raw(result);
885        self.drop_without_shutdown();
886        _result
887    }
888
889    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
890        self.control_handle.inner.send::<fidl::encoding::ResultType<BusReadBarResponse, i32>>(
891            result.map(|buffer| (buffer,)),
892            self.tx_id,
893            0x798f39b0dfdc4860,
894            fidl::encoding::DynamicFlags::empty(),
895        )
896    }
897}
898
899#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
900pub struct DeviceMarker;
901
902impl fidl::endpoints::ProtocolMarker for DeviceMarker {
903    type Proxy = DeviceProxy;
904    type RequestStream = DeviceRequestStream;
905    #[cfg(target_os = "fuchsia")]
906    type SynchronousProxy = DeviceSynchronousProxy;
907
908    const DEBUG_NAME: &'static str = "fuchsia.hardware.pci.Device";
909}
910impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
911pub type DeviceGetBarResult = Result<Bar, i32>;
912pub type DeviceSetBusMasteringResult = Result<(), i32>;
913pub type DeviceResetDeviceResult = Result<(), i32>;
914pub type DeviceAckInterruptResult = Result<(), i32>;
915pub type DeviceMapInterruptResult = Result<fidl::Interrupt, i32>;
916pub type DeviceSetInterruptModeResult = Result<(), i32>;
917pub type DeviceReadConfig8Result = Result<u8, i32>;
918pub type DeviceReadConfig16Result = Result<u16, i32>;
919pub type DeviceReadConfig32Result = Result<u32, i32>;
920pub type DeviceWriteConfig8Result = Result<(), i32>;
921pub type DeviceWriteConfig16Result = Result<(), i32>;
922pub type DeviceWriteConfig32Result = Result<(), i32>;
923pub type DeviceGetBtiResult = Result<fidl::Bti, i32>;
924
925pub trait DeviceProxyInterface: Send + Sync {
926    type GetDeviceInfoResponseFut: std::future::Future<Output = Result<DeviceInfo, fidl::Error>>
927        + Send;
928    fn r#get_device_info(&self) -> Self::GetDeviceInfoResponseFut;
929    type GetBarResponseFut: std::future::Future<Output = Result<DeviceGetBarResult, fidl::Error>>
930        + Send;
931    fn r#get_bar(&self, bar_id: u32) -> Self::GetBarResponseFut;
932    type SetBusMasteringResponseFut: std::future::Future<Output = Result<DeviceSetBusMasteringResult, fidl::Error>>
933        + Send;
934    fn r#set_bus_mastering(&self, enabled: bool) -> Self::SetBusMasteringResponseFut;
935    type ResetDeviceResponseFut: std::future::Future<Output = Result<DeviceResetDeviceResult, fidl::Error>>
936        + Send;
937    fn r#reset_device(&self) -> Self::ResetDeviceResponseFut;
938    type AckInterruptResponseFut: std::future::Future<Output = Result<DeviceAckInterruptResult, fidl::Error>>
939        + Send;
940    fn r#ack_interrupt(&self) -> Self::AckInterruptResponseFut;
941    type MapInterruptResponseFut: std::future::Future<Output = Result<DeviceMapInterruptResult, fidl::Error>>
942        + Send;
943    fn r#map_interrupt(&self, which_irq: u32) -> Self::MapInterruptResponseFut;
944    type GetInterruptModesResponseFut: std::future::Future<Output = Result<InterruptModes, fidl::Error>>
945        + Send;
946    fn r#get_interrupt_modes(&self) -> Self::GetInterruptModesResponseFut;
947    type SetInterruptModeResponseFut: std::future::Future<Output = Result<DeviceSetInterruptModeResult, fidl::Error>>
948        + Send;
949    fn r#set_interrupt_mode(
950        &self,
951        mode: InterruptMode,
952        requested_irq_count: u32,
953    ) -> Self::SetInterruptModeResponseFut;
954    type ReadConfig8ResponseFut: std::future::Future<Output = Result<DeviceReadConfig8Result, fidl::Error>>
955        + Send;
956    fn r#read_config8(&self, offset: u16) -> Self::ReadConfig8ResponseFut;
957    type ReadConfig16ResponseFut: std::future::Future<Output = Result<DeviceReadConfig16Result, fidl::Error>>
958        + Send;
959    fn r#read_config16(&self, offset: u16) -> Self::ReadConfig16ResponseFut;
960    type ReadConfig32ResponseFut: std::future::Future<Output = Result<DeviceReadConfig32Result, fidl::Error>>
961        + Send;
962    fn r#read_config32(&self, offset: u16) -> Self::ReadConfig32ResponseFut;
963    type WriteConfig8ResponseFut: std::future::Future<Output = Result<DeviceWriteConfig8Result, fidl::Error>>
964        + Send;
965    fn r#write_config8(&self, offset: u16, value: u8) -> Self::WriteConfig8ResponseFut;
966    type WriteConfig16ResponseFut: std::future::Future<Output = Result<DeviceWriteConfig16Result, fidl::Error>>
967        + Send;
968    fn r#write_config16(&self, offset: u16, value: u16) -> Self::WriteConfig16ResponseFut;
969    type WriteConfig32ResponseFut: std::future::Future<Output = Result<DeviceWriteConfig32Result, fidl::Error>>
970        + Send;
971    fn r#write_config32(&self, offset: u16, value: u32) -> Self::WriteConfig32ResponseFut;
972    type GetCapabilitiesResponseFut: std::future::Future<Output = Result<Vec<u8>, fidl::Error>>
973        + Send;
974    fn r#get_capabilities(&self, id: CapabilityId) -> Self::GetCapabilitiesResponseFut;
975    type GetExtendedCapabilitiesResponseFut: std::future::Future<Output = Result<Vec<u16>, fidl::Error>>
976        + Send;
977    fn r#get_extended_capabilities(
978        &self,
979        id: ExtendedCapabilityId,
980    ) -> Self::GetExtendedCapabilitiesResponseFut;
981    type GetBtiResponseFut: std::future::Future<Output = Result<DeviceGetBtiResult, fidl::Error>>
982        + Send;
983    fn r#get_bti(&self, index: u32) -> Self::GetBtiResponseFut;
984}
985#[derive(Debug)]
986#[cfg(target_os = "fuchsia")]
987pub struct DeviceSynchronousProxy {
988    client: fidl::client::sync::Client,
989}
990
991#[cfg(target_os = "fuchsia")]
992impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
993    type Proxy = DeviceProxy;
994    type Protocol = DeviceMarker;
995
996    fn from_channel(inner: fidl::Channel) -> Self {
997        Self::new(inner)
998    }
999
1000    fn into_channel(self) -> fidl::Channel {
1001        self.client.into_channel()
1002    }
1003
1004    fn as_channel(&self) -> &fidl::Channel {
1005        self.client.as_channel()
1006    }
1007}
1008
1009#[cfg(target_os = "fuchsia")]
1010impl DeviceSynchronousProxy {
1011    pub fn new(channel: fidl::Channel) -> Self {
1012        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1013        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1014    }
1015
1016    pub fn into_channel(self) -> fidl::Channel {
1017        self.client.into_channel()
1018    }
1019
1020    /// Waits until an event arrives and returns it. It is safe for other
1021    /// threads to make concurrent requests while waiting for an event.
1022    pub fn wait_for_event(
1023        &self,
1024        deadline: zx::MonotonicInstant,
1025    ) -> Result<DeviceEvent, fidl::Error> {
1026        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
1027    }
1028
1029    /// Returns a structure containing device information from the configuration header.
1030    pub fn r#get_device_info(
1031        &self,
1032        ___deadline: zx::MonotonicInstant,
1033    ) -> Result<DeviceInfo, fidl::Error> {
1034        let _response =
1035            self.client.send_query::<fidl::encoding::EmptyPayload, DeviceGetDeviceInfoResponse>(
1036                (),
1037                0x5599d144d4329916,
1038                fidl::encoding::DynamicFlags::empty(),
1039                ___deadline,
1040            )?;
1041        Ok(_response.info)
1042    }
1043
1044    /// Retrieves information for a specified Base Address Register (BAR). If the BAR contains
1045    /// MSI-X capability tables then an attempt will be made to return an MMIO region excluding
1046    /// those tables, if possible. Otherwise, an error will be returned.
1047    ///
1048    /// Parameters:
1049    /// |bar_id|: The id of the BAR being requested. Valid range is [0, 6).
1050    ///
1051    /// Errors:
1052    /// |ZX_ERR_ACCESS_DENIED|: The specified BAR does not have a driver-accessible region due to
1053    /// the presence of MSI-X tables. To use MSI-X see the |SetInterruptMode| method.
1054    /// |ZX_ERR_INTERNAL|: A bus driver error has occurred.
1055    /// |ZX_ERR_INVALID_ARGS|: The |bar_id| specified is outside of the acceptable range.
1056    /// |ZX_ERR_NOT_FOUND|: The specified |bar_id| does not exist for this device.
1057    pub fn r#get_bar(
1058        &self,
1059        mut bar_id: u32,
1060        ___deadline: zx::MonotonicInstant,
1061    ) -> Result<DeviceGetBarResult, fidl::Error> {
1062        let _response = self.client.send_query::<
1063            DeviceGetBarRequest,
1064            fidl::encoding::ResultType<DeviceGetBarResponse, i32>,
1065        >(
1066            (bar_id,),
1067            0x6b2683f6fbbff679,
1068            fidl::encoding::DynamicFlags::empty(),
1069            ___deadline,
1070        )?;
1071        Ok(_response.map(|x| x.result))
1072    }
1073
1074    /// Enables or disables the bus mastering capability for the device.
1075    ///
1076    /// Parameters:
1077    /// |enable|: true to enable bus mastering, false to disable.
1078    ///
1079    /// Errors:
1080    /// |ZX_ERR_BAD_STATE|: Method was called while the device is disabled.
1081    pub fn r#set_bus_mastering(
1082        &self,
1083        mut enabled: bool,
1084        ___deadline: zx::MonotonicInstant,
1085    ) -> Result<DeviceSetBusMasteringResult, fidl::Error> {
1086        let _response = self.client.send_query::<
1087            DeviceSetBusMasteringRequest,
1088            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1089        >(
1090            (enabled,),
1091            0x3421e9e030211003,
1092            fidl::encoding::DynamicFlags::empty(),
1093            ___deadline,
1094        )?;
1095        Ok(_response.map(|x| x))
1096    }
1097
1098    /// Initiates a function level reset for the device. This is a synchronous
1099    /// operation that will not return ontil the reset is complete. Interrupt
1100    /// operation of the device must be disabled before initiating a reset.
1101    ///
1102    /// Errors:
1103    /// |ZX_ERR_BAD_STATE|: Interrupts were not disabled before calling |ResetDevice|.
1104    /// |ZX_ERR_NOT_SUPPORTED|: The device does not support reset.
1105    /// |ZX_ERR_TIMED_OUT|: The device did not complete its reset in the
1106    /// expected amount of time and is presumed to no longer be operating
1107    /// properly.
1108    pub fn r#reset_device(
1109        &self,
1110        ___deadline: zx::MonotonicInstant,
1111    ) -> Result<DeviceResetDeviceResult, fidl::Error> {
1112        let _response = self.client.send_query::<
1113            fidl::encoding::EmptyPayload,
1114            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1115        >(
1116            (),
1117            0x3c5b7579bb6f8b9f,
1118            fidl::encoding::DynamicFlags::empty(),
1119            ___deadline,
1120        )?;
1121        Ok(_response.map(|x| x))
1122    }
1123
1124    /// Alerts the bus driver to deassert the raised legacy interrupt so that it
1125    /// may be waited on again. Only used if |SetInterruptMode| was called with
1126    /// |PCI_INTERRUPT_MODE_LEGACY|.
1127    ///
1128    /// Errors:
1129    /// |ZX_ERR_BAD_STATE|: device is not configured to use the Legacy interrupt mode.
1130    pub fn r#ack_interrupt(
1131        &self,
1132        ___deadline: zx::MonotonicInstant,
1133    ) -> Result<DeviceAckInterruptResult, fidl::Error> {
1134        let _response = self.client.send_query::<
1135            fidl::encoding::EmptyPayload,
1136            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1137        >(
1138            (),
1139            0x70742f64692d5a6b,
1140            fidl::encoding::DynamicFlags::empty(),
1141            ___deadline,
1142        )?;
1143        Ok(_response.map(|x| x))
1144    }
1145
1146    /// Maps a device's interrupt to a zx:interrupt. The device's interrupt mode
1147    /// must already be configured with |SetInterruptMode|, and |which_irq| must
1148    /// be >= to the number of interrupts reported for that interrupt mode by
1149    /// |GetInterruptModes|. A Legacy interrupt may be mapped multiple times,
1150    /// but the handles will point to the same interrupt object. MSI & MSI-X
1151    /// interrupts may only have one outstanding mapping at a time per
1152    /// interrupt. Outstanding MSI & MSI-X interrupt handles must be closed
1153    /// before attempting to change the interrupt mode in a subsequent call to
1154    /// |SetInterruptMode|.
1155    ///
1156    /// Parameters:
1157    /// |which_irq|: The id of the interrupt to map.
1158    ///
1159    /// Errors:
1160    /// |ZX_ERR_ALREADY_BOUND|: The interrupt specified by |which_irq| is
1161    /// already mapped to a valid handle.
1162    /// |ZX_ERR_BAD_STATE|: interrupts are currently disabled for the device.
1163    /// |ZX_ERR_INVALID_ARGS|: |which_irq| is invalid for the mode.
1164    pub fn r#map_interrupt(
1165        &self,
1166        mut which_irq: u32,
1167        ___deadline: zx::MonotonicInstant,
1168    ) -> Result<DeviceMapInterruptResult, fidl::Error> {
1169        let _response = self.client.send_query::<
1170            DeviceMapInterruptRequest,
1171            fidl::encoding::ResultType<DeviceMapInterruptResponse, i32>,
1172        >(
1173            (which_irq,),
1174            0x25eeff9d34a1fa13,
1175            fidl::encoding::DynamicFlags::empty(),
1176            ___deadline,
1177        )?;
1178        Ok(_response.map(|x| x.interrupt))
1179    }
1180
1181    /// Returns the supported interrupt modes for a device.
1182    pub fn r#get_interrupt_modes(
1183        &self,
1184        ___deadline: zx::MonotonicInstant,
1185    ) -> Result<InterruptModes, fidl::Error> {
1186        let _response = self
1187            .client
1188            .send_query::<fidl::encoding::EmptyPayload, DeviceGetInterruptModesResponse>(
1189                (),
1190                0x93f4cd8f79e9f4a,
1191                fidl::encoding::DynamicFlags::empty(),
1192                ___deadline,
1193            )?;
1194        Ok(_response.modes)
1195    }
1196
1197    /// Configures the interrupt mode for a device. When changing from one
1198    /// interrupt mode to another the driver must ensure existing interrupt
1199    /// handles are closed beforehand.
1200    ///
1201    /// Parameters:
1202    /// |mode|: The |InterruptMode| to request from the bus driver.
1203    /// |requested_irq_count|: The number of interrupts requested.
1204    ///
1205    /// Errors:
1206    /// |ZX_ERR_BAD_STATE|: The driver attempted to change interrupt mode while
1207    /// existing handles to mapped MSIs exist.
1208    /// |ZX_ERR_INVALID_ARGS|: |requested_irq_count| is 0.
1209    /// |ZX_ERR_NOT_SUPPORTED|: The provided |mode| is not supported, or invalid.
1210    pub fn r#set_interrupt_mode(
1211        &self,
1212        mut mode: InterruptMode,
1213        mut requested_irq_count: u32,
1214        ___deadline: zx::MonotonicInstant,
1215    ) -> Result<DeviceSetInterruptModeResult, fidl::Error> {
1216        let _response = self.client.send_query::<
1217            DeviceSetInterruptModeRequest,
1218            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1219        >(
1220            (mode, requested_irq_count,),
1221            0x85bebad3eb24866,
1222            fidl::encoding::DynamicFlags::empty(),
1223            ___deadline,
1224        )?;
1225        Ok(_response.map(|x| x))
1226    }
1227
1228    /// Reads a byte from the device's configuration space. |Offset| must be
1229    /// within [0x0, 0xFF] if PCI, or [0x0, 0xFFF) if PCIe. In most cases a
1230    /// device will be PCIe.
1231    ///
1232    /// Parameters:
1233    /// |offset|: The offset into the device's configuration space to read.
1234    ///
1235    /// Errors:
1236    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
1237    pub fn r#read_config8(
1238        &self,
1239        mut offset: u16,
1240        ___deadline: zx::MonotonicInstant,
1241    ) -> Result<DeviceReadConfig8Result, fidl::Error> {
1242        let _response = self.client.send_query::<
1243            DeviceReadConfig8Request,
1244            fidl::encoding::ResultType<DeviceReadConfig8Response, i32>,
1245        >(
1246            (offset,),
1247            0x28f9eb9e6dadda1c,
1248            fidl::encoding::DynamicFlags::empty(),
1249            ___deadline,
1250        )?;
1251        Ok(_response.map(|x| x.value))
1252    }
1253
1254    /// Reads two bytes from the device's configuration space. |Offset| must be
1255    /// within [0x0, 0xFE] if PCI, or [0x0, 0xFFE] if PCIe. In most cases a
1256    /// device will be PCIe.
1257    ///
1258    /// Parameters:
1259    /// |offset|: The offset into the device's configuration space to read.
1260    ///
1261    /// Errors:
1262    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
1263    pub fn r#read_config16(
1264        &self,
1265        mut offset: u16,
1266        ___deadline: zx::MonotonicInstant,
1267    ) -> Result<DeviceReadConfig16Result, fidl::Error> {
1268        let _response = self.client.send_query::<
1269            DeviceReadConfig16Request,
1270            fidl::encoding::ResultType<DeviceReadConfig16Response, i32>,
1271        >(
1272            (offset,),
1273            0x3bcda6171a3270bb,
1274            fidl::encoding::DynamicFlags::empty(),
1275            ___deadline,
1276        )?;
1277        Ok(_response.map(|x| x.value))
1278    }
1279
1280    /// Reads four bytes from the device's configuration space. |Offset| must be
1281    /// within [0x0, 0xFC] if PCI, or [0x0, 0xFFC] if PCIe. In most cases a
1282    /// device will be PCIe.
1283    ///
1284    /// Parameters:
1285    /// |offset|: The offset into the device's configuration space to read.
1286    ///
1287    /// Errors:
1288    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
1289    pub fn r#read_config32(
1290        &self,
1291        mut offset: u16,
1292        ___deadline: zx::MonotonicInstant,
1293    ) -> Result<DeviceReadConfig32Result, fidl::Error> {
1294        let _response = self.client.send_query::<
1295            DeviceReadConfig32Request,
1296            fidl::encoding::ResultType<DeviceReadConfig32Response, i32>,
1297        >(
1298            (offset,),
1299            0x55357535402f7507,
1300            fidl::encoding::DynamicFlags::empty(),
1301            ___deadline,
1302        )?;
1303        Ok(_response.map(|x| x.value))
1304    }
1305
1306    /// Writes a byte to the device's configuration space. The acceptable
1307    /// ranges of |offset| for writes are [0x40, 0xFF] if PCI, or [0x40,
1308    /// 0xFFF] if PCIe. For most purposes a device will be PCIe.
1309    ///
1310    ///
1311    /// Parameters
1312    /// |offset|: The offset into the device's configuration space to read.
1313    /// |value|: The value to write.
1314    ///
1315    /// Errors:
1316    /// |ZX_ERR_ACCESS_DENIED|: |offset| is within the device's configuration header.
1317    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
1318    pub fn r#write_config8(
1319        &self,
1320        mut offset: u16,
1321        mut value: u8,
1322        ___deadline: zx::MonotonicInstant,
1323    ) -> Result<DeviceWriteConfig8Result, fidl::Error> {
1324        let _response = self.client.send_query::<
1325            DeviceWriteConfig8Request,
1326            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1327        >(
1328            (offset, value,),
1329            0x49a0719e1433cff,
1330            fidl::encoding::DynamicFlags::empty(),
1331            ___deadline,
1332        )?;
1333        Ok(_response.map(|x| x))
1334    }
1335
1336    /// Writes two bytes to the device's configuration space. The acceptable
1337    /// ranges of |offset| for writes are [0x40, 0xFE] if PCI, or [0x40,
1338    /// 0xFFE] if PCIe. For most purposes a device will be PCIe.
1339    ///
1340    ///
1341    /// Parameters
1342    /// |offset|: The offset into the device's configuration space to read.
1343    /// |value|: The value to write.
1344    ///
1345    /// Errors:
1346    /// |ZX_ERR_ACCESS_DENIED|: |offset| is within the device's configuration header.
1347    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
1348    pub fn r#write_config16(
1349        &self,
1350        mut offset: u16,
1351        mut value: u16,
1352        ___deadline: zx::MonotonicInstant,
1353    ) -> Result<DeviceWriteConfig16Result, fidl::Error> {
1354        let _response = self.client.send_query::<
1355            DeviceWriteConfig16Request,
1356            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1357        >(
1358            (offset, value,),
1359            0x3e30bf13f1c07eff,
1360            fidl::encoding::DynamicFlags::empty(),
1361            ___deadline,
1362        )?;
1363        Ok(_response.map(|x| x))
1364    }
1365
1366    /// Writes four bytes to the device's configuration space. The acceptable
1367    /// ranges of |offset| for writes are [0x40, 0xFC] if PCI, or [0x40,
1368    /// 0xFFC] if PCIe. For most purposes a device will be PCIe.
1369    ///
1370    ///
1371    /// Parameters
1372    /// |offset|: The offset into the device's configuration space to read.
1373    /// |value|: The value to write.
1374    ///
1375    /// Errors:
1376    /// |ZX_ERR_ACCESS_DENIED|: |offset| is within the device's configuration header.
1377    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
1378    pub fn r#write_config32(
1379        &self,
1380        mut offset: u16,
1381        mut value: u32,
1382        ___deadline: zx::MonotonicInstant,
1383    ) -> Result<DeviceWriteConfig32Result, fidl::Error> {
1384        let _response = self.client.send_query::<
1385            DeviceWriteConfig32Request,
1386            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1387        >(
1388            (offset, value,),
1389            0x161584e5199b388,
1390            fidl::encoding::DynamicFlags::empty(),
1391            ___deadline,
1392        )?;
1393        Ok(_response.map(|x| x))
1394    }
1395
1396    /// Returns a vector of offsets in configuration space corresponding to
1397    /// capabilities matching the provided capability |id|.  If no corresponding
1398    /// match is found then the vector will be empty.
1399    ///
1400    /// Parameters:
1401    /// |id|: the capability id to search for.
1402    pub fn r#get_capabilities(
1403        &self,
1404        mut id: CapabilityId,
1405        ___deadline: zx::MonotonicInstant,
1406    ) -> Result<Vec<u8>, fidl::Error> {
1407        let _response =
1408            self.client.send_query::<DeviceGetCapabilitiesRequest, DeviceGetCapabilitiesResponse>(
1409                (id,),
1410                0x3a050fde46f3ba0f,
1411                fidl::encoding::DynamicFlags::empty(),
1412                ___deadline,
1413            )?;
1414        Ok(_response.offsets)
1415    }
1416
1417    /// Returns a vector of offsets in configuration space corresponding to
1418    /// extended capabilities matching the provided extended capability |id|.
1419    /// If no corresponding match is found then the vector will be empty.
1420    ///
1421    /// Parameters:
1422    /// |id|: the capability id to search for
1423    pub fn r#get_extended_capabilities(
1424        &self,
1425        mut id: ExtendedCapabilityId,
1426        ___deadline: zx::MonotonicInstant,
1427    ) -> Result<Vec<u16>, fidl::Error> {
1428        let _response = self.client.send_query::<
1429            DeviceGetExtendedCapabilitiesRequest,
1430            DeviceGetExtendedCapabilitiesResponse,
1431        >(
1432            (id,),
1433            0xb8573efcaae0c39,
1434            fidl::encoding::DynamicFlags::empty(),
1435            ___deadline,
1436        )?;
1437        Ok(_response.offsets)
1438    }
1439
1440    /// Returns the Bus Transaction Intiator (BTI) at a given index for the device.
1441    ///
1442    /// Parameters:
1443    /// |index|: the BTI to request.
1444    ///
1445    /// Errors:
1446    /// |ZX_ERR_OUT_OF_RANGE|: |index| was not 0.
1447    pub fn r#get_bti(
1448        &self,
1449        mut index: u32,
1450        ___deadline: zx::MonotonicInstant,
1451    ) -> Result<DeviceGetBtiResult, fidl::Error> {
1452        let _response = self.client.send_query::<
1453            DeviceGetBtiRequest,
1454            fidl::encoding::ResultType<DeviceGetBtiResponse, i32>,
1455        >(
1456            (index,),
1457            0x5e4fe9efb12d9ee3,
1458            fidl::encoding::DynamicFlags::empty(),
1459            ___deadline,
1460        )?;
1461        Ok(_response.map(|x| x.bti))
1462    }
1463}
1464
1465#[cfg(target_os = "fuchsia")]
1466impl From<DeviceSynchronousProxy> for zx::NullableHandle {
1467    fn from(value: DeviceSynchronousProxy) -> Self {
1468        value.into_channel().into()
1469    }
1470}
1471
1472#[cfg(target_os = "fuchsia")]
1473impl From<fidl::Channel> for DeviceSynchronousProxy {
1474    fn from(value: fidl::Channel) -> Self {
1475        Self::new(value)
1476    }
1477}
1478
1479#[cfg(target_os = "fuchsia")]
1480impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
1481    type Protocol = DeviceMarker;
1482
1483    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
1484        Self::new(value.into_channel())
1485    }
1486}
1487
1488#[derive(Debug, Clone)]
1489pub struct DeviceProxy {
1490    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1491}
1492
1493impl fidl::endpoints::Proxy for DeviceProxy {
1494    type Protocol = DeviceMarker;
1495
1496    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1497        Self::new(inner)
1498    }
1499
1500    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1501        self.client.into_channel().map_err(|client| Self { client })
1502    }
1503
1504    fn as_channel(&self) -> &::fidl::AsyncChannel {
1505        self.client.as_channel()
1506    }
1507}
1508
1509impl DeviceProxy {
1510    /// Create a new Proxy for fuchsia.hardware.pci/Device.
1511    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1512        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1513        Self { client: fidl::client::Client::new(channel, protocol_name) }
1514    }
1515
1516    /// Get a Stream of events from the remote end of the protocol.
1517    ///
1518    /// # Panics
1519    ///
1520    /// Panics if the event stream was already taken.
1521    pub fn take_event_stream(&self) -> DeviceEventStream {
1522        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
1523    }
1524
1525    /// Returns a structure containing device information from the configuration header.
1526    pub fn r#get_device_info(
1527        &self,
1528    ) -> fidl::client::QueryResponseFut<DeviceInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
1529    {
1530        DeviceProxyInterface::r#get_device_info(self)
1531    }
1532
1533    /// Retrieves information for a specified Base Address Register (BAR). If the BAR contains
1534    /// MSI-X capability tables then an attempt will be made to return an MMIO region excluding
1535    /// those tables, if possible. Otherwise, an error will be returned.
1536    ///
1537    /// Parameters:
1538    /// |bar_id|: The id of the BAR being requested. Valid range is [0, 6).
1539    ///
1540    /// Errors:
1541    /// |ZX_ERR_ACCESS_DENIED|: The specified BAR does not have a driver-accessible region due to
1542    /// the presence of MSI-X tables. To use MSI-X see the |SetInterruptMode| method.
1543    /// |ZX_ERR_INTERNAL|: A bus driver error has occurred.
1544    /// |ZX_ERR_INVALID_ARGS|: The |bar_id| specified is outside of the acceptable range.
1545    /// |ZX_ERR_NOT_FOUND|: The specified |bar_id| does not exist for this device.
1546    pub fn r#get_bar(
1547        &self,
1548        mut bar_id: u32,
1549    ) -> fidl::client::QueryResponseFut<
1550        DeviceGetBarResult,
1551        fidl::encoding::DefaultFuchsiaResourceDialect,
1552    > {
1553        DeviceProxyInterface::r#get_bar(self, bar_id)
1554    }
1555
1556    /// Enables or disables the bus mastering capability for the device.
1557    ///
1558    /// Parameters:
1559    /// |enable|: true to enable bus mastering, false to disable.
1560    ///
1561    /// Errors:
1562    /// |ZX_ERR_BAD_STATE|: Method was called while the device is disabled.
1563    pub fn r#set_bus_mastering(
1564        &self,
1565        mut enabled: bool,
1566    ) -> fidl::client::QueryResponseFut<
1567        DeviceSetBusMasteringResult,
1568        fidl::encoding::DefaultFuchsiaResourceDialect,
1569    > {
1570        DeviceProxyInterface::r#set_bus_mastering(self, enabled)
1571    }
1572
1573    /// Initiates a function level reset for the device. This is a synchronous
1574    /// operation that will not return ontil the reset is complete. Interrupt
1575    /// operation of the device must be disabled before initiating a reset.
1576    ///
1577    /// Errors:
1578    /// |ZX_ERR_BAD_STATE|: Interrupts were not disabled before calling |ResetDevice|.
1579    /// |ZX_ERR_NOT_SUPPORTED|: The device does not support reset.
1580    /// |ZX_ERR_TIMED_OUT|: The device did not complete its reset in the
1581    /// expected amount of time and is presumed to no longer be operating
1582    /// properly.
1583    pub fn r#reset_device(
1584        &self,
1585    ) -> fidl::client::QueryResponseFut<
1586        DeviceResetDeviceResult,
1587        fidl::encoding::DefaultFuchsiaResourceDialect,
1588    > {
1589        DeviceProxyInterface::r#reset_device(self)
1590    }
1591
1592    /// Alerts the bus driver to deassert the raised legacy interrupt so that it
1593    /// may be waited on again. Only used if |SetInterruptMode| was called with
1594    /// |PCI_INTERRUPT_MODE_LEGACY|.
1595    ///
1596    /// Errors:
1597    /// |ZX_ERR_BAD_STATE|: device is not configured to use the Legacy interrupt mode.
1598    pub fn r#ack_interrupt(
1599        &self,
1600    ) -> fidl::client::QueryResponseFut<
1601        DeviceAckInterruptResult,
1602        fidl::encoding::DefaultFuchsiaResourceDialect,
1603    > {
1604        DeviceProxyInterface::r#ack_interrupt(self)
1605    }
1606
1607    /// Maps a device's interrupt to a zx:interrupt. The device's interrupt mode
1608    /// must already be configured with |SetInterruptMode|, and |which_irq| must
1609    /// be >= to the number of interrupts reported for that interrupt mode by
1610    /// |GetInterruptModes|. A Legacy interrupt may be mapped multiple times,
1611    /// but the handles will point to the same interrupt object. MSI & MSI-X
1612    /// interrupts may only have one outstanding mapping at a time per
1613    /// interrupt. Outstanding MSI & MSI-X interrupt handles must be closed
1614    /// before attempting to change the interrupt mode in a subsequent call to
1615    /// |SetInterruptMode|.
1616    ///
1617    /// Parameters:
1618    /// |which_irq|: The id of the interrupt to map.
1619    ///
1620    /// Errors:
1621    /// |ZX_ERR_ALREADY_BOUND|: The interrupt specified by |which_irq| is
1622    /// already mapped to a valid handle.
1623    /// |ZX_ERR_BAD_STATE|: interrupts are currently disabled for the device.
1624    /// |ZX_ERR_INVALID_ARGS|: |which_irq| is invalid for the mode.
1625    pub fn r#map_interrupt(
1626        &self,
1627        mut which_irq: u32,
1628    ) -> fidl::client::QueryResponseFut<
1629        DeviceMapInterruptResult,
1630        fidl::encoding::DefaultFuchsiaResourceDialect,
1631    > {
1632        DeviceProxyInterface::r#map_interrupt(self, which_irq)
1633    }
1634
1635    /// Returns the supported interrupt modes for a device.
1636    pub fn r#get_interrupt_modes(
1637        &self,
1638    ) -> fidl::client::QueryResponseFut<InterruptModes, fidl::encoding::DefaultFuchsiaResourceDialect>
1639    {
1640        DeviceProxyInterface::r#get_interrupt_modes(self)
1641    }
1642
1643    /// Configures the interrupt mode for a device. When changing from one
1644    /// interrupt mode to another the driver must ensure existing interrupt
1645    /// handles are closed beforehand.
1646    ///
1647    /// Parameters:
1648    /// |mode|: The |InterruptMode| to request from the bus driver.
1649    /// |requested_irq_count|: The number of interrupts requested.
1650    ///
1651    /// Errors:
1652    /// |ZX_ERR_BAD_STATE|: The driver attempted to change interrupt mode while
1653    /// existing handles to mapped MSIs exist.
1654    /// |ZX_ERR_INVALID_ARGS|: |requested_irq_count| is 0.
1655    /// |ZX_ERR_NOT_SUPPORTED|: The provided |mode| is not supported, or invalid.
1656    pub fn r#set_interrupt_mode(
1657        &self,
1658        mut mode: InterruptMode,
1659        mut requested_irq_count: u32,
1660    ) -> fidl::client::QueryResponseFut<
1661        DeviceSetInterruptModeResult,
1662        fidl::encoding::DefaultFuchsiaResourceDialect,
1663    > {
1664        DeviceProxyInterface::r#set_interrupt_mode(self, mode, requested_irq_count)
1665    }
1666
1667    /// Reads a byte from the device's configuration space. |Offset| must be
1668    /// within [0x0, 0xFF] if PCI, or [0x0, 0xFFF) if PCIe. In most cases a
1669    /// device will be PCIe.
1670    ///
1671    /// Parameters:
1672    /// |offset|: The offset into the device's configuration space to read.
1673    ///
1674    /// Errors:
1675    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
1676    pub fn r#read_config8(
1677        &self,
1678        mut offset: u16,
1679    ) -> fidl::client::QueryResponseFut<
1680        DeviceReadConfig8Result,
1681        fidl::encoding::DefaultFuchsiaResourceDialect,
1682    > {
1683        DeviceProxyInterface::r#read_config8(self, offset)
1684    }
1685
1686    /// Reads two bytes from the device's configuration space. |Offset| must be
1687    /// within [0x0, 0xFE] if PCI, or [0x0, 0xFFE] if PCIe. In most cases a
1688    /// device will be PCIe.
1689    ///
1690    /// Parameters:
1691    /// |offset|: The offset into the device's configuration space to read.
1692    ///
1693    /// Errors:
1694    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
1695    pub fn r#read_config16(
1696        &self,
1697        mut offset: u16,
1698    ) -> fidl::client::QueryResponseFut<
1699        DeviceReadConfig16Result,
1700        fidl::encoding::DefaultFuchsiaResourceDialect,
1701    > {
1702        DeviceProxyInterface::r#read_config16(self, offset)
1703    }
1704
1705    /// Reads four bytes from the device's configuration space. |Offset| must be
1706    /// within [0x0, 0xFC] if PCI, or [0x0, 0xFFC] if PCIe. In most cases a
1707    /// device will be PCIe.
1708    ///
1709    /// Parameters:
1710    /// |offset|: The offset into the device's configuration space to read.
1711    ///
1712    /// Errors:
1713    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
1714    pub fn r#read_config32(
1715        &self,
1716        mut offset: u16,
1717    ) -> fidl::client::QueryResponseFut<
1718        DeviceReadConfig32Result,
1719        fidl::encoding::DefaultFuchsiaResourceDialect,
1720    > {
1721        DeviceProxyInterface::r#read_config32(self, offset)
1722    }
1723
1724    /// Writes a byte to the device's configuration space. The acceptable
1725    /// ranges of |offset| for writes are [0x40, 0xFF] if PCI, or [0x40,
1726    /// 0xFFF] if PCIe. For most purposes a device will be PCIe.
1727    ///
1728    ///
1729    /// Parameters
1730    /// |offset|: The offset into the device's configuration space to read.
1731    /// |value|: The value to write.
1732    ///
1733    /// Errors:
1734    /// |ZX_ERR_ACCESS_DENIED|: |offset| is within the device's configuration header.
1735    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
1736    pub fn r#write_config8(
1737        &self,
1738        mut offset: u16,
1739        mut value: u8,
1740    ) -> fidl::client::QueryResponseFut<
1741        DeviceWriteConfig8Result,
1742        fidl::encoding::DefaultFuchsiaResourceDialect,
1743    > {
1744        DeviceProxyInterface::r#write_config8(self, offset, value)
1745    }
1746
1747    /// Writes two bytes to the device's configuration space. The acceptable
1748    /// ranges of |offset| for writes are [0x40, 0xFE] if PCI, or [0x40,
1749    /// 0xFFE] if PCIe. For most purposes a device will be PCIe.
1750    ///
1751    ///
1752    /// Parameters
1753    /// |offset|: The offset into the device's configuration space to read.
1754    /// |value|: The value to write.
1755    ///
1756    /// Errors:
1757    /// |ZX_ERR_ACCESS_DENIED|: |offset| is within the device's configuration header.
1758    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
1759    pub fn r#write_config16(
1760        &self,
1761        mut offset: u16,
1762        mut value: u16,
1763    ) -> fidl::client::QueryResponseFut<
1764        DeviceWriteConfig16Result,
1765        fidl::encoding::DefaultFuchsiaResourceDialect,
1766    > {
1767        DeviceProxyInterface::r#write_config16(self, offset, value)
1768    }
1769
1770    /// Writes four bytes to the device's configuration space. The acceptable
1771    /// ranges of |offset| for writes are [0x40, 0xFC] if PCI, or [0x40,
1772    /// 0xFFC] if PCIe. For most purposes a device will be PCIe.
1773    ///
1774    ///
1775    /// Parameters
1776    /// |offset|: The offset into the device's configuration space to read.
1777    /// |value|: The value to write.
1778    ///
1779    /// Errors:
1780    /// |ZX_ERR_ACCESS_DENIED|: |offset| is within the device's configuration header.
1781    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
1782    pub fn r#write_config32(
1783        &self,
1784        mut offset: u16,
1785        mut value: u32,
1786    ) -> fidl::client::QueryResponseFut<
1787        DeviceWriteConfig32Result,
1788        fidl::encoding::DefaultFuchsiaResourceDialect,
1789    > {
1790        DeviceProxyInterface::r#write_config32(self, offset, value)
1791    }
1792
1793    /// Returns a vector of offsets in configuration space corresponding to
1794    /// capabilities matching the provided capability |id|.  If no corresponding
1795    /// match is found then the vector will be empty.
1796    ///
1797    /// Parameters:
1798    /// |id|: the capability id to search for.
1799    pub fn r#get_capabilities(
1800        &self,
1801        mut id: CapabilityId,
1802    ) -> fidl::client::QueryResponseFut<Vec<u8>, fidl::encoding::DefaultFuchsiaResourceDialect>
1803    {
1804        DeviceProxyInterface::r#get_capabilities(self, id)
1805    }
1806
1807    /// Returns a vector of offsets in configuration space corresponding to
1808    /// extended capabilities matching the provided extended capability |id|.
1809    /// If no corresponding match is found then the vector will be empty.
1810    ///
1811    /// Parameters:
1812    /// |id|: the capability id to search for
1813    pub fn r#get_extended_capabilities(
1814        &self,
1815        mut id: ExtendedCapabilityId,
1816    ) -> fidl::client::QueryResponseFut<Vec<u16>, fidl::encoding::DefaultFuchsiaResourceDialect>
1817    {
1818        DeviceProxyInterface::r#get_extended_capabilities(self, id)
1819    }
1820
1821    /// Returns the Bus Transaction Intiator (BTI) at a given index for the device.
1822    ///
1823    /// Parameters:
1824    /// |index|: the BTI to request.
1825    ///
1826    /// Errors:
1827    /// |ZX_ERR_OUT_OF_RANGE|: |index| was not 0.
1828    pub fn r#get_bti(
1829        &self,
1830        mut index: u32,
1831    ) -> fidl::client::QueryResponseFut<
1832        DeviceGetBtiResult,
1833        fidl::encoding::DefaultFuchsiaResourceDialect,
1834    > {
1835        DeviceProxyInterface::r#get_bti(self, index)
1836    }
1837}
1838
1839impl DeviceProxyInterface for DeviceProxy {
1840    type GetDeviceInfoResponseFut =
1841        fidl::client::QueryResponseFut<DeviceInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
1842    fn r#get_device_info(&self) -> Self::GetDeviceInfoResponseFut {
1843        fn _decode(
1844            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1845        ) -> Result<DeviceInfo, fidl::Error> {
1846            let _response = fidl::client::decode_transaction_body::<
1847                DeviceGetDeviceInfoResponse,
1848                fidl::encoding::DefaultFuchsiaResourceDialect,
1849                0x5599d144d4329916,
1850            >(_buf?)?;
1851            Ok(_response.info)
1852        }
1853        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceInfo>(
1854            (),
1855            0x5599d144d4329916,
1856            fidl::encoding::DynamicFlags::empty(),
1857            _decode,
1858        )
1859    }
1860
1861    type GetBarResponseFut = fidl::client::QueryResponseFut<
1862        DeviceGetBarResult,
1863        fidl::encoding::DefaultFuchsiaResourceDialect,
1864    >;
1865    fn r#get_bar(&self, mut bar_id: u32) -> Self::GetBarResponseFut {
1866        fn _decode(
1867            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1868        ) -> Result<DeviceGetBarResult, fidl::Error> {
1869            let _response = fidl::client::decode_transaction_body::<
1870                fidl::encoding::ResultType<DeviceGetBarResponse, i32>,
1871                fidl::encoding::DefaultFuchsiaResourceDialect,
1872                0x6b2683f6fbbff679,
1873            >(_buf?)?;
1874            Ok(_response.map(|x| x.result))
1875        }
1876        self.client.send_query_and_decode::<DeviceGetBarRequest, DeviceGetBarResult>(
1877            (bar_id,),
1878            0x6b2683f6fbbff679,
1879            fidl::encoding::DynamicFlags::empty(),
1880            _decode,
1881        )
1882    }
1883
1884    type SetBusMasteringResponseFut = fidl::client::QueryResponseFut<
1885        DeviceSetBusMasteringResult,
1886        fidl::encoding::DefaultFuchsiaResourceDialect,
1887    >;
1888    fn r#set_bus_mastering(&self, mut enabled: bool) -> Self::SetBusMasteringResponseFut {
1889        fn _decode(
1890            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1891        ) -> Result<DeviceSetBusMasteringResult, fidl::Error> {
1892            let _response = fidl::client::decode_transaction_body::<
1893                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1894                fidl::encoding::DefaultFuchsiaResourceDialect,
1895                0x3421e9e030211003,
1896            >(_buf?)?;
1897            Ok(_response.map(|x| x))
1898        }
1899        self.client
1900            .send_query_and_decode::<DeviceSetBusMasteringRequest, DeviceSetBusMasteringResult>(
1901                (enabled,),
1902                0x3421e9e030211003,
1903                fidl::encoding::DynamicFlags::empty(),
1904                _decode,
1905            )
1906    }
1907
1908    type ResetDeviceResponseFut = fidl::client::QueryResponseFut<
1909        DeviceResetDeviceResult,
1910        fidl::encoding::DefaultFuchsiaResourceDialect,
1911    >;
1912    fn r#reset_device(&self) -> Self::ResetDeviceResponseFut {
1913        fn _decode(
1914            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1915        ) -> Result<DeviceResetDeviceResult, fidl::Error> {
1916            let _response = fidl::client::decode_transaction_body::<
1917                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1918                fidl::encoding::DefaultFuchsiaResourceDialect,
1919                0x3c5b7579bb6f8b9f,
1920            >(_buf?)?;
1921            Ok(_response.map(|x| x))
1922        }
1923        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceResetDeviceResult>(
1924            (),
1925            0x3c5b7579bb6f8b9f,
1926            fidl::encoding::DynamicFlags::empty(),
1927            _decode,
1928        )
1929    }
1930
1931    type AckInterruptResponseFut = fidl::client::QueryResponseFut<
1932        DeviceAckInterruptResult,
1933        fidl::encoding::DefaultFuchsiaResourceDialect,
1934    >;
1935    fn r#ack_interrupt(&self) -> Self::AckInterruptResponseFut {
1936        fn _decode(
1937            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1938        ) -> Result<DeviceAckInterruptResult, fidl::Error> {
1939            let _response = fidl::client::decode_transaction_body::<
1940                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1941                fidl::encoding::DefaultFuchsiaResourceDialect,
1942                0x70742f64692d5a6b,
1943            >(_buf?)?;
1944            Ok(_response.map(|x| x))
1945        }
1946        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceAckInterruptResult>(
1947            (),
1948            0x70742f64692d5a6b,
1949            fidl::encoding::DynamicFlags::empty(),
1950            _decode,
1951        )
1952    }
1953
1954    type MapInterruptResponseFut = fidl::client::QueryResponseFut<
1955        DeviceMapInterruptResult,
1956        fidl::encoding::DefaultFuchsiaResourceDialect,
1957    >;
1958    fn r#map_interrupt(&self, mut which_irq: u32) -> Self::MapInterruptResponseFut {
1959        fn _decode(
1960            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1961        ) -> Result<DeviceMapInterruptResult, fidl::Error> {
1962            let _response = fidl::client::decode_transaction_body::<
1963                fidl::encoding::ResultType<DeviceMapInterruptResponse, i32>,
1964                fidl::encoding::DefaultFuchsiaResourceDialect,
1965                0x25eeff9d34a1fa13,
1966            >(_buf?)?;
1967            Ok(_response.map(|x| x.interrupt))
1968        }
1969        self.client.send_query_and_decode::<DeviceMapInterruptRequest, DeviceMapInterruptResult>(
1970            (which_irq,),
1971            0x25eeff9d34a1fa13,
1972            fidl::encoding::DynamicFlags::empty(),
1973            _decode,
1974        )
1975    }
1976
1977    type GetInterruptModesResponseFut = fidl::client::QueryResponseFut<
1978        InterruptModes,
1979        fidl::encoding::DefaultFuchsiaResourceDialect,
1980    >;
1981    fn r#get_interrupt_modes(&self) -> Self::GetInterruptModesResponseFut {
1982        fn _decode(
1983            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1984        ) -> Result<InterruptModes, fidl::Error> {
1985            let _response = fidl::client::decode_transaction_body::<
1986                DeviceGetInterruptModesResponse,
1987                fidl::encoding::DefaultFuchsiaResourceDialect,
1988                0x93f4cd8f79e9f4a,
1989            >(_buf?)?;
1990            Ok(_response.modes)
1991        }
1992        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, InterruptModes>(
1993            (),
1994            0x93f4cd8f79e9f4a,
1995            fidl::encoding::DynamicFlags::empty(),
1996            _decode,
1997        )
1998    }
1999
2000    type SetInterruptModeResponseFut = fidl::client::QueryResponseFut<
2001        DeviceSetInterruptModeResult,
2002        fidl::encoding::DefaultFuchsiaResourceDialect,
2003    >;
2004    fn r#set_interrupt_mode(
2005        &self,
2006        mut mode: InterruptMode,
2007        mut requested_irq_count: u32,
2008    ) -> Self::SetInterruptModeResponseFut {
2009        fn _decode(
2010            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2011        ) -> Result<DeviceSetInterruptModeResult, fidl::Error> {
2012            let _response = fidl::client::decode_transaction_body::<
2013                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2014                fidl::encoding::DefaultFuchsiaResourceDialect,
2015                0x85bebad3eb24866,
2016            >(_buf?)?;
2017            Ok(_response.map(|x| x))
2018        }
2019        self.client
2020            .send_query_and_decode::<DeviceSetInterruptModeRequest, DeviceSetInterruptModeResult>(
2021                (mode, requested_irq_count),
2022                0x85bebad3eb24866,
2023                fidl::encoding::DynamicFlags::empty(),
2024                _decode,
2025            )
2026    }
2027
2028    type ReadConfig8ResponseFut = fidl::client::QueryResponseFut<
2029        DeviceReadConfig8Result,
2030        fidl::encoding::DefaultFuchsiaResourceDialect,
2031    >;
2032    fn r#read_config8(&self, mut offset: u16) -> Self::ReadConfig8ResponseFut {
2033        fn _decode(
2034            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2035        ) -> Result<DeviceReadConfig8Result, fidl::Error> {
2036            let _response = fidl::client::decode_transaction_body::<
2037                fidl::encoding::ResultType<DeviceReadConfig8Response, i32>,
2038                fidl::encoding::DefaultFuchsiaResourceDialect,
2039                0x28f9eb9e6dadda1c,
2040            >(_buf?)?;
2041            Ok(_response.map(|x| x.value))
2042        }
2043        self.client.send_query_and_decode::<DeviceReadConfig8Request, DeviceReadConfig8Result>(
2044            (offset,),
2045            0x28f9eb9e6dadda1c,
2046            fidl::encoding::DynamicFlags::empty(),
2047            _decode,
2048        )
2049    }
2050
2051    type ReadConfig16ResponseFut = fidl::client::QueryResponseFut<
2052        DeviceReadConfig16Result,
2053        fidl::encoding::DefaultFuchsiaResourceDialect,
2054    >;
2055    fn r#read_config16(&self, mut offset: u16) -> Self::ReadConfig16ResponseFut {
2056        fn _decode(
2057            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2058        ) -> Result<DeviceReadConfig16Result, fidl::Error> {
2059            let _response = fidl::client::decode_transaction_body::<
2060                fidl::encoding::ResultType<DeviceReadConfig16Response, i32>,
2061                fidl::encoding::DefaultFuchsiaResourceDialect,
2062                0x3bcda6171a3270bb,
2063            >(_buf?)?;
2064            Ok(_response.map(|x| x.value))
2065        }
2066        self.client.send_query_and_decode::<DeviceReadConfig16Request, DeviceReadConfig16Result>(
2067            (offset,),
2068            0x3bcda6171a3270bb,
2069            fidl::encoding::DynamicFlags::empty(),
2070            _decode,
2071        )
2072    }
2073
2074    type ReadConfig32ResponseFut = fidl::client::QueryResponseFut<
2075        DeviceReadConfig32Result,
2076        fidl::encoding::DefaultFuchsiaResourceDialect,
2077    >;
2078    fn r#read_config32(&self, mut offset: u16) -> Self::ReadConfig32ResponseFut {
2079        fn _decode(
2080            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2081        ) -> Result<DeviceReadConfig32Result, fidl::Error> {
2082            let _response = fidl::client::decode_transaction_body::<
2083                fidl::encoding::ResultType<DeviceReadConfig32Response, i32>,
2084                fidl::encoding::DefaultFuchsiaResourceDialect,
2085                0x55357535402f7507,
2086            >(_buf?)?;
2087            Ok(_response.map(|x| x.value))
2088        }
2089        self.client.send_query_and_decode::<DeviceReadConfig32Request, DeviceReadConfig32Result>(
2090            (offset,),
2091            0x55357535402f7507,
2092            fidl::encoding::DynamicFlags::empty(),
2093            _decode,
2094        )
2095    }
2096
2097    type WriteConfig8ResponseFut = fidl::client::QueryResponseFut<
2098        DeviceWriteConfig8Result,
2099        fidl::encoding::DefaultFuchsiaResourceDialect,
2100    >;
2101    fn r#write_config8(&self, mut offset: u16, mut value: u8) -> Self::WriteConfig8ResponseFut {
2102        fn _decode(
2103            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2104        ) -> Result<DeviceWriteConfig8Result, fidl::Error> {
2105            let _response = fidl::client::decode_transaction_body::<
2106                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2107                fidl::encoding::DefaultFuchsiaResourceDialect,
2108                0x49a0719e1433cff,
2109            >(_buf?)?;
2110            Ok(_response.map(|x| x))
2111        }
2112        self.client.send_query_and_decode::<DeviceWriteConfig8Request, DeviceWriteConfig8Result>(
2113            (offset, value),
2114            0x49a0719e1433cff,
2115            fidl::encoding::DynamicFlags::empty(),
2116            _decode,
2117        )
2118    }
2119
2120    type WriteConfig16ResponseFut = fidl::client::QueryResponseFut<
2121        DeviceWriteConfig16Result,
2122        fidl::encoding::DefaultFuchsiaResourceDialect,
2123    >;
2124    fn r#write_config16(&self, mut offset: u16, mut value: u16) -> Self::WriteConfig16ResponseFut {
2125        fn _decode(
2126            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2127        ) -> Result<DeviceWriteConfig16Result, fidl::Error> {
2128            let _response = fidl::client::decode_transaction_body::<
2129                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2130                fidl::encoding::DefaultFuchsiaResourceDialect,
2131                0x3e30bf13f1c07eff,
2132            >(_buf?)?;
2133            Ok(_response.map(|x| x))
2134        }
2135        self.client.send_query_and_decode::<DeviceWriteConfig16Request, DeviceWriteConfig16Result>(
2136            (offset, value),
2137            0x3e30bf13f1c07eff,
2138            fidl::encoding::DynamicFlags::empty(),
2139            _decode,
2140        )
2141    }
2142
2143    type WriteConfig32ResponseFut = fidl::client::QueryResponseFut<
2144        DeviceWriteConfig32Result,
2145        fidl::encoding::DefaultFuchsiaResourceDialect,
2146    >;
2147    fn r#write_config32(&self, mut offset: u16, mut value: u32) -> Self::WriteConfig32ResponseFut {
2148        fn _decode(
2149            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2150        ) -> Result<DeviceWriteConfig32Result, fidl::Error> {
2151            let _response = fidl::client::decode_transaction_body::<
2152                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2153                fidl::encoding::DefaultFuchsiaResourceDialect,
2154                0x161584e5199b388,
2155            >(_buf?)?;
2156            Ok(_response.map(|x| x))
2157        }
2158        self.client.send_query_and_decode::<DeviceWriteConfig32Request, DeviceWriteConfig32Result>(
2159            (offset, value),
2160            0x161584e5199b388,
2161            fidl::encoding::DynamicFlags::empty(),
2162            _decode,
2163        )
2164    }
2165
2166    type GetCapabilitiesResponseFut =
2167        fidl::client::QueryResponseFut<Vec<u8>, fidl::encoding::DefaultFuchsiaResourceDialect>;
2168    fn r#get_capabilities(&self, mut id: CapabilityId) -> Self::GetCapabilitiesResponseFut {
2169        fn _decode(
2170            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2171        ) -> Result<Vec<u8>, fidl::Error> {
2172            let _response = fidl::client::decode_transaction_body::<
2173                DeviceGetCapabilitiesResponse,
2174                fidl::encoding::DefaultFuchsiaResourceDialect,
2175                0x3a050fde46f3ba0f,
2176            >(_buf?)?;
2177            Ok(_response.offsets)
2178        }
2179        self.client.send_query_and_decode::<DeviceGetCapabilitiesRequest, Vec<u8>>(
2180            (id,),
2181            0x3a050fde46f3ba0f,
2182            fidl::encoding::DynamicFlags::empty(),
2183            _decode,
2184        )
2185    }
2186
2187    type GetExtendedCapabilitiesResponseFut =
2188        fidl::client::QueryResponseFut<Vec<u16>, fidl::encoding::DefaultFuchsiaResourceDialect>;
2189    fn r#get_extended_capabilities(
2190        &self,
2191        mut id: ExtendedCapabilityId,
2192    ) -> Self::GetExtendedCapabilitiesResponseFut {
2193        fn _decode(
2194            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2195        ) -> Result<Vec<u16>, fidl::Error> {
2196            let _response = fidl::client::decode_transaction_body::<
2197                DeviceGetExtendedCapabilitiesResponse,
2198                fidl::encoding::DefaultFuchsiaResourceDialect,
2199                0xb8573efcaae0c39,
2200            >(_buf?)?;
2201            Ok(_response.offsets)
2202        }
2203        self.client.send_query_and_decode::<DeviceGetExtendedCapabilitiesRequest, Vec<u16>>(
2204            (id,),
2205            0xb8573efcaae0c39,
2206            fidl::encoding::DynamicFlags::empty(),
2207            _decode,
2208        )
2209    }
2210
2211    type GetBtiResponseFut = fidl::client::QueryResponseFut<
2212        DeviceGetBtiResult,
2213        fidl::encoding::DefaultFuchsiaResourceDialect,
2214    >;
2215    fn r#get_bti(&self, mut index: u32) -> Self::GetBtiResponseFut {
2216        fn _decode(
2217            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2218        ) -> Result<DeviceGetBtiResult, fidl::Error> {
2219            let _response = fidl::client::decode_transaction_body::<
2220                fidl::encoding::ResultType<DeviceGetBtiResponse, i32>,
2221                fidl::encoding::DefaultFuchsiaResourceDialect,
2222                0x5e4fe9efb12d9ee3,
2223            >(_buf?)?;
2224            Ok(_response.map(|x| x.bti))
2225        }
2226        self.client.send_query_and_decode::<DeviceGetBtiRequest, DeviceGetBtiResult>(
2227            (index,),
2228            0x5e4fe9efb12d9ee3,
2229            fidl::encoding::DynamicFlags::empty(),
2230            _decode,
2231        )
2232    }
2233}
2234
2235pub struct DeviceEventStream {
2236    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2237}
2238
2239impl std::marker::Unpin for DeviceEventStream {}
2240
2241impl futures::stream::FusedStream for DeviceEventStream {
2242    fn is_terminated(&self) -> bool {
2243        self.event_receiver.is_terminated()
2244    }
2245}
2246
2247impl futures::Stream for DeviceEventStream {
2248    type Item = Result<DeviceEvent, fidl::Error>;
2249
2250    fn poll_next(
2251        mut self: std::pin::Pin<&mut Self>,
2252        cx: &mut std::task::Context<'_>,
2253    ) -> std::task::Poll<Option<Self::Item>> {
2254        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2255            &mut self.event_receiver,
2256            cx
2257        )?) {
2258            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
2259            None => std::task::Poll::Ready(None),
2260        }
2261    }
2262}
2263
2264#[derive(Debug)]
2265pub enum DeviceEvent {}
2266
2267impl DeviceEvent {
2268    /// Decodes a message buffer as a [`DeviceEvent`].
2269    fn decode(
2270        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2271    ) -> Result<DeviceEvent, fidl::Error> {
2272        let (bytes, _handles) = buf.split_mut();
2273        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2274        debug_assert_eq!(tx_header.tx_id, 0);
2275        match tx_header.ordinal {
2276            _ => Err(fidl::Error::UnknownOrdinal {
2277                ordinal: tx_header.ordinal,
2278                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2279            }),
2280        }
2281    }
2282}
2283
2284/// A Stream of incoming requests for fuchsia.hardware.pci/Device.
2285pub struct DeviceRequestStream {
2286    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2287    is_terminated: bool,
2288}
2289
2290impl std::marker::Unpin for DeviceRequestStream {}
2291
2292impl futures::stream::FusedStream for DeviceRequestStream {
2293    fn is_terminated(&self) -> bool {
2294        self.is_terminated
2295    }
2296}
2297
2298impl fidl::endpoints::RequestStream for DeviceRequestStream {
2299    type Protocol = DeviceMarker;
2300    type ControlHandle = DeviceControlHandle;
2301
2302    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2303        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2304    }
2305
2306    fn control_handle(&self) -> Self::ControlHandle {
2307        DeviceControlHandle { inner: self.inner.clone() }
2308    }
2309
2310    fn into_inner(
2311        self,
2312    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2313    {
2314        (self.inner, self.is_terminated)
2315    }
2316
2317    fn from_inner(
2318        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2319        is_terminated: bool,
2320    ) -> Self {
2321        Self { inner, is_terminated }
2322    }
2323}
2324
2325impl futures::Stream for DeviceRequestStream {
2326    type Item = Result<DeviceRequest, fidl::Error>;
2327
2328    fn poll_next(
2329        mut self: std::pin::Pin<&mut Self>,
2330        cx: &mut std::task::Context<'_>,
2331    ) -> std::task::Poll<Option<Self::Item>> {
2332        let this = &mut *self;
2333        if this.inner.check_shutdown(cx) {
2334            this.is_terminated = true;
2335            return std::task::Poll::Ready(None);
2336        }
2337        if this.is_terminated {
2338            panic!("polled DeviceRequestStream after completion");
2339        }
2340        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2341            |bytes, handles| {
2342                match this.inner.channel().read_etc(cx, bytes, handles) {
2343                    std::task::Poll::Ready(Ok(())) => {}
2344                    std::task::Poll::Pending => return std::task::Poll::Pending,
2345                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2346                        this.is_terminated = true;
2347                        return std::task::Poll::Ready(None);
2348                    }
2349                    std::task::Poll::Ready(Err(e)) => {
2350                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2351                            e.into(),
2352                        ))));
2353                    }
2354                }
2355
2356                // A message has been received from the channel
2357                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2358
2359                std::task::Poll::Ready(Some(match header.ordinal {
2360                    0x5599d144d4329916 => {
2361                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2362                        let mut req = fidl::new_empty!(
2363                            fidl::encoding::EmptyPayload,
2364                            fidl::encoding::DefaultFuchsiaResourceDialect
2365                        );
2366                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2367                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2368                        Ok(DeviceRequest::GetDeviceInfo {
2369                            responder: DeviceGetDeviceInfoResponder {
2370                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2371                                tx_id: header.tx_id,
2372                            },
2373                        })
2374                    }
2375                    0x6b2683f6fbbff679 => {
2376                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2377                        let mut req = fidl::new_empty!(
2378                            DeviceGetBarRequest,
2379                            fidl::encoding::DefaultFuchsiaResourceDialect
2380                        );
2381                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetBarRequest>(&header, _body_bytes, handles, &mut req)?;
2382                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2383                        Ok(DeviceRequest::GetBar {
2384                            bar_id: req.bar_id,
2385
2386                            responder: DeviceGetBarResponder {
2387                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2388                                tx_id: header.tx_id,
2389                            },
2390                        })
2391                    }
2392                    0x3421e9e030211003 => {
2393                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2394                        let mut req = fidl::new_empty!(
2395                            DeviceSetBusMasteringRequest,
2396                            fidl::encoding::DefaultFuchsiaResourceDialect
2397                        );
2398                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetBusMasteringRequest>(&header, _body_bytes, handles, &mut req)?;
2399                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2400                        Ok(DeviceRequest::SetBusMastering {
2401                            enabled: req.enabled,
2402
2403                            responder: DeviceSetBusMasteringResponder {
2404                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2405                                tx_id: header.tx_id,
2406                            },
2407                        })
2408                    }
2409                    0x3c5b7579bb6f8b9f => {
2410                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2411                        let mut req = fidl::new_empty!(
2412                            fidl::encoding::EmptyPayload,
2413                            fidl::encoding::DefaultFuchsiaResourceDialect
2414                        );
2415                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2416                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2417                        Ok(DeviceRequest::ResetDevice {
2418                            responder: DeviceResetDeviceResponder {
2419                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2420                                tx_id: header.tx_id,
2421                            },
2422                        })
2423                    }
2424                    0x70742f64692d5a6b => {
2425                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2426                        let mut req = fidl::new_empty!(
2427                            fidl::encoding::EmptyPayload,
2428                            fidl::encoding::DefaultFuchsiaResourceDialect
2429                        );
2430                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2431                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2432                        Ok(DeviceRequest::AckInterrupt {
2433                            responder: DeviceAckInterruptResponder {
2434                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2435                                tx_id: header.tx_id,
2436                            },
2437                        })
2438                    }
2439                    0x25eeff9d34a1fa13 => {
2440                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2441                        let mut req = fidl::new_empty!(
2442                            DeviceMapInterruptRequest,
2443                            fidl::encoding::DefaultFuchsiaResourceDialect
2444                        );
2445                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceMapInterruptRequest>(&header, _body_bytes, handles, &mut req)?;
2446                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2447                        Ok(DeviceRequest::MapInterrupt {
2448                            which_irq: req.which_irq,
2449
2450                            responder: DeviceMapInterruptResponder {
2451                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2452                                tx_id: header.tx_id,
2453                            },
2454                        })
2455                    }
2456                    0x93f4cd8f79e9f4a => {
2457                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2458                        let mut req = fidl::new_empty!(
2459                            fidl::encoding::EmptyPayload,
2460                            fidl::encoding::DefaultFuchsiaResourceDialect
2461                        );
2462                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2463                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2464                        Ok(DeviceRequest::GetInterruptModes {
2465                            responder: DeviceGetInterruptModesResponder {
2466                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2467                                tx_id: header.tx_id,
2468                            },
2469                        })
2470                    }
2471                    0x85bebad3eb24866 => {
2472                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2473                        let mut req = fidl::new_empty!(
2474                            DeviceSetInterruptModeRequest,
2475                            fidl::encoding::DefaultFuchsiaResourceDialect
2476                        );
2477                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetInterruptModeRequest>(&header, _body_bytes, handles, &mut req)?;
2478                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2479                        Ok(DeviceRequest::SetInterruptMode {
2480                            mode: req.mode,
2481                            requested_irq_count: req.requested_irq_count,
2482
2483                            responder: DeviceSetInterruptModeResponder {
2484                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2485                                tx_id: header.tx_id,
2486                            },
2487                        })
2488                    }
2489                    0x28f9eb9e6dadda1c => {
2490                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2491                        let mut req = fidl::new_empty!(
2492                            DeviceReadConfig8Request,
2493                            fidl::encoding::DefaultFuchsiaResourceDialect
2494                        );
2495                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceReadConfig8Request>(&header, _body_bytes, handles, &mut req)?;
2496                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2497                        Ok(DeviceRequest::ReadConfig8 {
2498                            offset: req.offset,
2499
2500                            responder: DeviceReadConfig8Responder {
2501                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2502                                tx_id: header.tx_id,
2503                            },
2504                        })
2505                    }
2506                    0x3bcda6171a3270bb => {
2507                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2508                        let mut req = fidl::new_empty!(
2509                            DeviceReadConfig16Request,
2510                            fidl::encoding::DefaultFuchsiaResourceDialect
2511                        );
2512                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceReadConfig16Request>(&header, _body_bytes, handles, &mut req)?;
2513                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2514                        Ok(DeviceRequest::ReadConfig16 {
2515                            offset: req.offset,
2516
2517                            responder: DeviceReadConfig16Responder {
2518                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2519                                tx_id: header.tx_id,
2520                            },
2521                        })
2522                    }
2523                    0x55357535402f7507 => {
2524                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2525                        let mut req = fidl::new_empty!(
2526                            DeviceReadConfig32Request,
2527                            fidl::encoding::DefaultFuchsiaResourceDialect
2528                        );
2529                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceReadConfig32Request>(&header, _body_bytes, handles, &mut req)?;
2530                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2531                        Ok(DeviceRequest::ReadConfig32 {
2532                            offset: req.offset,
2533
2534                            responder: DeviceReadConfig32Responder {
2535                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2536                                tx_id: header.tx_id,
2537                            },
2538                        })
2539                    }
2540                    0x49a0719e1433cff => {
2541                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2542                        let mut req = fidl::new_empty!(
2543                            DeviceWriteConfig8Request,
2544                            fidl::encoding::DefaultFuchsiaResourceDialect
2545                        );
2546                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceWriteConfig8Request>(&header, _body_bytes, handles, &mut req)?;
2547                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2548                        Ok(DeviceRequest::WriteConfig8 {
2549                            offset: req.offset,
2550                            value: req.value,
2551
2552                            responder: DeviceWriteConfig8Responder {
2553                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2554                                tx_id: header.tx_id,
2555                            },
2556                        })
2557                    }
2558                    0x3e30bf13f1c07eff => {
2559                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2560                        let mut req = fidl::new_empty!(
2561                            DeviceWriteConfig16Request,
2562                            fidl::encoding::DefaultFuchsiaResourceDialect
2563                        );
2564                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceWriteConfig16Request>(&header, _body_bytes, handles, &mut req)?;
2565                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2566                        Ok(DeviceRequest::WriteConfig16 {
2567                            offset: req.offset,
2568                            value: req.value,
2569
2570                            responder: DeviceWriteConfig16Responder {
2571                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2572                                tx_id: header.tx_id,
2573                            },
2574                        })
2575                    }
2576                    0x161584e5199b388 => {
2577                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2578                        let mut req = fidl::new_empty!(
2579                            DeviceWriteConfig32Request,
2580                            fidl::encoding::DefaultFuchsiaResourceDialect
2581                        );
2582                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceWriteConfig32Request>(&header, _body_bytes, handles, &mut req)?;
2583                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2584                        Ok(DeviceRequest::WriteConfig32 {
2585                            offset: req.offset,
2586                            value: req.value,
2587
2588                            responder: DeviceWriteConfig32Responder {
2589                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2590                                tx_id: header.tx_id,
2591                            },
2592                        })
2593                    }
2594                    0x3a050fde46f3ba0f => {
2595                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2596                        let mut req = fidl::new_empty!(
2597                            DeviceGetCapabilitiesRequest,
2598                            fidl::encoding::DefaultFuchsiaResourceDialect
2599                        );
2600                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetCapabilitiesRequest>(&header, _body_bytes, handles, &mut req)?;
2601                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2602                        Ok(DeviceRequest::GetCapabilities {
2603                            id: req.id,
2604
2605                            responder: DeviceGetCapabilitiesResponder {
2606                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2607                                tx_id: header.tx_id,
2608                            },
2609                        })
2610                    }
2611                    0xb8573efcaae0c39 => {
2612                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2613                        let mut req = fidl::new_empty!(
2614                            DeviceGetExtendedCapabilitiesRequest,
2615                            fidl::encoding::DefaultFuchsiaResourceDialect
2616                        );
2617                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetExtendedCapabilitiesRequest>(&header, _body_bytes, handles, &mut req)?;
2618                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2619                        Ok(DeviceRequest::GetExtendedCapabilities {
2620                            id: req.id,
2621
2622                            responder: DeviceGetExtendedCapabilitiesResponder {
2623                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2624                                tx_id: header.tx_id,
2625                            },
2626                        })
2627                    }
2628                    0x5e4fe9efb12d9ee3 => {
2629                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2630                        let mut req = fidl::new_empty!(
2631                            DeviceGetBtiRequest,
2632                            fidl::encoding::DefaultFuchsiaResourceDialect
2633                        );
2634                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetBtiRequest>(&header, _body_bytes, handles, &mut req)?;
2635                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
2636                        Ok(DeviceRequest::GetBti {
2637                            index: req.index,
2638
2639                            responder: DeviceGetBtiResponder {
2640                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2641                                tx_id: header.tx_id,
2642                            },
2643                        })
2644                    }
2645                    _ => Err(fidl::Error::UnknownOrdinal {
2646                        ordinal: header.ordinal,
2647                        protocol_name:
2648                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2649                    }),
2650                }))
2651            },
2652        )
2653    }
2654}
2655
2656#[derive(Debug)]
2657pub enum DeviceRequest {
2658    /// Returns a structure containing device information from the configuration header.
2659    GetDeviceInfo { responder: DeviceGetDeviceInfoResponder },
2660    /// Retrieves information for a specified Base Address Register (BAR). If the BAR contains
2661    /// MSI-X capability tables then an attempt will be made to return an MMIO region excluding
2662    /// those tables, if possible. Otherwise, an error will be returned.
2663    ///
2664    /// Parameters:
2665    /// |bar_id|: The id of the BAR being requested. Valid range is [0, 6).
2666    ///
2667    /// Errors:
2668    /// |ZX_ERR_ACCESS_DENIED|: The specified BAR does not have a driver-accessible region due to
2669    /// the presence of MSI-X tables. To use MSI-X see the |SetInterruptMode| method.
2670    /// |ZX_ERR_INTERNAL|: A bus driver error has occurred.
2671    /// |ZX_ERR_INVALID_ARGS|: The |bar_id| specified is outside of the acceptable range.
2672    /// |ZX_ERR_NOT_FOUND|: The specified |bar_id| does not exist for this device.
2673    GetBar { bar_id: u32, responder: DeviceGetBarResponder },
2674    /// Enables or disables the bus mastering capability for the device.
2675    ///
2676    /// Parameters:
2677    /// |enable|: true to enable bus mastering, false to disable.
2678    ///
2679    /// Errors:
2680    /// |ZX_ERR_BAD_STATE|: Method was called while the device is disabled.
2681    SetBusMastering { enabled: bool, responder: DeviceSetBusMasteringResponder },
2682    /// Initiates a function level reset for the device. This is a synchronous
2683    /// operation that will not return ontil the reset is complete. Interrupt
2684    /// operation of the device must be disabled before initiating a reset.
2685    ///
2686    /// Errors:
2687    /// |ZX_ERR_BAD_STATE|: Interrupts were not disabled before calling |ResetDevice|.
2688    /// |ZX_ERR_NOT_SUPPORTED|: The device does not support reset.
2689    /// |ZX_ERR_TIMED_OUT|: The device did not complete its reset in the
2690    /// expected amount of time and is presumed to no longer be operating
2691    /// properly.
2692    ResetDevice { responder: DeviceResetDeviceResponder },
2693    /// Alerts the bus driver to deassert the raised legacy interrupt so that it
2694    /// may be waited on again. Only used if |SetInterruptMode| was called with
2695    /// |PCI_INTERRUPT_MODE_LEGACY|.
2696    ///
2697    /// Errors:
2698    /// |ZX_ERR_BAD_STATE|: device is not configured to use the Legacy interrupt mode.
2699    AckInterrupt { responder: DeviceAckInterruptResponder },
2700    /// Maps a device's interrupt to a zx:interrupt. The device's interrupt mode
2701    /// must already be configured with |SetInterruptMode|, and |which_irq| must
2702    /// be >= to the number of interrupts reported for that interrupt mode by
2703    /// |GetInterruptModes|. A Legacy interrupt may be mapped multiple times,
2704    /// but the handles will point to the same interrupt object. MSI & MSI-X
2705    /// interrupts may only have one outstanding mapping at a time per
2706    /// interrupt. Outstanding MSI & MSI-X interrupt handles must be closed
2707    /// before attempting to change the interrupt mode in a subsequent call to
2708    /// |SetInterruptMode|.
2709    ///
2710    /// Parameters:
2711    /// |which_irq|: The id of the interrupt to map.
2712    ///
2713    /// Errors:
2714    /// |ZX_ERR_ALREADY_BOUND|: The interrupt specified by |which_irq| is
2715    /// already mapped to a valid handle.
2716    /// |ZX_ERR_BAD_STATE|: interrupts are currently disabled for the device.
2717    /// |ZX_ERR_INVALID_ARGS|: |which_irq| is invalid for the mode.
2718    MapInterrupt { which_irq: u32, responder: DeviceMapInterruptResponder },
2719    /// Returns the supported interrupt modes for a device.
2720    GetInterruptModes { responder: DeviceGetInterruptModesResponder },
2721    /// Configures the interrupt mode for a device. When changing from one
2722    /// interrupt mode to another the driver must ensure existing interrupt
2723    /// handles are closed beforehand.
2724    ///
2725    /// Parameters:
2726    /// |mode|: The |InterruptMode| to request from the bus driver.
2727    /// |requested_irq_count|: The number of interrupts requested.
2728    ///
2729    /// Errors:
2730    /// |ZX_ERR_BAD_STATE|: The driver attempted to change interrupt mode while
2731    /// existing handles to mapped MSIs exist.
2732    /// |ZX_ERR_INVALID_ARGS|: |requested_irq_count| is 0.
2733    /// |ZX_ERR_NOT_SUPPORTED|: The provided |mode| is not supported, or invalid.
2734    SetInterruptMode {
2735        mode: InterruptMode,
2736        requested_irq_count: u32,
2737        responder: DeviceSetInterruptModeResponder,
2738    },
2739    /// Reads a byte from the device's configuration space. |Offset| must be
2740    /// within [0x0, 0xFF] if PCI, or [0x0, 0xFFF) if PCIe. In most cases a
2741    /// device will be PCIe.
2742    ///
2743    /// Parameters:
2744    /// |offset|: The offset into the device's configuration space to read.
2745    ///
2746    /// Errors:
2747    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
2748    ReadConfig8 { offset: u16, responder: DeviceReadConfig8Responder },
2749    /// Reads two bytes from the device's configuration space. |Offset| must be
2750    /// within [0x0, 0xFE] if PCI, or [0x0, 0xFFE] if PCIe. In most cases a
2751    /// device will be PCIe.
2752    ///
2753    /// Parameters:
2754    /// |offset|: The offset into the device's configuration space to read.
2755    ///
2756    /// Errors:
2757    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
2758    ReadConfig16 { offset: u16, responder: DeviceReadConfig16Responder },
2759    /// Reads four bytes from the device's configuration space. |Offset| must be
2760    /// within [0x0, 0xFC] if PCI, or [0x0, 0xFFC] if PCIe. In most cases a
2761    /// device will be PCIe.
2762    ///
2763    /// Parameters:
2764    /// |offset|: The offset into the device's configuration space to read.
2765    ///
2766    /// Errors:
2767    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
2768    ReadConfig32 { offset: u16, responder: DeviceReadConfig32Responder },
2769    /// Writes a byte to the device's configuration space. The acceptable
2770    /// ranges of |offset| for writes are [0x40, 0xFF] if PCI, or [0x40,
2771    /// 0xFFF] if PCIe. For most purposes a device will be PCIe.
2772    ///
2773    ///
2774    /// Parameters
2775    /// |offset|: The offset into the device's configuration space to read.
2776    /// |value|: The value to write.
2777    ///
2778    /// Errors:
2779    /// |ZX_ERR_ACCESS_DENIED|: |offset| is within the device's configuration header.
2780    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
2781    WriteConfig8 { offset: u16, value: u8, responder: DeviceWriteConfig8Responder },
2782    /// Writes two bytes to the device's configuration space. The acceptable
2783    /// ranges of |offset| for writes are [0x40, 0xFE] if PCI, or [0x40,
2784    /// 0xFFE] if PCIe. For most purposes a device will be PCIe.
2785    ///
2786    ///
2787    /// Parameters
2788    /// |offset|: The offset into the device's configuration space to read.
2789    /// |value|: The value to write.
2790    ///
2791    /// Errors:
2792    /// |ZX_ERR_ACCESS_DENIED|: |offset| is within the device's configuration header.
2793    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
2794    WriteConfig16 { offset: u16, value: u16, responder: DeviceWriteConfig16Responder },
2795    /// Writes four bytes to the device's configuration space. The acceptable
2796    /// ranges of |offset| for writes are [0x40, 0xFC] if PCI, or [0x40,
2797    /// 0xFFC] if PCIe. For most purposes a device will be PCIe.
2798    ///
2799    ///
2800    /// Parameters
2801    /// |offset|: The offset into the device's configuration space to read.
2802    /// |value|: The value to write.
2803    ///
2804    /// Errors:
2805    /// |ZX_ERR_ACCESS_DENIED|: |offset| is within the device's configuration header.
2806    /// |ZX_ERR_OUT_OF_RANGE|: |offset| is an invalid address.
2807    WriteConfig32 { offset: u16, value: u32, responder: DeviceWriteConfig32Responder },
2808    /// Returns a vector of offsets in configuration space corresponding to
2809    /// capabilities matching the provided capability |id|.  If no corresponding
2810    /// match is found then the vector will be empty.
2811    ///
2812    /// Parameters:
2813    /// |id|: the capability id to search for.
2814    GetCapabilities { id: CapabilityId, responder: DeviceGetCapabilitiesResponder },
2815    /// Returns a vector of offsets in configuration space corresponding to
2816    /// extended capabilities matching the provided extended capability |id|.
2817    /// If no corresponding match is found then the vector will be empty.
2818    ///
2819    /// Parameters:
2820    /// |id|: the capability id to search for
2821    GetExtendedCapabilities {
2822        id: ExtendedCapabilityId,
2823        responder: DeviceGetExtendedCapabilitiesResponder,
2824    },
2825    /// Returns the Bus Transaction Intiator (BTI) at a given index for the device.
2826    ///
2827    /// Parameters:
2828    /// |index|: the BTI to request.
2829    ///
2830    /// Errors:
2831    /// |ZX_ERR_OUT_OF_RANGE|: |index| was not 0.
2832    GetBti { index: u32, responder: DeviceGetBtiResponder },
2833}
2834
2835impl DeviceRequest {
2836    #[allow(irrefutable_let_patterns)]
2837    pub fn into_get_device_info(self) -> Option<(DeviceGetDeviceInfoResponder)> {
2838        if let DeviceRequest::GetDeviceInfo { responder } = self { Some((responder)) } else { None }
2839    }
2840
2841    #[allow(irrefutable_let_patterns)]
2842    pub fn into_get_bar(self) -> Option<(u32, DeviceGetBarResponder)> {
2843        if let DeviceRequest::GetBar { bar_id, responder } = self {
2844            Some((bar_id, responder))
2845        } else {
2846            None
2847        }
2848    }
2849
2850    #[allow(irrefutable_let_patterns)]
2851    pub fn into_set_bus_mastering(self) -> Option<(bool, DeviceSetBusMasteringResponder)> {
2852        if let DeviceRequest::SetBusMastering { enabled, responder } = self {
2853            Some((enabled, responder))
2854        } else {
2855            None
2856        }
2857    }
2858
2859    #[allow(irrefutable_let_patterns)]
2860    pub fn into_reset_device(self) -> Option<(DeviceResetDeviceResponder)> {
2861        if let DeviceRequest::ResetDevice { responder } = self { Some((responder)) } else { None }
2862    }
2863
2864    #[allow(irrefutable_let_patterns)]
2865    pub fn into_ack_interrupt(self) -> Option<(DeviceAckInterruptResponder)> {
2866        if let DeviceRequest::AckInterrupt { responder } = self { Some((responder)) } else { None }
2867    }
2868
2869    #[allow(irrefutable_let_patterns)]
2870    pub fn into_map_interrupt(self) -> Option<(u32, DeviceMapInterruptResponder)> {
2871        if let DeviceRequest::MapInterrupt { which_irq, responder } = self {
2872            Some((which_irq, responder))
2873        } else {
2874            None
2875        }
2876    }
2877
2878    #[allow(irrefutable_let_patterns)]
2879    pub fn into_get_interrupt_modes(self) -> Option<(DeviceGetInterruptModesResponder)> {
2880        if let DeviceRequest::GetInterruptModes { responder } = self {
2881            Some((responder))
2882        } else {
2883            None
2884        }
2885    }
2886
2887    #[allow(irrefutable_let_patterns)]
2888    pub fn into_set_interrupt_mode(
2889        self,
2890    ) -> Option<(InterruptMode, u32, DeviceSetInterruptModeResponder)> {
2891        if let DeviceRequest::SetInterruptMode { mode, requested_irq_count, responder } = self {
2892            Some((mode, requested_irq_count, responder))
2893        } else {
2894            None
2895        }
2896    }
2897
2898    #[allow(irrefutable_let_patterns)]
2899    pub fn into_read_config8(self) -> Option<(u16, DeviceReadConfig8Responder)> {
2900        if let DeviceRequest::ReadConfig8 { offset, responder } = self {
2901            Some((offset, responder))
2902        } else {
2903            None
2904        }
2905    }
2906
2907    #[allow(irrefutable_let_patterns)]
2908    pub fn into_read_config16(self) -> Option<(u16, DeviceReadConfig16Responder)> {
2909        if let DeviceRequest::ReadConfig16 { offset, responder } = self {
2910            Some((offset, responder))
2911        } else {
2912            None
2913        }
2914    }
2915
2916    #[allow(irrefutable_let_patterns)]
2917    pub fn into_read_config32(self) -> Option<(u16, DeviceReadConfig32Responder)> {
2918        if let DeviceRequest::ReadConfig32 { offset, responder } = self {
2919            Some((offset, responder))
2920        } else {
2921            None
2922        }
2923    }
2924
2925    #[allow(irrefutable_let_patterns)]
2926    pub fn into_write_config8(self) -> Option<(u16, u8, DeviceWriteConfig8Responder)> {
2927        if let DeviceRequest::WriteConfig8 { offset, value, responder } = self {
2928            Some((offset, value, responder))
2929        } else {
2930            None
2931        }
2932    }
2933
2934    #[allow(irrefutable_let_patterns)]
2935    pub fn into_write_config16(self) -> Option<(u16, u16, DeviceWriteConfig16Responder)> {
2936        if let DeviceRequest::WriteConfig16 { offset, value, responder } = self {
2937            Some((offset, value, responder))
2938        } else {
2939            None
2940        }
2941    }
2942
2943    #[allow(irrefutable_let_patterns)]
2944    pub fn into_write_config32(self) -> Option<(u16, u32, DeviceWriteConfig32Responder)> {
2945        if let DeviceRequest::WriteConfig32 { offset, value, responder } = self {
2946            Some((offset, value, responder))
2947        } else {
2948            None
2949        }
2950    }
2951
2952    #[allow(irrefutable_let_patterns)]
2953    pub fn into_get_capabilities(self) -> Option<(CapabilityId, DeviceGetCapabilitiesResponder)> {
2954        if let DeviceRequest::GetCapabilities { id, responder } = self {
2955            Some((id, responder))
2956        } else {
2957            None
2958        }
2959    }
2960
2961    #[allow(irrefutable_let_patterns)]
2962    pub fn into_get_extended_capabilities(
2963        self,
2964    ) -> Option<(ExtendedCapabilityId, DeviceGetExtendedCapabilitiesResponder)> {
2965        if let DeviceRequest::GetExtendedCapabilities { id, responder } = self {
2966            Some((id, responder))
2967        } else {
2968            None
2969        }
2970    }
2971
2972    #[allow(irrefutable_let_patterns)]
2973    pub fn into_get_bti(self) -> Option<(u32, DeviceGetBtiResponder)> {
2974        if let DeviceRequest::GetBti { index, responder } = self {
2975            Some((index, responder))
2976        } else {
2977            None
2978        }
2979    }
2980
2981    /// Name of the method defined in FIDL
2982    pub fn method_name(&self) -> &'static str {
2983        match *self {
2984            DeviceRequest::GetDeviceInfo { .. } => "get_device_info",
2985            DeviceRequest::GetBar { .. } => "get_bar",
2986            DeviceRequest::SetBusMastering { .. } => "set_bus_mastering",
2987            DeviceRequest::ResetDevice { .. } => "reset_device",
2988            DeviceRequest::AckInterrupt { .. } => "ack_interrupt",
2989            DeviceRequest::MapInterrupt { .. } => "map_interrupt",
2990            DeviceRequest::GetInterruptModes { .. } => "get_interrupt_modes",
2991            DeviceRequest::SetInterruptMode { .. } => "set_interrupt_mode",
2992            DeviceRequest::ReadConfig8 { .. } => "read_config8",
2993            DeviceRequest::ReadConfig16 { .. } => "read_config16",
2994            DeviceRequest::ReadConfig32 { .. } => "read_config32",
2995            DeviceRequest::WriteConfig8 { .. } => "write_config8",
2996            DeviceRequest::WriteConfig16 { .. } => "write_config16",
2997            DeviceRequest::WriteConfig32 { .. } => "write_config32",
2998            DeviceRequest::GetCapabilities { .. } => "get_capabilities",
2999            DeviceRequest::GetExtendedCapabilities { .. } => "get_extended_capabilities",
3000            DeviceRequest::GetBti { .. } => "get_bti",
3001        }
3002    }
3003}
3004
3005#[derive(Debug, Clone)]
3006pub struct DeviceControlHandle {
3007    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3008}
3009
3010impl fidl::endpoints::ControlHandle for DeviceControlHandle {
3011    fn shutdown(&self) {
3012        self.inner.shutdown()
3013    }
3014
3015    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3016        self.inner.shutdown_with_epitaph(status)
3017    }
3018
3019    fn is_closed(&self) -> bool {
3020        self.inner.channel().is_closed()
3021    }
3022    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3023        self.inner.channel().on_closed()
3024    }
3025
3026    #[cfg(target_os = "fuchsia")]
3027    fn signal_peer(
3028        &self,
3029        clear_mask: zx::Signals,
3030        set_mask: zx::Signals,
3031    ) -> Result<(), zx_status::Status> {
3032        use fidl::Peered;
3033        self.inner.channel().signal_peer(clear_mask, set_mask)
3034    }
3035}
3036
3037impl DeviceControlHandle {}
3038
3039#[must_use = "FIDL methods require a response to be sent"]
3040#[derive(Debug)]
3041pub struct DeviceGetDeviceInfoResponder {
3042    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3043    tx_id: u32,
3044}
3045
3046/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3047/// if the responder is dropped without sending a response, so that the client
3048/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3049impl std::ops::Drop for DeviceGetDeviceInfoResponder {
3050    fn drop(&mut self) {
3051        self.control_handle.shutdown();
3052        // Safety: drops once, never accessed again
3053        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3054    }
3055}
3056
3057impl fidl::endpoints::Responder for DeviceGetDeviceInfoResponder {
3058    type ControlHandle = DeviceControlHandle;
3059
3060    fn control_handle(&self) -> &DeviceControlHandle {
3061        &self.control_handle
3062    }
3063
3064    fn drop_without_shutdown(mut self) {
3065        // Safety: drops once, never accessed again due to mem::forget
3066        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3067        // Prevent Drop from running (which would shut down the channel)
3068        std::mem::forget(self);
3069    }
3070}
3071
3072impl DeviceGetDeviceInfoResponder {
3073    /// Sends a response to the FIDL transaction.
3074    ///
3075    /// Sets the channel to shutdown if an error occurs.
3076    pub fn send(self, mut info: &DeviceInfo) -> Result<(), fidl::Error> {
3077        let _result = self.send_raw(info);
3078        if _result.is_err() {
3079            self.control_handle.shutdown();
3080        }
3081        self.drop_without_shutdown();
3082        _result
3083    }
3084
3085    /// Similar to "send" but does not shutdown the channel if an error occurs.
3086    pub fn send_no_shutdown_on_err(self, mut info: &DeviceInfo) -> Result<(), fidl::Error> {
3087        let _result = self.send_raw(info);
3088        self.drop_without_shutdown();
3089        _result
3090    }
3091
3092    fn send_raw(&self, mut info: &DeviceInfo) -> Result<(), fidl::Error> {
3093        self.control_handle.inner.send::<DeviceGetDeviceInfoResponse>(
3094            (info,),
3095            self.tx_id,
3096            0x5599d144d4329916,
3097            fidl::encoding::DynamicFlags::empty(),
3098        )
3099    }
3100}
3101
3102#[must_use = "FIDL methods require a response to be sent"]
3103#[derive(Debug)]
3104pub struct DeviceGetBarResponder {
3105    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3106    tx_id: u32,
3107}
3108
3109/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3110/// if the responder is dropped without sending a response, so that the client
3111/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3112impl std::ops::Drop for DeviceGetBarResponder {
3113    fn drop(&mut self) {
3114        self.control_handle.shutdown();
3115        // Safety: drops once, never accessed again
3116        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3117    }
3118}
3119
3120impl fidl::endpoints::Responder for DeviceGetBarResponder {
3121    type ControlHandle = DeviceControlHandle;
3122
3123    fn control_handle(&self) -> &DeviceControlHandle {
3124        &self.control_handle
3125    }
3126
3127    fn drop_without_shutdown(mut self) {
3128        // Safety: drops once, never accessed again due to mem::forget
3129        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3130        // Prevent Drop from running (which would shut down the channel)
3131        std::mem::forget(self);
3132    }
3133}
3134
3135impl DeviceGetBarResponder {
3136    /// Sends a response to the FIDL transaction.
3137    ///
3138    /// Sets the channel to shutdown if an error occurs.
3139    pub fn send(self, mut result: Result<Bar, i32>) -> Result<(), fidl::Error> {
3140        let _result = self.send_raw(result);
3141        if _result.is_err() {
3142            self.control_handle.shutdown();
3143        }
3144        self.drop_without_shutdown();
3145        _result
3146    }
3147
3148    /// Similar to "send" but does not shutdown the channel if an error occurs.
3149    pub fn send_no_shutdown_on_err(self, mut result: Result<Bar, i32>) -> Result<(), fidl::Error> {
3150        let _result = self.send_raw(result);
3151        self.drop_without_shutdown();
3152        _result
3153    }
3154
3155    fn send_raw(&self, mut result: Result<Bar, i32>) -> Result<(), fidl::Error> {
3156        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceGetBarResponse, i32>>(
3157            result.as_mut().map_err(|e| *e).map(|result| (result,)),
3158            self.tx_id,
3159            0x6b2683f6fbbff679,
3160            fidl::encoding::DynamicFlags::empty(),
3161        )
3162    }
3163}
3164
3165#[must_use = "FIDL methods require a response to be sent"]
3166#[derive(Debug)]
3167pub struct DeviceSetBusMasteringResponder {
3168    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3169    tx_id: u32,
3170}
3171
3172/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3173/// if the responder is dropped without sending a response, so that the client
3174/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3175impl std::ops::Drop for DeviceSetBusMasteringResponder {
3176    fn drop(&mut self) {
3177        self.control_handle.shutdown();
3178        // Safety: drops once, never accessed again
3179        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3180    }
3181}
3182
3183impl fidl::endpoints::Responder for DeviceSetBusMasteringResponder {
3184    type ControlHandle = DeviceControlHandle;
3185
3186    fn control_handle(&self) -> &DeviceControlHandle {
3187        &self.control_handle
3188    }
3189
3190    fn drop_without_shutdown(mut self) {
3191        // Safety: drops once, never accessed again due to mem::forget
3192        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3193        // Prevent Drop from running (which would shut down the channel)
3194        std::mem::forget(self);
3195    }
3196}
3197
3198impl DeviceSetBusMasteringResponder {
3199    /// Sends a response to the FIDL transaction.
3200    ///
3201    /// Sets the channel to shutdown if an error occurs.
3202    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3203        let _result = self.send_raw(result);
3204        if _result.is_err() {
3205            self.control_handle.shutdown();
3206        }
3207        self.drop_without_shutdown();
3208        _result
3209    }
3210
3211    /// Similar to "send" but does not shutdown the channel if an error occurs.
3212    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3213        let _result = self.send_raw(result);
3214        self.drop_without_shutdown();
3215        _result
3216    }
3217
3218    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3219        self.control_handle
3220            .inner
3221            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3222                result,
3223                self.tx_id,
3224                0x3421e9e030211003,
3225                fidl::encoding::DynamicFlags::empty(),
3226            )
3227    }
3228}
3229
3230#[must_use = "FIDL methods require a response to be sent"]
3231#[derive(Debug)]
3232pub struct DeviceResetDeviceResponder {
3233    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3234    tx_id: u32,
3235}
3236
3237/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3238/// if the responder is dropped without sending a response, so that the client
3239/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3240impl std::ops::Drop for DeviceResetDeviceResponder {
3241    fn drop(&mut self) {
3242        self.control_handle.shutdown();
3243        // Safety: drops once, never accessed again
3244        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3245    }
3246}
3247
3248impl fidl::endpoints::Responder for DeviceResetDeviceResponder {
3249    type ControlHandle = DeviceControlHandle;
3250
3251    fn control_handle(&self) -> &DeviceControlHandle {
3252        &self.control_handle
3253    }
3254
3255    fn drop_without_shutdown(mut self) {
3256        // Safety: drops once, never accessed again due to mem::forget
3257        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3258        // Prevent Drop from running (which would shut down the channel)
3259        std::mem::forget(self);
3260    }
3261}
3262
3263impl DeviceResetDeviceResponder {
3264    /// Sends a response to the FIDL transaction.
3265    ///
3266    /// Sets the channel to shutdown if an error occurs.
3267    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3268        let _result = self.send_raw(result);
3269        if _result.is_err() {
3270            self.control_handle.shutdown();
3271        }
3272        self.drop_without_shutdown();
3273        _result
3274    }
3275
3276    /// Similar to "send" but does not shutdown the channel if an error occurs.
3277    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3278        let _result = self.send_raw(result);
3279        self.drop_without_shutdown();
3280        _result
3281    }
3282
3283    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3284        self.control_handle
3285            .inner
3286            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3287                result,
3288                self.tx_id,
3289                0x3c5b7579bb6f8b9f,
3290                fidl::encoding::DynamicFlags::empty(),
3291            )
3292    }
3293}
3294
3295#[must_use = "FIDL methods require a response to be sent"]
3296#[derive(Debug)]
3297pub struct DeviceAckInterruptResponder {
3298    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3299    tx_id: u32,
3300}
3301
3302/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3303/// if the responder is dropped without sending a response, so that the client
3304/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3305impl std::ops::Drop for DeviceAckInterruptResponder {
3306    fn drop(&mut self) {
3307        self.control_handle.shutdown();
3308        // Safety: drops once, never accessed again
3309        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3310    }
3311}
3312
3313impl fidl::endpoints::Responder for DeviceAckInterruptResponder {
3314    type ControlHandle = DeviceControlHandle;
3315
3316    fn control_handle(&self) -> &DeviceControlHandle {
3317        &self.control_handle
3318    }
3319
3320    fn drop_without_shutdown(mut self) {
3321        // Safety: drops once, never accessed again due to mem::forget
3322        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3323        // Prevent Drop from running (which would shut down the channel)
3324        std::mem::forget(self);
3325    }
3326}
3327
3328impl DeviceAckInterruptResponder {
3329    /// Sends a response to the FIDL transaction.
3330    ///
3331    /// Sets the channel to shutdown if an error occurs.
3332    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3333        let _result = self.send_raw(result);
3334        if _result.is_err() {
3335            self.control_handle.shutdown();
3336        }
3337        self.drop_without_shutdown();
3338        _result
3339    }
3340
3341    /// Similar to "send" but does not shutdown the channel if an error occurs.
3342    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3343        let _result = self.send_raw(result);
3344        self.drop_without_shutdown();
3345        _result
3346    }
3347
3348    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3349        self.control_handle
3350            .inner
3351            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3352                result,
3353                self.tx_id,
3354                0x70742f64692d5a6b,
3355                fidl::encoding::DynamicFlags::empty(),
3356            )
3357    }
3358}
3359
3360#[must_use = "FIDL methods require a response to be sent"]
3361#[derive(Debug)]
3362pub struct DeviceMapInterruptResponder {
3363    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3364    tx_id: u32,
3365}
3366
3367/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3368/// if the responder is dropped without sending a response, so that the client
3369/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3370impl std::ops::Drop for DeviceMapInterruptResponder {
3371    fn drop(&mut self) {
3372        self.control_handle.shutdown();
3373        // Safety: drops once, never accessed again
3374        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3375    }
3376}
3377
3378impl fidl::endpoints::Responder for DeviceMapInterruptResponder {
3379    type ControlHandle = DeviceControlHandle;
3380
3381    fn control_handle(&self) -> &DeviceControlHandle {
3382        &self.control_handle
3383    }
3384
3385    fn drop_without_shutdown(mut self) {
3386        // Safety: drops once, never accessed again due to mem::forget
3387        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3388        // Prevent Drop from running (which would shut down the channel)
3389        std::mem::forget(self);
3390    }
3391}
3392
3393impl DeviceMapInterruptResponder {
3394    /// Sends a response to the FIDL transaction.
3395    ///
3396    /// Sets the channel to shutdown if an error occurs.
3397    pub fn send(self, mut result: Result<fidl::Interrupt, i32>) -> Result<(), fidl::Error> {
3398        let _result = self.send_raw(result);
3399        if _result.is_err() {
3400            self.control_handle.shutdown();
3401        }
3402        self.drop_without_shutdown();
3403        _result
3404    }
3405
3406    /// Similar to "send" but does not shutdown the channel if an error occurs.
3407    pub fn send_no_shutdown_on_err(
3408        self,
3409        mut result: Result<fidl::Interrupt, i32>,
3410    ) -> Result<(), fidl::Error> {
3411        let _result = self.send_raw(result);
3412        self.drop_without_shutdown();
3413        _result
3414    }
3415
3416    fn send_raw(&self, mut result: Result<fidl::Interrupt, i32>) -> Result<(), fidl::Error> {
3417        self.control_handle
3418            .inner
3419            .send::<fidl::encoding::ResultType<DeviceMapInterruptResponse, i32>>(
3420                result.map(|interrupt| (interrupt,)),
3421                self.tx_id,
3422                0x25eeff9d34a1fa13,
3423                fidl::encoding::DynamicFlags::empty(),
3424            )
3425    }
3426}
3427
3428#[must_use = "FIDL methods require a response to be sent"]
3429#[derive(Debug)]
3430pub struct DeviceGetInterruptModesResponder {
3431    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3432    tx_id: u32,
3433}
3434
3435/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3436/// if the responder is dropped without sending a response, so that the client
3437/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3438impl std::ops::Drop for DeviceGetInterruptModesResponder {
3439    fn drop(&mut self) {
3440        self.control_handle.shutdown();
3441        // Safety: drops once, never accessed again
3442        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3443    }
3444}
3445
3446impl fidl::endpoints::Responder for DeviceGetInterruptModesResponder {
3447    type ControlHandle = DeviceControlHandle;
3448
3449    fn control_handle(&self) -> &DeviceControlHandle {
3450        &self.control_handle
3451    }
3452
3453    fn drop_without_shutdown(mut self) {
3454        // Safety: drops once, never accessed again due to mem::forget
3455        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3456        // Prevent Drop from running (which would shut down the channel)
3457        std::mem::forget(self);
3458    }
3459}
3460
3461impl DeviceGetInterruptModesResponder {
3462    /// Sends a response to the FIDL transaction.
3463    ///
3464    /// Sets the channel to shutdown if an error occurs.
3465    pub fn send(self, mut modes: &InterruptModes) -> Result<(), fidl::Error> {
3466        let _result = self.send_raw(modes);
3467        if _result.is_err() {
3468            self.control_handle.shutdown();
3469        }
3470        self.drop_without_shutdown();
3471        _result
3472    }
3473
3474    /// Similar to "send" but does not shutdown the channel if an error occurs.
3475    pub fn send_no_shutdown_on_err(self, mut modes: &InterruptModes) -> Result<(), fidl::Error> {
3476        let _result = self.send_raw(modes);
3477        self.drop_without_shutdown();
3478        _result
3479    }
3480
3481    fn send_raw(&self, mut modes: &InterruptModes) -> Result<(), fidl::Error> {
3482        self.control_handle.inner.send::<DeviceGetInterruptModesResponse>(
3483            (modes,),
3484            self.tx_id,
3485            0x93f4cd8f79e9f4a,
3486            fidl::encoding::DynamicFlags::empty(),
3487        )
3488    }
3489}
3490
3491#[must_use = "FIDL methods require a response to be sent"]
3492#[derive(Debug)]
3493pub struct DeviceSetInterruptModeResponder {
3494    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3495    tx_id: u32,
3496}
3497
3498/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3499/// if the responder is dropped without sending a response, so that the client
3500/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3501impl std::ops::Drop for DeviceSetInterruptModeResponder {
3502    fn drop(&mut self) {
3503        self.control_handle.shutdown();
3504        // Safety: drops once, never accessed again
3505        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3506    }
3507}
3508
3509impl fidl::endpoints::Responder for DeviceSetInterruptModeResponder {
3510    type ControlHandle = DeviceControlHandle;
3511
3512    fn control_handle(&self) -> &DeviceControlHandle {
3513        &self.control_handle
3514    }
3515
3516    fn drop_without_shutdown(mut self) {
3517        // Safety: drops once, never accessed again due to mem::forget
3518        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3519        // Prevent Drop from running (which would shut down the channel)
3520        std::mem::forget(self);
3521    }
3522}
3523
3524impl DeviceSetInterruptModeResponder {
3525    /// Sends a response to the FIDL transaction.
3526    ///
3527    /// Sets the channel to shutdown if an error occurs.
3528    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3529        let _result = self.send_raw(result);
3530        if _result.is_err() {
3531            self.control_handle.shutdown();
3532        }
3533        self.drop_without_shutdown();
3534        _result
3535    }
3536
3537    /// Similar to "send" but does not shutdown the channel if an error occurs.
3538    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3539        let _result = self.send_raw(result);
3540        self.drop_without_shutdown();
3541        _result
3542    }
3543
3544    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3545        self.control_handle
3546            .inner
3547            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3548                result,
3549                self.tx_id,
3550                0x85bebad3eb24866,
3551                fidl::encoding::DynamicFlags::empty(),
3552            )
3553    }
3554}
3555
3556#[must_use = "FIDL methods require a response to be sent"]
3557#[derive(Debug)]
3558pub struct DeviceReadConfig8Responder {
3559    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3560    tx_id: u32,
3561}
3562
3563/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3564/// if the responder is dropped without sending a response, so that the client
3565/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3566impl std::ops::Drop for DeviceReadConfig8Responder {
3567    fn drop(&mut self) {
3568        self.control_handle.shutdown();
3569        // Safety: drops once, never accessed again
3570        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3571    }
3572}
3573
3574impl fidl::endpoints::Responder for DeviceReadConfig8Responder {
3575    type ControlHandle = DeviceControlHandle;
3576
3577    fn control_handle(&self) -> &DeviceControlHandle {
3578        &self.control_handle
3579    }
3580
3581    fn drop_without_shutdown(mut self) {
3582        // Safety: drops once, never accessed again due to mem::forget
3583        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3584        // Prevent Drop from running (which would shut down the channel)
3585        std::mem::forget(self);
3586    }
3587}
3588
3589impl DeviceReadConfig8Responder {
3590    /// Sends a response to the FIDL transaction.
3591    ///
3592    /// Sets the channel to shutdown if an error occurs.
3593    pub fn send(self, mut result: Result<u8, i32>) -> Result<(), fidl::Error> {
3594        let _result = self.send_raw(result);
3595        if _result.is_err() {
3596            self.control_handle.shutdown();
3597        }
3598        self.drop_without_shutdown();
3599        _result
3600    }
3601
3602    /// Similar to "send" but does not shutdown the channel if an error occurs.
3603    pub fn send_no_shutdown_on_err(self, mut result: Result<u8, i32>) -> Result<(), fidl::Error> {
3604        let _result = self.send_raw(result);
3605        self.drop_without_shutdown();
3606        _result
3607    }
3608
3609    fn send_raw(&self, mut result: Result<u8, i32>) -> Result<(), fidl::Error> {
3610        self.control_handle
3611            .inner
3612            .send::<fidl::encoding::ResultType<DeviceReadConfig8Response, i32>>(
3613                result.map(|value| (value,)),
3614                self.tx_id,
3615                0x28f9eb9e6dadda1c,
3616                fidl::encoding::DynamicFlags::empty(),
3617            )
3618    }
3619}
3620
3621#[must_use = "FIDL methods require a response to be sent"]
3622#[derive(Debug)]
3623pub struct DeviceReadConfig16Responder {
3624    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3625    tx_id: u32,
3626}
3627
3628/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3629/// if the responder is dropped without sending a response, so that the client
3630/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3631impl std::ops::Drop for DeviceReadConfig16Responder {
3632    fn drop(&mut self) {
3633        self.control_handle.shutdown();
3634        // Safety: drops once, never accessed again
3635        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3636    }
3637}
3638
3639impl fidl::endpoints::Responder for DeviceReadConfig16Responder {
3640    type ControlHandle = DeviceControlHandle;
3641
3642    fn control_handle(&self) -> &DeviceControlHandle {
3643        &self.control_handle
3644    }
3645
3646    fn drop_without_shutdown(mut self) {
3647        // Safety: drops once, never accessed again due to mem::forget
3648        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3649        // Prevent Drop from running (which would shut down the channel)
3650        std::mem::forget(self);
3651    }
3652}
3653
3654impl DeviceReadConfig16Responder {
3655    /// Sends a response to the FIDL transaction.
3656    ///
3657    /// Sets the channel to shutdown if an error occurs.
3658    pub fn send(self, mut result: Result<u16, i32>) -> Result<(), fidl::Error> {
3659        let _result = self.send_raw(result);
3660        if _result.is_err() {
3661            self.control_handle.shutdown();
3662        }
3663        self.drop_without_shutdown();
3664        _result
3665    }
3666
3667    /// Similar to "send" but does not shutdown the channel if an error occurs.
3668    pub fn send_no_shutdown_on_err(self, mut result: Result<u16, i32>) -> Result<(), fidl::Error> {
3669        let _result = self.send_raw(result);
3670        self.drop_without_shutdown();
3671        _result
3672    }
3673
3674    fn send_raw(&self, mut result: Result<u16, i32>) -> Result<(), fidl::Error> {
3675        self.control_handle
3676            .inner
3677            .send::<fidl::encoding::ResultType<DeviceReadConfig16Response, i32>>(
3678                result.map(|value| (value,)),
3679                self.tx_id,
3680                0x3bcda6171a3270bb,
3681                fidl::encoding::DynamicFlags::empty(),
3682            )
3683    }
3684}
3685
3686#[must_use = "FIDL methods require a response to be sent"]
3687#[derive(Debug)]
3688pub struct DeviceReadConfig32Responder {
3689    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3690    tx_id: u32,
3691}
3692
3693/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3694/// if the responder is dropped without sending a response, so that the client
3695/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3696impl std::ops::Drop for DeviceReadConfig32Responder {
3697    fn drop(&mut self) {
3698        self.control_handle.shutdown();
3699        // Safety: drops once, never accessed again
3700        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3701    }
3702}
3703
3704impl fidl::endpoints::Responder for DeviceReadConfig32Responder {
3705    type ControlHandle = DeviceControlHandle;
3706
3707    fn control_handle(&self) -> &DeviceControlHandle {
3708        &self.control_handle
3709    }
3710
3711    fn drop_without_shutdown(mut self) {
3712        // Safety: drops once, never accessed again due to mem::forget
3713        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3714        // Prevent Drop from running (which would shut down the channel)
3715        std::mem::forget(self);
3716    }
3717}
3718
3719impl DeviceReadConfig32Responder {
3720    /// Sends a response to the FIDL transaction.
3721    ///
3722    /// Sets the channel to shutdown if an error occurs.
3723    pub fn send(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
3724        let _result = self.send_raw(result);
3725        if _result.is_err() {
3726            self.control_handle.shutdown();
3727        }
3728        self.drop_without_shutdown();
3729        _result
3730    }
3731
3732    /// Similar to "send" but does not shutdown the channel if an error occurs.
3733    pub fn send_no_shutdown_on_err(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
3734        let _result = self.send_raw(result);
3735        self.drop_without_shutdown();
3736        _result
3737    }
3738
3739    fn send_raw(&self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
3740        self.control_handle
3741            .inner
3742            .send::<fidl::encoding::ResultType<DeviceReadConfig32Response, i32>>(
3743                result.map(|value| (value,)),
3744                self.tx_id,
3745                0x55357535402f7507,
3746                fidl::encoding::DynamicFlags::empty(),
3747            )
3748    }
3749}
3750
3751#[must_use = "FIDL methods require a response to be sent"]
3752#[derive(Debug)]
3753pub struct DeviceWriteConfig8Responder {
3754    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3755    tx_id: u32,
3756}
3757
3758/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3759/// if the responder is dropped without sending a response, so that the client
3760/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3761impl std::ops::Drop for DeviceWriteConfig8Responder {
3762    fn drop(&mut self) {
3763        self.control_handle.shutdown();
3764        // Safety: drops once, never accessed again
3765        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3766    }
3767}
3768
3769impl fidl::endpoints::Responder for DeviceWriteConfig8Responder {
3770    type ControlHandle = DeviceControlHandle;
3771
3772    fn control_handle(&self) -> &DeviceControlHandle {
3773        &self.control_handle
3774    }
3775
3776    fn drop_without_shutdown(mut self) {
3777        // Safety: drops once, never accessed again due to mem::forget
3778        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3779        // Prevent Drop from running (which would shut down the channel)
3780        std::mem::forget(self);
3781    }
3782}
3783
3784impl DeviceWriteConfig8Responder {
3785    /// Sends a response to the FIDL transaction.
3786    ///
3787    /// Sets the channel to shutdown if an error occurs.
3788    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3789        let _result = self.send_raw(result);
3790        if _result.is_err() {
3791            self.control_handle.shutdown();
3792        }
3793        self.drop_without_shutdown();
3794        _result
3795    }
3796
3797    /// Similar to "send" but does not shutdown the channel if an error occurs.
3798    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3799        let _result = self.send_raw(result);
3800        self.drop_without_shutdown();
3801        _result
3802    }
3803
3804    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3805        self.control_handle
3806            .inner
3807            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3808                result,
3809                self.tx_id,
3810                0x49a0719e1433cff,
3811                fidl::encoding::DynamicFlags::empty(),
3812            )
3813    }
3814}
3815
3816#[must_use = "FIDL methods require a response to be sent"]
3817#[derive(Debug)]
3818pub struct DeviceWriteConfig16Responder {
3819    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3820    tx_id: u32,
3821}
3822
3823/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3824/// if the responder is dropped without sending a response, so that the client
3825/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3826impl std::ops::Drop for DeviceWriteConfig16Responder {
3827    fn drop(&mut self) {
3828        self.control_handle.shutdown();
3829        // Safety: drops once, never accessed again
3830        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3831    }
3832}
3833
3834impl fidl::endpoints::Responder for DeviceWriteConfig16Responder {
3835    type ControlHandle = DeviceControlHandle;
3836
3837    fn control_handle(&self) -> &DeviceControlHandle {
3838        &self.control_handle
3839    }
3840
3841    fn drop_without_shutdown(mut self) {
3842        // Safety: drops once, never accessed again due to mem::forget
3843        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3844        // Prevent Drop from running (which would shut down the channel)
3845        std::mem::forget(self);
3846    }
3847}
3848
3849impl DeviceWriteConfig16Responder {
3850    /// Sends a response to the FIDL transaction.
3851    ///
3852    /// Sets the channel to shutdown if an error occurs.
3853    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3854        let _result = self.send_raw(result);
3855        if _result.is_err() {
3856            self.control_handle.shutdown();
3857        }
3858        self.drop_without_shutdown();
3859        _result
3860    }
3861
3862    /// Similar to "send" but does not shutdown the channel if an error occurs.
3863    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3864        let _result = self.send_raw(result);
3865        self.drop_without_shutdown();
3866        _result
3867    }
3868
3869    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3870        self.control_handle
3871            .inner
3872            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3873                result,
3874                self.tx_id,
3875                0x3e30bf13f1c07eff,
3876                fidl::encoding::DynamicFlags::empty(),
3877            )
3878    }
3879}
3880
3881#[must_use = "FIDL methods require a response to be sent"]
3882#[derive(Debug)]
3883pub struct DeviceWriteConfig32Responder {
3884    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3885    tx_id: u32,
3886}
3887
3888/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3889/// if the responder is dropped without sending a response, so that the client
3890/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3891impl std::ops::Drop for DeviceWriteConfig32Responder {
3892    fn drop(&mut self) {
3893        self.control_handle.shutdown();
3894        // Safety: drops once, never accessed again
3895        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3896    }
3897}
3898
3899impl fidl::endpoints::Responder for DeviceWriteConfig32Responder {
3900    type ControlHandle = DeviceControlHandle;
3901
3902    fn control_handle(&self) -> &DeviceControlHandle {
3903        &self.control_handle
3904    }
3905
3906    fn drop_without_shutdown(mut self) {
3907        // Safety: drops once, never accessed again due to mem::forget
3908        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3909        // Prevent Drop from running (which would shut down the channel)
3910        std::mem::forget(self);
3911    }
3912}
3913
3914impl DeviceWriteConfig32Responder {
3915    /// Sends a response to the FIDL transaction.
3916    ///
3917    /// Sets the channel to shutdown if an error occurs.
3918    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3919        let _result = self.send_raw(result);
3920        if _result.is_err() {
3921            self.control_handle.shutdown();
3922        }
3923        self.drop_without_shutdown();
3924        _result
3925    }
3926
3927    /// Similar to "send" but does not shutdown the channel if an error occurs.
3928    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3929        let _result = self.send_raw(result);
3930        self.drop_without_shutdown();
3931        _result
3932    }
3933
3934    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3935        self.control_handle
3936            .inner
3937            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3938                result,
3939                self.tx_id,
3940                0x161584e5199b388,
3941                fidl::encoding::DynamicFlags::empty(),
3942            )
3943    }
3944}
3945
3946#[must_use = "FIDL methods require a response to be sent"]
3947#[derive(Debug)]
3948pub struct DeviceGetCapabilitiesResponder {
3949    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
3950    tx_id: u32,
3951}
3952
3953/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
3954/// if the responder is dropped without sending a response, so that the client
3955/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3956impl std::ops::Drop for DeviceGetCapabilitiesResponder {
3957    fn drop(&mut self) {
3958        self.control_handle.shutdown();
3959        // Safety: drops once, never accessed again
3960        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3961    }
3962}
3963
3964impl fidl::endpoints::Responder for DeviceGetCapabilitiesResponder {
3965    type ControlHandle = DeviceControlHandle;
3966
3967    fn control_handle(&self) -> &DeviceControlHandle {
3968        &self.control_handle
3969    }
3970
3971    fn drop_without_shutdown(mut self) {
3972        // Safety: drops once, never accessed again due to mem::forget
3973        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3974        // Prevent Drop from running (which would shut down the channel)
3975        std::mem::forget(self);
3976    }
3977}
3978
3979impl DeviceGetCapabilitiesResponder {
3980    /// Sends a response to the FIDL transaction.
3981    ///
3982    /// Sets the channel to shutdown if an error occurs.
3983    pub fn send(self, mut offsets: &[u8]) -> Result<(), fidl::Error> {
3984        let _result = self.send_raw(offsets);
3985        if _result.is_err() {
3986            self.control_handle.shutdown();
3987        }
3988        self.drop_without_shutdown();
3989        _result
3990    }
3991
3992    /// Similar to "send" but does not shutdown the channel if an error occurs.
3993    pub fn send_no_shutdown_on_err(self, mut offsets: &[u8]) -> Result<(), fidl::Error> {
3994        let _result = self.send_raw(offsets);
3995        self.drop_without_shutdown();
3996        _result
3997    }
3998
3999    fn send_raw(&self, mut offsets: &[u8]) -> Result<(), fidl::Error> {
4000        self.control_handle.inner.send::<DeviceGetCapabilitiesResponse>(
4001            (offsets,),
4002            self.tx_id,
4003            0x3a050fde46f3ba0f,
4004            fidl::encoding::DynamicFlags::empty(),
4005        )
4006    }
4007}
4008
4009#[must_use = "FIDL methods require a response to be sent"]
4010#[derive(Debug)]
4011pub struct DeviceGetExtendedCapabilitiesResponder {
4012    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
4013    tx_id: u32,
4014}
4015
4016/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
4017/// if the responder is dropped without sending a response, so that the client
4018/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4019impl std::ops::Drop for DeviceGetExtendedCapabilitiesResponder {
4020    fn drop(&mut self) {
4021        self.control_handle.shutdown();
4022        // Safety: drops once, never accessed again
4023        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4024    }
4025}
4026
4027impl fidl::endpoints::Responder for DeviceGetExtendedCapabilitiesResponder {
4028    type ControlHandle = DeviceControlHandle;
4029
4030    fn control_handle(&self) -> &DeviceControlHandle {
4031        &self.control_handle
4032    }
4033
4034    fn drop_without_shutdown(mut self) {
4035        // Safety: drops once, never accessed again due to mem::forget
4036        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4037        // Prevent Drop from running (which would shut down the channel)
4038        std::mem::forget(self);
4039    }
4040}
4041
4042impl DeviceGetExtendedCapabilitiesResponder {
4043    /// Sends a response to the FIDL transaction.
4044    ///
4045    /// Sets the channel to shutdown if an error occurs.
4046    pub fn send(self, mut offsets: &[u16]) -> Result<(), fidl::Error> {
4047        let _result = self.send_raw(offsets);
4048        if _result.is_err() {
4049            self.control_handle.shutdown();
4050        }
4051        self.drop_without_shutdown();
4052        _result
4053    }
4054
4055    /// Similar to "send" but does not shutdown the channel if an error occurs.
4056    pub fn send_no_shutdown_on_err(self, mut offsets: &[u16]) -> Result<(), fidl::Error> {
4057        let _result = self.send_raw(offsets);
4058        self.drop_without_shutdown();
4059        _result
4060    }
4061
4062    fn send_raw(&self, mut offsets: &[u16]) -> Result<(), fidl::Error> {
4063        self.control_handle.inner.send::<DeviceGetExtendedCapabilitiesResponse>(
4064            (offsets,),
4065            self.tx_id,
4066            0xb8573efcaae0c39,
4067            fidl::encoding::DynamicFlags::empty(),
4068        )
4069    }
4070}
4071
4072#[must_use = "FIDL methods require a response to be sent"]
4073#[derive(Debug)]
4074pub struct DeviceGetBtiResponder {
4075    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
4076    tx_id: u32,
4077}
4078
4079/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
4080/// if the responder is dropped without sending a response, so that the client
4081/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4082impl std::ops::Drop for DeviceGetBtiResponder {
4083    fn drop(&mut self) {
4084        self.control_handle.shutdown();
4085        // Safety: drops once, never accessed again
4086        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4087    }
4088}
4089
4090impl fidl::endpoints::Responder for DeviceGetBtiResponder {
4091    type ControlHandle = DeviceControlHandle;
4092
4093    fn control_handle(&self) -> &DeviceControlHandle {
4094        &self.control_handle
4095    }
4096
4097    fn drop_without_shutdown(mut self) {
4098        // Safety: drops once, never accessed again due to mem::forget
4099        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4100        // Prevent Drop from running (which would shut down the channel)
4101        std::mem::forget(self);
4102    }
4103}
4104
4105impl DeviceGetBtiResponder {
4106    /// Sends a response to the FIDL transaction.
4107    ///
4108    /// Sets the channel to shutdown if an error occurs.
4109    pub fn send(self, mut result: Result<fidl::Bti, i32>) -> Result<(), fidl::Error> {
4110        let _result = self.send_raw(result);
4111        if _result.is_err() {
4112            self.control_handle.shutdown();
4113        }
4114        self.drop_without_shutdown();
4115        _result
4116    }
4117
4118    /// Similar to "send" but does not shutdown the channel if an error occurs.
4119    pub fn send_no_shutdown_on_err(
4120        self,
4121        mut result: Result<fidl::Bti, i32>,
4122    ) -> Result<(), fidl::Error> {
4123        let _result = self.send_raw(result);
4124        self.drop_without_shutdown();
4125        _result
4126    }
4127
4128    fn send_raw(&self, mut result: Result<fidl::Bti, i32>) -> Result<(), fidl::Error> {
4129        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceGetBtiResponse, i32>>(
4130            result.map(|bti| (bti,)),
4131            self.tx_id,
4132            0x5e4fe9efb12d9ee3,
4133            fidl::encoding::DynamicFlags::empty(),
4134        )
4135    }
4136}
4137
4138#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4139pub struct ServiceMarker;
4140
4141#[cfg(target_os = "fuchsia")]
4142impl fidl::endpoints::ServiceMarker for ServiceMarker {
4143    type Proxy = ServiceProxy;
4144    type Request = ServiceRequest;
4145    const SERVICE_NAME: &'static str = "fuchsia.hardware.pci.Service";
4146}
4147
4148/// A request for one of the member protocols of Service.
4149///
4150#[cfg(target_os = "fuchsia")]
4151pub enum ServiceRequest {
4152    Device(DeviceRequestStream),
4153}
4154
4155#[cfg(target_os = "fuchsia")]
4156impl fidl::endpoints::ServiceRequest for ServiceRequest {
4157    type Service = ServiceMarker;
4158
4159    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
4160        match name {
4161            "device" => Self::Device(
4162                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
4163            ),
4164            _ => panic!("no such member protocol name for service Service"),
4165        }
4166    }
4167
4168    fn member_names() -> &'static [&'static str] {
4169        &["device"]
4170    }
4171}
4172#[cfg(target_os = "fuchsia")]
4173pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
4174
4175#[cfg(target_os = "fuchsia")]
4176impl fidl::endpoints::ServiceProxy for ServiceProxy {
4177    type Service = ServiceMarker;
4178
4179    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
4180        Self(opener)
4181    }
4182}
4183
4184#[cfg(target_os = "fuchsia")]
4185impl ServiceProxy {
4186    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
4187        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
4188        self.connect_channel_to_device(server_end)?;
4189        Ok(proxy)
4190    }
4191
4192    /// Like `connect_to_device`, but returns a sync proxy.
4193    /// See [`Self::connect_to_device`] for more details.
4194    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
4195        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
4196        self.connect_channel_to_device(server_end)?;
4197        Ok(proxy)
4198    }
4199
4200    /// Like `connect_to_device`, but accepts a server end.
4201    /// See [`Self::connect_to_device`] for more details.
4202    pub fn connect_channel_to_device(
4203        &self,
4204        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
4205    ) -> Result<(), fidl::Error> {
4206        self.0.open_member("device", server_end.into_channel())
4207    }
4208
4209    pub fn instance_name(&self) -> &str {
4210        self.0.instance_name()
4211    }
4212}
4213
4214mod internal {
4215    use super::*;
4216
4217    impl fidl::encoding::ResourceTypeMarker for Bar {
4218        type Borrowed<'a> = &'a mut Self;
4219        fn take_or_borrow<'a>(
4220            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4221        ) -> Self::Borrowed<'a> {
4222            value
4223        }
4224    }
4225
4226    unsafe impl fidl::encoding::TypeMarker for Bar {
4227        type Owned = Self;
4228
4229        #[inline(always)]
4230        fn inline_align(_context: fidl::encoding::Context) -> usize {
4231            8
4232        }
4233
4234        #[inline(always)]
4235        fn inline_size(_context: fidl::encoding::Context) -> usize {
4236            32
4237        }
4238    }
4239
4240    unsafe impl fidl::encoding::Encode<Bar, fidl::encoding::DefaultFuchsiaResourceDialect>
4241        for &mut Bar
4242    {
4243        #[inline]
4244        unsafe fn encode(
4245            self,
4246            encoder: &mut fidl::encoding::Encoder<
4247                '_,
4248                fidl::encoding::DefaultFuchsiaResourceDialect,
4249            >,
4250            offset: usize,
4251            _depth: fidl::encoding::Depth,
4252        ) -> fidl::Result<()> {
4253            encoder.debug_check_bounds::<Bar>(offset);
4254            // Delegate to tuple encoding.
4255            fidl::encoding::Encode::<Bar, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4256                (
4257                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.bar_id),
4258                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.size),
4259                    <BarResult as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4260                        &mut self.result,
4261                    ),
4262                ),
4263                encoder,
4264                offset,
4265                _depth,
4266            )
4267        }
4268    }
4269    unsafe impl<
4270        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
4271        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
4272        T2: fidl::encoding::Encode<BarResult, fidl::encoding::DefaultFuchsiaResourceDialect>,
4273    > fidl::encoding::Encode<Bar, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0, T1, T2)
4274    {
4275        #[inline]
4276        unsafe fn encode(
4277            self,
4278            encoder: &mut fidl::encoding::Encoder<
4279                '_,
4280                fidl::encoding::DefaultFuchsiaResourceDialect,
4281            >,
4282            offset: usize,
4283            depth: fidl::encoding::Depth,
4284        ) -> fidl::Result<()> {
4285            encoder.debug_check_bounds::<Bar>(offset);
4286            // Zero out padding regions. There's no need to apply masks
4287            // because the unmasked parts will be overwritten by fields.
4288            unsafe {
4289                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
4290                (ptr as *mut u64).write_unaligned(0);
4291            }
4292            // Write the fields.
4293            self.0.encode(encoder, offset + 0, depth)?;
4294            self.1.encode(encoder, offset + 8, depth)?;
4295            self.2.encode(encoder, offset + 16, depth)?;
4296            Ok(())
4297        }
4298    }
4299
4300    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Bar {
4301        #[inline(always)]
4302        fn new_empty() -> Self {
4303            Self {
4304                bar_id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
4305                size: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
4306                result: fidl::new_empty!(BarResult, fidl::encoding::DefaultFuchsiaResourceDialect),
4307            }
4308        }
4309
4310        #[inline]
4311        unsafe fn decode(
4312            &mut self,
4313            decoder: &mut fidl::encoding::Decoder<
4314                '_,
4315                fidl::encoding::DefaultFuchsiaResourceDialect,
4316            >,
4317            offset: usize,
4318            _depth: fidl::encoding::Depth,
4319        ) -> fidl::Result<()> {
4320            decoder.debug_check_bounds::<Self>(offset);
4321            // Verify that padding bytes are zero.
4322            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
4323            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4324            let mask = 0xffffffff00000000u64;
4325            let maskedval = padval & mask;
4326            if maskedval != 0 {
4327                return Err(fidl::Error::NonZeroPadding {
4328                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
4329                });
4330            }
4331            fidl::decode!(
4332                u32,
4333                fidl::encoding::DefaultFuchsiaResourceDialect,
4334                &mut self.bar_id,
4335                decoder,
4336                offset + 0,
4337                _depth
4338            )?;
4339            fidl::decode!(
4340                u64,
4341                fidl::encoding::DefaultFuchsiaResourceDialect,
4342                &mut self.size,
4343                decoder,
4344                offset + 8,
4345                _depth
4346            )?;
4347            fidl::decode!(
4348                BarResult,
4349                fidl::encoding::DefaultFuchsiaResourceDialect,
4350                &mut self.result,
4351                decoder,
4352                offset + 16,
4353                _depth
4354            )?;
4355            Ok(())
4356        }
4357    }
4358
4359    impl fidl::encoding::ResourceTypeMarker for DeviceGetBarResponse {
4360        type Borrowed<'a> = &'a mut Self;
4361        fn take_or_borrow<'a>(
4362            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4363        ) -> Self::Borrowed<'a> {
4364            value
4365        }
4366    }
4367
4368    unsafe impl fidl::encoding::TypeMarker for DeviceGetBarResponse {
4369        type Owned = Self;
4370
4371        #[inline(always)]
4372        fn inline_align(_context: fidl::encoding::Context) -> usize {
4373            8
4374        }
4375
4376        #[inline(always)]
4377        fn inline_size(_context: fidl::encoding::Context) -> usize {
4378            32
4379        }
4380    }
4381
4382    unsafe impl
4383        fidl::encoding::Encode<DeviceGetBarResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
4384        for &mut DeviceGetBarResponse
4385    {
4386        #[inline]
4387        unsafe fn encode(
4388            self,
4389            encoder: &mut fidl::encoding::Encoder<
4390                '_,
4391                fidl::encoding::DefaultFuchsiaResourceDialect,
4392            >,
4393            offset: usize,
4394            _depth: fidl::encoding::Depth,
4395        ) -> fidl::Result<()> {
4396            encoder.debug_check_bounds::<DeviceGetBarResponse>(offset);
4397            // Delegate to tuple encoding.
4398            fidl::encoding::Encode::<
4399                DeviceGetBarResponse,
4400                fidl::encoding::DefaultFuchsiaResourceDialect,
4401            >::encode(
4402                (<Bar as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.result),),
4403                encoder,
4404                offset,
4405                _depth,
4406            )
4407        }
4408    }
4409    unsafe impl<T0: fidl::encoding::Encode<Bar, fidl::encoding::DefaultFuchsiaResourceDialect>>
4410        fidl::encoding::Encode<DeviceGetBarResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
4411        for (T0,)
4412    {
4413        #[inline]
4414        unsafe fn encode(
4415            self,
4416            encoder: &mut fidl::encoding::Encoder<
4417                '_,
4418                fidl::encoding::DefaultFuchsiaResourceDialect,
4419            >,
4420            offset: usize,
4421            depth: fidl::encoding::Depth,
4422        ) -> fidl::Result<()> {
4423            encoder.debug_check_bounds::<DeviceGetBarResponse>(offset);
4424            // Zero out padding regions. There's no need to apply masks
4425            // because the unmasked parts will be overwritten by fields.
4426            // Write the fields.
4427            self.0.encode(encoder, offset + 0, depth)?;
4428            Ok(())
4429        }
4430    }
4431
4432    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4433        for DeviceGetBarResponse
4434    {
4435        #[inline(always)]
4436        fn new_empty() -> Self {
4437            Self { result: fidl::new_empty!(Bar, fidl::encoding::DefaultFuchsiaResourceDialect) }
4438        }
4439
4440        #[inline]
4441        unsafe fn decode(
4442            &mut self,
4443            decoder: &mut fidl::encoding::Decoder<
4444                '_,
4445                fidl::encoding::DefaultFuchsiaResourceDialect,
4446            >,
4447            offset: usize,
4448            _depth: fidl::encoding::Depth,
4449        ) -> fidl::Result<()> {
4450            decoder.debug_check_bounds::<Self>(offset);
4451            // Verify that padding bytes are zero.
4452            fidl::decode!(
4453                Bar,
4454                fidl::encoding::DefaultFuchsiaResourceDialect,
4455                &mut self.result,
4456                decoder,
4457                offset + 0,
4458                _depth
4459            )?;
4460            Ok(())
4461        }
4462    }
4463
4464    impl fidl::encoding::ResourceTypeMarker for DeviceGetBtiResponse {
4465        type Borrowed<'a> = &'a mut Self;
4466        fn take_or_borrow<'a>(
4467            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4468        ) -> Self::Borrowed<'a> {
4469            value
4470        }
4471    }
4472
4473    unsafe impl fidl::encoding::TypeMarker for DeviceGetBtiResponse {
4474        type Owned = Self;
4475
4476        #[inline(always)]
4477        fn inline_align(_context: fidl::encoding::Context) -> usize {
4478            4
4479        }
4480
4481        #[inline(always)]
4482        fn inline_size(_context: fidl::encoding::Context) -> usize {
4483            4
4484        }
4485    }
4486
4487    unsafe impl
4488        fidl::encoding::Encode<DeviceGetBtiResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
4489        for &mut DeviceGetBtiResponse
4490    {
4491        #[inline]
4492        unsafe fn encode(
4493            self,
4494            encoder: &mut fidl::encoding::Encoder<
4495                '_,
4496                fidl::encoding::DefaultFuchsiaResourceDialect,
4497            >,
4498            offset: usize,
4499            _depth: fidl::encoding::Depth,
4500        ) -> fidl::Result<()> {
4501            encoder.debug_check_bounds::<DeviceGetBtiResponse>(offset);
4502            // Delegate to tuple encoding.
4503            fidl::encoding::Encode::<
4504                DeviceGetBtiResponse,
4505                fidl::encoding::DefaultFuchsiaResourceDialect,
4506            >::encode(
4507                (<fidl::encoding::HandleType<
4508                    fidl::Bti,
4509                    { fidl::ObjectType::BTI.into_raw() },
4510                    2147483648,
4511                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4512                    &mut self.bti
4513                ),),
4514                encoder,
4515                offset,
4516                _depth,
4517            )
4518        }
4519    }
4520    unsafe impl<
4521        T0: fidl::encoding::Encode<
4522                fidl::encoding::HandleType<
4523                    fidl::Bti,
4524                    { fidl::ObjectType::BTI.into_raw() },
4525                    2147483648,
4526                >,
4527                fidl::encoding::DefaultFuchsiaResourceDialect,
4528            >,
4529    >
4530        fidl::encoding::Encode<DeviceGetBtiResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
4531        for (T0,)
4532    {
4533        #[inline]
4534        unsafe fn encode(
4535            self,
4536            encoder: &mut fidl::encoding::Encoder<
4537                '_,
4538                fidl::encoding::DefaultFuchsiaResourceDialect,
4539            >,
4540            offset: usize,
4541            depth: fidl::encoding::Depth,
4542        ) -> fidl::Result<()> {
4543            encoder.debug_check_bounds::<DeviceGetBtiResponse>(offset);
4544            // Zero out padding regions. There's no need to apply masks
4545            // because the unmasked parts will be overwritten by fields.
4546            // Write the fields.
4547            self.0.encode(encoder, offset + 0, depth)?;
4548            Ok(())
4549        }
4550    }
4551
4552    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4553        for DeviceGetBtiResponse
4554    {
4555        #[inline(always)]
4556        fn new_empty() -> Self {
4557            Self {
4558                bti: fidl::new_empty!(fidl::encoding::HandleType<fidl::Bti, { fidl::ObjectType::BTI.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
4559            }
4560        }
4561
4562        #[inline]
4563        unsafe fn decode(
4564            &mut self,
4565            decoder: &mut fidl::encoding::Decoder<
4566                '_,
4567                fidl::encoding::DefaultFuchsiaResourceDialect,
4568            >,
4569            offset: usize,
4570            _depth: fidl::encoding::Depth,
4571        ) -> fidl::Result<()> {
4572            decoder.debug_check_bounds::<Self>(offset);
4573            // Verify that padding bytes are zero.
4574            fidl::decode!(fidl::encoding::HandleType<fidl::Bti, { fidl::ObjectType::BTI.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.bti, decoder, offset + 0, _depth)?;
4575            Ok(())
4576        }
4577    }
4578
4579    impl fidl::encoding::ResourceTypeMarker for DeviceMapInterruptResponse {
4580        type Borrowed<'a> = &'a mut Self;
4581        fn take_or_borrow<'a>(
4582            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4583        ) -> Self::Borrowed<'a> {
4584            value
4585        }
4586    }
4587
4588    unsafe impl fidl::encoding::TypeMarker for DeviceMapInterruptResponse {
4589        type Owned = Self;
4590
4591        #[inline(always)]
4592        fn inline_align(_context: fidl::encoding::Context) -> usize {
4593            4
4594        }
4595
4596        #[inline(always)]
4597        fn inline_size(_context: fidl::encoding::Context) -> usize {
4598            4
4599        }
4600    }
4601
4602    unsafe impl
4603        fidl::encoding::Encode<
4604            DeviceMapInterruptResponse,
4605            fidl::encoding::DefaultFuchsiaResourceDialect,
4606        > for &mut DeviceMapInterruptResponse
4607    {
4608        #[inline]
4609        unsafe fn encode(
4610            self,
4611            encoder: &mut fidl::encoding::Encoder<
4612                '_,
4613                fidl::encoding::DefaultFuchsiaResourceDialect,
4614            >,
4615            offset: usize,
4616            _depth: fidl::encoding::Depth,
4617        ) -> fidl::Result<()> {
4618            encoder.debug_check_bounds::<DeviceMapInterruptResponse>(offset);
4619            // Delegate to tuple encoding.
4620            fidl::encoding::Encode::<
4621                DeviceMapInterruptResponse,
4622                fidl::encoding::DefaultFuchsiaResourceDialect,
4623            >::encode(
4624                (<fidl::encoding::HandleType<
4625                    fidl::Interrupt,
4626                    { fidl::ObjectType::INTERRUPT.into_raw() },
4627                    2147483648,
4628                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4629                    &mut self.interrupt
4630                ),),
4631                encoder,
4632                offset,
4633                _depth,
4634            )
4635        }
4636    }
4637    unsafe impl<
4638        T0: fidl::encoding::Encode<
4639                fidl::encoding::HandleType<
4640                    fidl::Interrupt,
4641                    { fidl::ObjectType::INTERRUPT.into_raw() },
4642                    2147483648,
4643                >,
4644                fidl::encoding::DefaultFuchsiaResourceDialect,
4645            >,
4646    >
4647        fidl::encoding::Encode<
4648            DeviceMapInterruptResponse,
4649            fidl::encoding::DefaultFuchsiaResourceDialect,
4650        > for (T0,)
4651    {
4652        #[inline]
4653        unsafe fn encode(
4654            self,
4655            encoder: &mut fidl::encoding::Encoder<
4656                '_,
4657                fidl::encoding::DefaultFuchsiaResourceDialect,
4658            >,
4659            offset: usize,
4660            depth: fidl::encoding::Depth,
4661        ) -> fidl::Result<()> {
4662            encoder.debug_check_bounds::<DeviceMapInterruptResponse>(offset);
4663            // Zero out padding regions. There's no need to apply masks
4664            // because the unmasked parts will be overwritten by fields.
4665            // Write the fields.
4666            self.0.encode(encoder, offset + 0, depth)?;
4667            Ok(())
4668        }
4669    }
4670
4671    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4672        for DeviceMapInterruptResponse
4673    {
4674        #[inline(always)]
4675        fn new_empty() -> Self {
4676            Self {
4677                interrupt: fidl::new_empty!(fidl::encoding::HandleType<fidl::Interrupt, { fidl::ObjectType::INTERRUPT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
4678            }
4679        }
4680
4681        #[inline]
4682        unsafe fn decode(
4683            &mut self,
4684            decoder: &mut fidl::encoding::Decoder<
4685                '_,
4686                fidl::encoding::DefaultFuchsiaResourceDialect,
4687            >,
4688            offset: usize,
4689            _depth: fidl::encoding::Depth,
4690        ) -> fidl::Result<()> {
4691            decoder.debug_check_bounds::<Self>(offset);
4692            // Verify that padding bytes are zero.
4693            fidl::decode!(fidl::encoding::HandleType<fidl::Interrupt, { fidl::ObjectType::INTERRUPT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.interrupt, decoder, offset + 0, _depth)?;
4694            Ok(())
4695        }
4696    }
4697
4698    impl fidl::encoding::ResourceTypeMarker for IoBar {
4699        type Borrowed<'a> = &'a mut Self;
4700        fn take_or_borrow<'a>(
4701            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4702        ) -> Self::Borrowed<'a> {
4703            value
4704        }
4705    }
4706
4707    unsafe impl fidl::encoding::TypeMarker for IoBar {
4708        type Owned = Self;
4709
4710        #[inline(always)]
4711        fn inline_align(_context: fidl::encoding::Context) -> usize {
4712            8
4713        }
4714
4715        #[inline(always)]
4716        fn inline_size(_context: fidl::encoding::Context) -> usize {
4717            16
4718        }
4719    }
4720
4721    unsafe impl fidl::encoding::Encode<IoBar, fidl::encoding::DefaultFuchsiaResourceDialect>
4722        for &mut IoBar
4723    {
4724        #[inline]
4725        unsafe fn encode(
4726            self,
4727            encoder: &mut fidl::encoding::Encoder<
4728                '_,
4729                fidl::encoding::DefaultFuchsiaResourceDialect,
4730            >,
4731            offset: usize,
4732            _depth: fidl::encoding::Depth,
4733        ) -> fidl::Result<()> {
4734            encoder.debug_check_bounds::<IoBar>(offset);
4735            // Delegate to tuple encoding.
4736            fidl::encoding::Encode::<IoBar, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4737                (
4738                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.address),
4739                    <fidl::encoding::HandleType<
4740                        fidl::Resource,
4741                        { fidl::ObjectType::RESOURCE.into_raw() },
4742                        2147483648,
4743                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4744                        &mut self.resource
4745                    ),
4746                ),
4747                encoder,
4748                offset,
4749                _depth,
4750            )
4751        }
4752    }
4753    unsafe impl<
4754        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
4755        T1: fidl::encoding::Encode<
4756                fidl::encoding::HandleType<
4757                    fidl::Resource,
4758                    { fidl::ObjectType::RESOURCE.into_raw() },
4759                    2147483648,
4760                >,
4761                fidl::encoding::DefaultFuchsiaResourceDialect,
4762            >,
4763    > fidl::encoding::Encode<IoBar, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0, T1)
4764    {
4765        #[inline]
4766        unsafe fn encode(
4767            self,
4768            encoder: &mut fidl::encoding::Encoder<
4769                '_,
4770                fidl::encoding::DefaultFuchsiaResourceDialect,
4771            >,
4772            offset: usize,
4773            depth: fidl::encoding::Depth,
4774        ) -> fidl::Result<()> {
4775            encoder.debug_check_bounds::<IoBar>(offset);
4776            // Zero out padding regions. There's no need to apply masks
4777            // because the unmasked parts will be overwritten by fields.
4778            unsafe {
4779                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
4780                (ptr as *mut u64).write_unaligned(0);
4781            }
4782            // Write the fields.
4783            self.0.encode(encoder, offset + 0, depth)?;
4784            self.1.encode(encoder, offset + 8, depth)?;
4785            Ok(())
4786        }
4787    }
4788
4789    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for IoBar {
4790        #[inline(always)]
4791        fn new_empty() -> Self {
4792            Self {
4793                address: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
4794                resource: fidl::new_empty!(fidl::encoding::HandleType<fidl::Resource, { fidl::ObjectType::RESOURCE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
4795            }
4796        }
4797
4798        #[inline]
4799        unsafe fn decode(
4800            &mut self,
4801            decoder: &mut fidl::encoding::Decoder<
4802                '_,
4803                fidl::encoding::DefaultFuchsiaResourceDialect,
4804            >,
4805            offset: usize,
4806            _depth: fidl::encoding::Depth,
4807        ) -> fidl::Result<()> {
4808            decoder.debug_check_bounds::<Self>(offset);
4809            // Verify that padding bytes are zero.
4810            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
4811            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4812            let mask = 0xffffffff00000000u64;
4813            let maskedval = padval & mask;
4814            if maskedval != 0 {
4815                return Err(fidl::Error::NonZeroPadding {
4816                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
4817                });
4818            }
4819            fidl::decode!(
4820                u64,
4821                fidl::encoding::DefaultFuchsiaResourceDialect,
4822                &mut self.address,
4823                decoder,
4824                offset + 0,
4825                _depth
4826            )?;
4827            fidl::decode!(fidl::encoding::HandleType<fidl::Resource, { fidl::ObjectType::RESOURCE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.resource, decoder, offset + 8, _depth)?;
4828            Ok(())
4829        }
4830    }
4831
4832    impl fidl::encoding::ResourceTypeMarker for BarResult {
4833        type Borrowed<'a> = &'a mut Self;
4834        fn take_or_borrow<'a>(
4835            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4836        ) -> Self::Borrowed<'a> {
4837            value
4838        }
4839    }
4840
4841    unsafe impl fidl::encoding::TypeMarker for BarResult {
4842        type Owned = Self;
4843
4844        #[inline(always)]
4845        fn inline_align(_context: fidl::encoding::Context) -> usize {
4846            8
4847        }
4848
4849        #[inline(always)]
4850        fn inline_size(_context: fidl::encoding::Context) -> usize {
4851            16
4852        }
4853    }
4854
4855    unsafe impl fidl::encoding::Encode<BarResult, fidl::encoding::DefaultFuchsiaResourceDialect>
4856        for &mut BarResult
4857    {
4858        #[inline]
4859        unsafe fn encode(
4860            self,
4861            encoder: &mut fidl::encoding::Encoder<
4862                '_,
4863                fidl::encoding::DefaultFuchsiaResourceDialect,
4864            >,
4865            offset: usize,
4866            _depth: fidl::encoding::Depth,
4867        ) -> fidl::Result<()> {
4868            encoder.debug_check_bounds::<BarResult>(offset);
4869            encoder.write_num::<u64>(self.ordinal(), offset);
4870            match self {
4871                BarResult::Io(ref mut val) => fidl::encoding::encode_in_envelope::<
4872                    IoBar,
4873                    fidl::encoding::DefaultFuchsiaResourceDialect,
4874                >(
4875                    <IoBar as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
4876                    encoder,
4877                    offset + 8,
4878                    _depth,
4879                ),
4880                BarResult::Vmo(ref mut val) => fidl::encoding::encode_in_envelope::<
4881                    fidl::encoding::HandleType<
4882                        fidl::Vmo,
4883                        { fidl::ObjectType::VMO.into_raw() },
4884                        2147483648,
4885                    >,
4886                    fidl::encoding::DefaultFuchsiaResourceDialect,
4887                >(
4888                    <fidl::encoding::HandleType<
4889                        fidl::Vmo,
4890                        { fidl::ObjectType::VMO.into_raw() },
4891                        2147483648,
4892                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4893                        val
4894                    ),
4895                    encoder,
4896                    offset + 8,
4897                    _depth,
4898                ),
4899                BarResult::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
4900            }
4901        }
4902    }
4903
4904    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BarResult {
4905        #[inline(always)]
4906        fn new_empty() -> Self {
4907            Self::__SourceBreaking { unknown_ordinal: 0 }
4908        }
4909
4910        #[inline]
4911        unsafe fn decode(
4912            &mut self,
4913            decoder: &mut fidl::encoding::Decoder<
4914                '_,
4915                fidl::encoding::DefaultFuchsiaResourceDialect,
4916            >,
4917            offset: usize,
4918            mut depth: fidl::encoding::Depth,
4919        ) -> fidl::Result<()> {
4920            decoder.debug_check_bounds::<Self>(offset);
4921            #[allow(unused_variables)]
4922            let next_out_of_line = decoder.next_out_of_line();
4923            let handles_before = decoder.remaining_handles();
4924            let (ordinal, inlined, num_bytes, num_handles) =
4925                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4926
4927            let member_inline_size = match ordinal {
4928                1 => <IoBar as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4929                2 => <fidl::encoding::HandleType<
4930                    fidl::Vmo,
4931                    { fidl::ObjectType::VMO.into_raw() },
4932                    2147483648,
4933                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4934                0 => return Err(fidl::Error::UnknownUnionTag),
4935                _ => num_bytes as usize,
4936            };
4937
4938            if inlined != (member_inline_size <= 4) {
4939                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4940            }
4941            let _inner_offset;
4942            if inlined {
4943                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4944                _inner_offset = offset + 8;
4945            } else {
4946                depth.increment()?;
4947                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4948            }
4949            match ordinal {
4950                1 => {
4951                    #[allow(irrefutable_let_patterns)]
4952                    if let BarResult::Io(_) = self {
4953                        // Do nothing, read the value into the object
4954                    } else {
4955                        // Initialize `self` to the right variant
4956                        *self = BarResult::Io(fidl::new_empty!(
4957                            IoBar,
4958                            fidl::encoding::DefaultFuchsiaResourceDialect
4959                        ));
4960                    }
4961                    #[allow(irrefutable_let_patterns)]
4962                    if let BarResult::Io(ref mut val) = self {
4963                        fidl::decode!(
4964                            IoBar,
4965                            fidl::encoding::DefaultFuchsiaResourceDialect,
4966                            val,
4967                            decoder,
4968                            _inner_offset,
4969                            depth
4970                        )?;
4971                    } else {
4972                        unreachable!()
4973                    }
4974                }
4975                2 => {
4976                    #[allow(irrefutable_let_patterns)]
4977                    if let BarResult::Vmo(_) = self {
4978                        // Do nothing, read the value into the object
4979                    } else {
4980                        // Initialize `self` to the right variant
4981                        *self = BarResult::Vmo(
4982                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
4983                        );
4984                    }
4985                    #[allow(irrefutable_let_patterns)]
4986                    if let BarResult::Vmo(ref mut val) = self {
4987                        fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
4988                    } else {
4989                        unreachable!()
4990                    }
4991                }
4992                #[allow(deprecated)]
4993                ordinal => {
4994                    for _ in 0..num_handles {
4995                        decoder.drop_next_handle()?;
4996                    }
4997                    *self = BarResult::__SourceBreaking { unknown_ordinal: ordinal };
4998                }
4999            }
5000            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
5001                return Err(fidl::Error::InvalidNumBytesInEnvelope);
5002            }
5003            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5004                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5005            }
5006            Ok(())
5007        }
5008    }
5009}