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