Skip to main content

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