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